mirror of
https://github.com/fankes/moshi.git
synced 2025-10-19 16:09:21 +08:00
* Simplify parameterProperties and parameterProperties * Match only on synthetic constructors * Limit synthetic constructor keeps to kotlin classes
This commit is contained in:
@@ -36,8 +36,8 @@ import com.squareup.moshi.JsonReader
|
||||
import com.squareup.moshi.JsonWriter
|
||||
import com.squareup.moshi.Moshi
|
||||
import com.squareup.moshi.internal.Util
|
||||
import java.lang.reflect.Constructor
|
||||
import com.squareup.moshi.kotlin.codegen.JsonClassCodegenProcessor
|
||||
import java.lang.reflect.Constructor
|
||||
import java.lang.reflect.Type
|
||||
|
||||
private val MOSHI_UTIL = Util::class.asClassName()
|
||||
@@ -226,13 +226,8 @@ internal class AdapterGenerator(
|
||||
result.addStatement("%N.endObject()", readerParam)
|
||||
|
||||
var separator = "\n"
|
||||
var useDefaultsConstructor = false
|
||||
val parameterProperties = propertyList.asSequence()
|
||||
.filter { it.hasConstructorParameter }
|
||||
.onEach {
|
||||
useDefaultsConstructor = useDefaultsConstructor || it.hasDefault
|
||||
}
|
||||
.toList()
|
||||
val parameterProperties = propertyList.filter { it.hasConstructorParameter }
|
||||
val useDefaultsConstructor = parameterProperties.any { it.hasDefault }
|
||||
|
||||
val resultName = nameAllocator.newName("result")
|
||||
val hasNonConstructorProperties = nonTransientProperties.any { !it.hasConstructorParameter }
|
||||
|
@@ -22,8 +22,8 @@
|
||||
# We can't _just_ keep the defaults constructor because Proguard/R8's spec doesn't allow wildcard
|
||||
# matching preceding parameters.
|
||||
-keepnames class kotlin.jvm.internal.DefaultConstructorMarker
|
||||
-keepclassmembers @com.squareup.moshi.JsonClass class * {
|
||||
<init>(...);
|
||||
-keepclassmembers @com.squareup.moshi.JsonClass @kotlin.Metadata class * {
|
||||
synthetic <init>(...);
|
||||
}
|
||||
|
||||
# Retain generated JsonAdapters if annotated type is retained.
|
||||
|
Reference in New Issue
Block a user