Parcelable: Parcelize overrides describeContents despite being already implemented (KT-20026)
This commit is contained in:
committed by
Yan Zhulanow
parent
e645da64da
commit
32fc340d62
+4
-1
@@ -93,6 +93,7 @@ open class ParcelableResolveExtension : SyntheticResolveExtension {
|
|||||||
&& clazz.isParcelize
|
&& clazz.isParcelize
|
||||||
&& isExperimental()
|
&& isExperimental()
|
||||||
&& result.none { it.isDescribeContents() }
|
&& result.none { it.isDescribeContents() }
|
||||||
|
&& fromSupertypes.none { it.isDescribeContents() }
|
||||||
) {
|
) {
|
||||||
result += createMethod(clazz, DESCRIBE_CONTENTS, clazz.builtIns.intType)
|
result += createMethod(clazz, DESCRIBE_CONTENTS, clazz.builtIns.intType)
|
||||||
} else if (name.asString() == WRITE_TO_PARCEL.methodName
|
} else if (name.asString() == WRITE_TO_PARCEL.methodName
|
||||||
@@ -107,7 +108,9 @@ open class ParcelableResolveExtension : SyntheticResolveExtension {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun SimpleFunctionDescriptor.isDescribeContents(): Boolean {
|
private fun SimpleFunctionDescriptor.isDescribeContents(): Boolean {
|
||||||
return typeParameters.isEmpty()
|
return this.kind != CallableMemberDescriptor.Kind.FAKE_OVERRIDE
|
||||||
|
&& modality != Modality.ABSTRACT
|
||||||
|
&& typeParameters.isEmpty()
|
||||||
&& valueParameters.isEmpty()
|
&& valueParameters.isEmpty()
|
||||||
&& returnType?.let { type -> KotlinBuiltIns.isInt(type) } == true
|
&& returnType?.let { type -> KotlinBuiltIns.isInt(type) } == true
|
||||||
}
|
}
|
||||||
|
|||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
// CURIOUS_ABOUT describeContents
|
||||||
|
|
||||||
|
import kotlinx.android.parcel.*
|
||||||
|
import android.os.Parcelable
|
||||||
|
|
||||||
|
abstract class AbstractUser : Parcelable {
|
||||||
|
override fun describeContents() = 100
|
||||||
|
}
|
||||||
|
|
||||||
|
@Parcelize
|
||||||
|
class User(val firstName: String, val lastName: String, val age: Int, val isProUser: Boolean) : AbstractUser()
|
||||||
+53
@@ -0,0 +1,53 @@
|
|||||||
|
public abstract class AbstractUser : java/lang/Object, android/os/Parcelable {
|
||||||
|
public void <init>()
|
||||||
|
|
||||||
|
public int describeContents() {
|
||||||
|
LABEL (L0)
|
||||||
|
LINENUMBER (7)
|
||||||
|
BIPUSH (100)
|
||||||
|
IRETURN
|
||||||
|
LABEL (L1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class User$Companion : java/lang/Object {
|
||||||
|
private void <init>()
|
||||||
|
|
||||||
|
public void <init>(kotlin.jvm.internal.DefaultConstructorMarker p0)
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class User$Creator : java/lang/Object, android/os/Parcelable$Creator {
|
||||||
|
public void <init>()
|
||||||
|
|
||||||
|
public final java.lang.Object createFromParcel(android.os.Parcel p0)
|
||||||
|
|
||||||
|
public final User[] newArray(int p0)
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class User : AbstractUser {
|
||||||
|
public final static User$Creator CREATOR
|
||||||
|
|
||||||
|
public final static User$Companion Companion
|
||||||
|
|
||||||
|
private final int age
|
||||||
|
|
||||||
|
private final java.lang.String firstName
|
||||||
|
|
||||||
|
private final boolean isProUser
|
||||||
|
|
||||||
|
private final java.lang.String lastName
|
||||||
|
|
||||||
|
static void <clinit>()
|
||||||
|
|
||||||
|
public void <init>(java.lang.String p0, java.lang.String p1, int p2, boolean p3)
|
||||||
|
|
||||||
|
public final int getAge()
|
||||||
|
|
||||||
|
public final java.lang.String getFirstName()
|
||||||
|
|
||||||
|
public final java.lang.String getLastName()
|
||||||
|
|
||||||
|
public final boolean isProUser()
|
||||||
|
|
||||||
|
public final void writeToParcel(android.os.Parcel p0, int p1)
|
||||||
|
}
|
||||||
+6
@@ -54,6 +54,12 @@ public class ParcelBytecodeListingTestGenerated extends AbstractParcelBytecodeLi
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("describeContentsFromSuperType.kt")
|
||||||
|
public void testDescribeContentsFromSuperType() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/parcel/codegen/describeContentsFromSuperType.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("duplicatingClinit.kt")
|
@TestMetadata("duplicatingClinit.kt")
|
||||||
public void testDuplicatingClinit() throws Exception {
|
public void testDuplicatingClinit() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/parcel/codegen/duplicatingClinit.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/parcel/codegen/duplicatingClinit.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user