Not writing fake parameters of enum constructors to generic signature.
This commit is contained in:
@@ -322,7 +322,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
|
||||
signatureVisitor.writeSupersEnd();
|
||||
|
||||
return new JvmClassSignature(jvmName(), superClassAsmType.getInternalName(), superInterfaces, signatureVisitor.makeJavaString(),
|
||||
return new JvmClassSignature(jvmName(), superClassAsmType.getInternalName(), superInterfaces, signatureVisitor.makeJavaGenericSignature(),
|
||||
signatureVisitor.makeKotlinClassSignature());
|
||||
}
|
||||
|
||||
|
||||
@@ -346,7 +346,18 @@ public class BothSignatureWriter {
|
||||
public void writeParameterType(JvmMethodParameterKind parameterKind) {
|
||||
transitionState(State.PARAMETERS, State.PARAMETER);
|
||||
|
||||
push(signatureVisitor().visitParameterType());
|
||||
// This magic mimics the behavior of javac that enum constructor have these synthetic parameters in erased signature, but doesn't
|
||||
// have them in generic signature. IDEA relies on this behavior.
|
||||
if (parameterKind == JvmMethodParameterKind.ENUM_NAME || parameterKind == JvmMethodParameterKind.ENUM_ORDINAL) {
|
||||
generic = true;
|
||||
|
||||
// pushing dummy visitor, because we don't want these parameters to appear in generic JVM signature
|
||||
push(new SignatureWriter());
|
||||
}
|
||||
else {
|
||||
push(signatureVisitor().visitParameterType());
|
||||
}
|
||||
|
||||
jetSignatureWriter = new JetSignatureWriter();
|
||||
if (jvmCurrentType != null || jvmCurrentTypeArrayLevel != 0) {
|
||||
throw new IllegalStateException();
|
||||
@@ -476,7 +487,7 @@ public class BothSignatureWriter {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String makeJavaString() {
|
||||
public String makeJavaGenericSignature() {
|
||||
if (state != State.METHOD_END && state != State.CLASS_END) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
@@ -519,7 +530,7 @@ public class BothSignatureWriter {
|
||||
if (needGenerics) {
|
||||
return new JvmMethodSignature(
|
||||
makeAsmMethod(name),
|
||||
makeJavaString(),
|
||||
makeJavaGenericSignature(),
|
||||
makeKotlinMethodTypeParameters(),
|
||||
makeKotlinParameterTypes(),
|
||||
makeKotlinReturnTypeSignature()
|
||||
@@ -530,3 +541,4 @@ public class BothSignatureWriter {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
package test
|
||||
|
||||
enum class EnumWithGenericConstructorParameter(list: List<String>?) {
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace test
|
||||
|
||||
internal final enum class test.EnumWithGenericConstructorParameter : jet.Enum<test.EnumWithGenericConstructorParameter> {
|
||||
private final /*primary constructor*/ fun <init>(/*0*/ list: jet.List<jet.String>?): test.EnumWithGenericConstructorParameter
|
||||
public final override /*1*/ /*fake_override*/ fun name(): jet.String
|
||||
public final override /*1*/ /*fake_override*/ fun ordinal(): jet.Int
|
||||
internal final class object test.EnumWithGenericConstructorParameter.<class-object-for-EnumWithGenericConstructorParameter> {
|
||||
private final /*constructor*/ fun <init>(): test.EnumWithGenericConstructorParameter.<class-object-for-EnumWithGenericConstructorParameter>
|
||||
public final fun valueOf(/*0*/ value: jet.String): test.EnumWithGenericConstructorParameter
|
||||
public final fun values(): jet.Array<test.EnumWithGenericConstructorParameter>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package test
|
||||
|
||||
enum class EnumWithPrimitiveConstructorParameter(b: Boolean) {
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace test
|
||||
|
||||
internal final enum class test.EnumWithPrimitiveConstructorParameter : jet.Enum<test.EnumWithPrimitiveConstructorParameter> {
|
||||
private final /*primary constructor*/ fun <init>(/*0*/ b: jet.Boolean): test.EnumWithPrimitiveConstructorParameter
|
||||
public final override /*1*/ /*fake_override*/ fun name(): jet.String
|
||||
public final override /*1*/ /*fake_override*/ fun ordinal(): jet.Int
|
||||
internal final class object test.EnumWithPrimitiveConstructorParameter.<class-object-for-EnumWithPrimitiveConstructorParameter> {
|
||||
private final /*constructor*/ fun <init>(): test.EnumWithPrimitiveConstructorParameter.<class-object-for-EnumWithPrimitiveConstructorParameter>
|
||||
public final fun valueOf(/*0*/ value: jet.String): test.EnumWithPrimitiveConstructorParameter
|
||||
public final fun values(): jet.Array<test.EnumWithPrimitiveConstructorParameter>
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
namespace test
|
||||
|
||||
internal final enum class test.In : jet.Enum<test.In> {
|
||||
private final /*constructor*/ fun <init>(/*0*/ p0: jet.String?, /*1*/ p1: jet.Int): test.In
|
||||
private final /*constructor*/ fun <init>(): test.In
|
||||
public final override /*1*/ /*fake_override*/ fun name(): jet.String
|
||||
public final override /*1*/ /*fake_override*/ fun ordinal(): jet.Int
|
||||
internal final class object test.In.<class-object-for-In> {
|
||||
@@ -12,7 +12,7 @@ internal final enum class test.In : jet.Enum<test.In> {
|
||||
}
|
||||
}
|
||||
private final enum class test.Pr : jet.Enum<test.Pr> {
|
||||
private final /*constructor*/ fun <init>(/*0*/ p0: jet.String?, /*1*/ p1: jet.Int): test.Pr
|
||||
private final /*constructor*/ fun <init>(): test.Pr
|
||||
public final override /*1*/ /*fake_override*/ fun name(): jet.String
|
||||
public final override /*1*/ /*fake_override*/ fun ordinal(): jet.Int
|
||||
private final class object test.Pr.<class-object-for-Pr> {
|
||||
@@ -23,7 +23,7 @@ private final enum class test.Pr : jet.Enum<test.Pr> {
|
||||
}
|
||||
}
|
||||
public final enum class test.Pu : jet.Enum<test.Pu> {
|
||||
private final /*constructor*/ fun <init>(/*0*/ p0: jet.String?, /*1*/ p1: jet.Int): test.Pu
|
||||
private final /*constructor*/ fun <init>(): test.Pu
|
||||
public final override /*1*/ /*fake_override*/ fun name(): jet.String
|
||||
public final override /*1*/ /*fake_override*/ fun ordinal(): jet.Int
|
||||
public final class object test.Pu.<class-object-for-Pu> {
|
||||
|
||||
@@ -5,7 +5,7 @@ internal final class test.A : jet.Any {
|
||||
internal final class object test.A.<class-object-for-A> {
|
||||
private final /*constructor*/ fun <init>(): test.A.<class-object-for-A>
|
||||
internal final enum class test.A.<class-object-for-A>.E : jet.Enum<test.A.<class-object-for-A>.E> {
|
||||
private final /*constructor*/ fun <init>(/*0*/ p0: jet.String?, /*1*/ p1: jet.Int): test.A.<class-object-for-A>.E
|
||||
private final /*constructor*/ fun <init>(): test.A.<class-object-for-A>.E
|
||||
public final override /*1*/ /*fake_override*/ fun name(): jet.String
|
||||
public final override /*1*/ /*fake_override*/ fun ordinal(): jet.Int
|
||||
internal final class object test.A.<class-object-for-A>.E.<class-object-for-E> {
|
||||
|
||||
@@ -5,7 +5,7 @@ internal final class test.A : jet.Any {
|
||||
internal final class object test.A.<class-object-for-A> {
|
||||
private final /*constructor*/ fun <init>(): test.A.<class-object-for-A>
|
||||
internal final enum class test.A.<class-object-for-A>.E : jet.Enum<test.A.<class-object-for-A>.E> {
|
||||
private final /*constructor*/ fun <init>(/*0*/ p0: jet.String?, /*1*/ p1: jet.Int): test.A.<class-object-for-A>.E
|
||||
private final /*constructor*/ fun <init>(): test.A.<class-object-for-A>.E
|
||||
public final override /*1*/ /*fake_override*/ fun name(): jet.String
|
||||
public final override /*1*/ /*fake_override*/ fun ordinal(): jet.Int
|
||||
internal final class object test.A.<class-object-for-A>.E.<class-object-for-E> {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
namespace test
|
||||
|
||||
internal final enum class test.MyEnum : jet.Enum<test.MyEnum> {
|
||||
private final /*constructor*/ fun <init>(/*0*/ p0: jet.String?, /*1*/ p1: jet.Int): test.MyEnum
|
||||
private final /*constructor*/ fun <init>(): test.MyEnum
|
||||
public final override /*1*/ /*fake_override*/ fun name(): jet.String
|
||||
public final override /*1*/ /*fake_override*/ fun ordinal(): jet.Int
|
||||
internal final class object test.MyEnum.<class-object-for-MyEnum> {
|
||||
|
||||
@@ -110,6 +110,16 @@ public class LoadCompiledKotlinTestGenerated extends AbstractLoadCompiledKotlinT
|
||||
doTest("compiler/testData/loadKotlin/class/ClassTwoParams2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("EnumWithGenericConstructorParameter.kt")
|
||||
public void testEnumWithGenericConstructorParameter() throws Exception {
|
||||
doTest("compiler/testData/loadKotlin/class/EnumWithGenericConstructorParameter.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("EnumWithPrimitiveConstructorParameter.kt")
|
||||
public void testEnumWithPrimitiveConstructorParameter() throws Exception {
|
||||
doTest("compiler/testData/loadKotlin/class/EnumWithPrimitiveConstructorParameter.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("InheritClassSimple.kt")
|
||||
public void testInheritClassSimple() throws Exception {
|
||||
doTest("compiler/testData/loadKotlin/class/InheritClassSimple.kt");
|
||||
|
||||
+10
@@ -112,6 +112,16 @@ public class LazyResolveNamespaceComparingTestGenerated extends AbstractLazyReso
|
||||
doTestCheckingPrimaryConstructors("compiler/testData/loadKotlin/class/ClassTwoParams2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("EnumWithGenericConstructorParameter.kt")
|
||||
public void testEnumWithGenericConstructorParameter() throws Exception {
|
||||
doTestCheckingPrimaryConstructors("compiler/testData/loadKotlin/class/EnumWithGenericConstructorParameter.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("EnumWithPrimitiveConstructorParameter.kt")
|
||||
public void testEnumWithPrimitiveConstructorParameter() throws Exception {
|
||||
doTestCheckingPrimaryConstructors("compiler/testData/loadKotlin/class/EnumWithPrimitiveConstructorParameter.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("InheritClassSimple.kt")
|
||||
public void testInheritClassSimple() throws Exception {
|
||||
doTestCheckingPrimaryConstructors("compiler/testData/loadKotlin/class/InheritClassSimple.kt");
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
package testData.libraries
|
||||
|
||||
[[public final enum class Color(rgb : jet.Int, p1 : jet.Int, p2 : jet.Int) : jet.Enum<testData.libraries.Color> {
|
||||
[[public final enum class Color(rgb : jet.Int) : jet.Enum<testData.libraries.Color> {
|
||||
class object {
|
||||
[public final val BLUE : testData.libraries.Color] /* compiled code */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user