From 043ce1cb276bdce52d32ddf506c6a2da6aaa1e2e Mon Sep 17 00:00:00 2001 From: Mikhail Zarechenskiy Date: Sun, 29 Jul 2018 21:14:59 +0200 Subject: [PATCH] Support secondary constructors for inline classes #KT-25614 Fixed #KT-25246 Fixed KT-25599 Will be fixed after recompilation of unsigned classes --- .../kotlin/codegen/ConstructorCodegen.java | 23 +++++++++-- .../codegen/ErasedInlineClassBodyCodegen.kt | 33 ++++++++++++++- .../kotlin/codegen/ExpressionCodegen.java | 7 +++- .../codegen/state/KotlinTypeMapper.java | 26 +++++++++--- .../jvm/lower/JvmStaticAnnotationLowering.kt | 2 +- .../codegen/box/inlineClasses/kt25246.kt | 40 +++++++++++++++++++ .../secondaryConstructorsInsideInlineClass.kt | 29 ++++++++++++++ .../companionObjectInsideInlineClass.txt | 1 + .../computablePropertiesInsideInlineClass.txt | 1 + .../noBridgesForErasedInlineClass.txt | 1 + .../shapeOfInlineClassWithPrimitive.txt | 1 + ...sertionsForParametersOfInlineClassTypes.kt | 4 +- .../ir/IrBlackBoxCodegenTestGenerated.java | 10 +++++ .../codegen/BlackBoxCodegenTestGenerated.java | 10 +++++ .../LightAnalysisModeTestGenerated.java | 10 +++++ .../jetbrains/kotlin/load/java/JvmAbi.java | 3 +- .../IrJsCodegenBoxTestGenerated.java | 10 +++++ .../semantics/JsCodegenBoxTestGenerated.java | 10 +++++ 18 files changed, 204 insertions(+), 17 deletions(-) create mode 100644 compiler/testData/codegen/box/inlineClasses/kt25246.kt create mode 100644 compiler/testData/codegen/box/inlineClasses/secondaryConstructorsInsideInlineClass.kt diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ConstructorCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ConstructorCodegen.java index 2e53320fa29..b05eb601d52 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ConstructorCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ConstructorCodegen.java @@ -174,6 +174,13 @@ public class ConstructorCodegen { markLineNumberForConstructor(constructorDescriptor, primaryConstructor, codegen); + if (OwnerKind.ERASED_INLINE_CLASS == kind) { + Type t = typeMapper.mapType(constructorDescriptor.getContainingDeclaration()); + iv.load(0, t); + iv.areturn(t); + return; + } + generateClosureInitialization(iv); generateDelegatorToConstructorCall( @@ -237,7 +244,12 @@ public class ConstructorCodegen { codegen.gen(constructor.getBodyExpression(), Type.VOID_TYPE); } - iv.visitInsn(RETURN); + if (OwnerKind.ERASED_INLINE_CLASS == kind) { + iv.areturn(typeMapper.mapType(constructorDescriptor.getContainingDeclaration())); + } + else { + iv.visitInsn(RETURN); + } } private void genCallToDelegatorByExpressionSpecifier( @@ -278,13 +290,16 @@ public class ConstructorCodegen { @NotNull ClassConstructorDescriptor constructorDescriptor, @NotNull ResolvedCall delegationConstructorCall ) { - iv.load(0, OBJECT_TYPE); + if (OwnerKind.ERASED_INLINE_CLASS != kind) { + iv.load(0, OBJECT_TYPE); + } + ConstructorDescriptor delegateConstructor = SamCodegenUtil.resolveSamAdapter(codegen.getConstructorDescriptor(delegationConstructorCall)); KotlinTypeMapper typeMapper = state.getTypeMapper(); - CallableMethod delegateConstructorCallable = typeMapper.mapToCallableMethod(delegateConstructor, false); - CallableMethod callable = typeMapper.mapToCallableMethod(constructorDescriptor, false); + CallableMethod delegateConstructorCallable = typeMapper.mapToCallableMethod(delegateConstructor, false, kind); + CallableMethod callable = typeMapper.mapToCallableMethod(constructorDescriptor, false, kind); List delegatingParameters = delegateConstructorCallable.getValueParameters(); List parameters = callable.getValueParameters(); diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ErasedInlineClassBodyCodegen.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/ErasedInlineClassBodyCodegen.kt index b96752851fc..2fad45da68f 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ErasedInlineClassBodyCodegen.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ErasedInlineClassBodyCodegen.kt @@ -12,10 +12,12 @@ import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper import org.jetbrains.kotlin.descriptors.FunctionDescriptor import org.jetbrains.kotlin.psi.KtClass import org.jetbrains.kotlin.resolve.InlineClassDescriptorResolver +import org.jetbrains.kotlin.resolve.descriptorUtil.secondaryConstructors import org.jetbrains.kotlin.resolve.jvm.diagnostics.Synthetic import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodGenericSignature import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature import org.jetbrains.org.objectweb.asm.Opcodes +import org.jetbrains.org.objectweb.asm.Type class ErasedInlineClassBodyCodegen( aClass: KtClass, @@ -24,19 +26,46 @@ class ErasedInlineClassBodyCodegen( state: GenerationState, parentCodegen: MemberCodegen<*>? ) : ClassBodyCodegen(aClass, context, v, state, parentCodegen) { + + private val superClassAsmType: Type by lazy { + SuperClassInfo.getSuperClassInfo(descriptor, typeMapper).type + } + + private val classAsmType = typeMapper.mapErasedInlineClass(descriptor) + + private val constructorCodegen = ConstructorCodegen( + descriptor, context, functionCodegen, this, this, state, kind, v, classAsmType, aClass, bindingContext + ) + override fun generateDeclaration() { v.defineClass( myClass.psiOrParent, state.classFileVersion, Opcodes.ACC_FINAL or Opcodes.ACC_STATIC or Opcodes.ACC_PUBLIC, - typeMapper.mapErasedInlineClass(descriptor).internalName, - null, "java/lang/Object", ArrayUtil.EMPTY_STRING_ARRAY + classAsmType.internalName, null, "java/lang/Object", ArrayUtil.EMPTY_STRING_ARRAY ) v.visitSource(myClass.containingKtFile.name, null) } + override fun generateConstructors() { + val delegationFieldsInfo = DelegationFieldsInfo(classAsmType, descriptor, state, bindingContext) + + constructorCodegen.generatePrimaryConstructor( + delegationFieldsInfo.getDelegationFieldsInfo(myClass.superTypeListEntries), superClassAsmType + ) + + for (secondaryConstructor in descriptor.secondaryConstructors) { + constructorCodegen.generateSecondaryConstructor(secondaryConstructor, superClassAsmType) + } + } + override fun generateSyntheticPartsAfterBody() { super.generateSyntheticPartsAfterBody() + generateUnboxMethod() + } + + private fun generateUnboxMethod() { val boxMethodDescriptor = InlineClassDescriptorResolver.createBoxFunctionDescriptor(descriptor) ?: return + functionCodegen.generateMethod( Synthetic(null, boxMethodDescriptor), boxMethodDescriptor, object : FunctionGenerationStrategy.CodegenBased(state) { override fun mapMethodSignature( diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java index b2adac2797c..62e8ef1f5d7 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java @@ -2152,7 +2152,8 @@ public class ExpressionCodegen extends KtVisitor impleme FunctionDescriptor descriptor = accessibleFunctionDescriptor(resolvedCall); if (descriptor instanceof ConstructorDescriptor) { - if (InlineClassesUtilsKt.isInlineClass(descriptor.getContainingDeclaration())) { + if (InlineClassesUtilsKt.isInlineClass(descriptor.getContainingDeclaration()) && ((ConstructorDescriptor) descriptor).isPrimary()) { + // we do not call static function `constructor`, because it's empty return generateInlineClassConstructorCall(expression); } @@ -4151,7 +4152,9 @@ public class ExpressionCodegen extends KtVisitor impleme ); constructor = SamCodegenUtil.resolveSamAdapter(constructor); - CallableMethod method = typeMapper.mapToCallableMethod(constructor, false); + OwnerKind inlineClassKindOrNull = + InlineClassesUtilsKt.isInlineClass(constructor.getContainingDeclaration()) ? OwnerKind.ERASED_INLINE_CLASS : null; + CallableMethod method = typeMapper.mapToCallableMethod(constructor, false, inlineClassKindOrNull); invokeMethodWithArguments(method, resolvedCall, StackValue.none()); return Unit.INSTANCE; diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/KotlinTypeMapper.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/KotlinTypeMapper.java index e3256b746c9..5a7d3c067c5 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/KotlinTypeMapper.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/KotlinTypeMapper.java @@ -780,8 +780,9 @@ public class KotlinTypeMapper { } @NotNull - public CallableMethod mapToCallableMethod(@NotNull FunctionDescriptor descriptor, boolean superCall) { - if (descriptor instanceof ConstructorDescriptor) { + public CallableMethod mapToCallableMethod(@NotNull FunctionDescriptor descriptor, boolean superCall, @Nullable OwnerKind kind) { + // we generate constructors of inline classes as usual functions + if (descriptor instanceof ConstructorDescriptor && kind != OwnerKind.ERASED_INLINE_CLASS) { JvmMethodSignature method = mapSignatureSkipGeneric(descriptor.getOriginal()); Type owner = mapOwner(descriptor); FunctionDescriptor originalDescriptor = descriptor.getOriginal(); @@ -948,6 +949,11 @@ public class KotlinTypeMapper { ); } + @NotNull + public CallableMethod mapToCallableMethod(@NotNull FunctionDescriptor descriptor, boolean superCall) { + return mapToCallableMethod(descriptor, superCall, null); + } + public static boolean isAccessor(@Nullable CallableMemberDescriptor descriptor) { return descriptor instanceof AccessorForCallableDescriptor || descriptor instanceof AccessorForCompanionObjectInstanceFieldDescriptor; @@ -978,7 +984,7 @@ public class KotlinTypeMapper { } @NotNull - public String mapFunctionName(@NotNull FunctionDescriptor descriptor) { + public String mapFunctionName(@NotNull FunctionDescriptor descriptor, @Nullable OwnerKind kind) { if (!(descriptor instanceof JavaCallableMemberDescriptor)) { String platformName = getJvmName(descriptor); if (platformName != null) return platformName; @@ -1021,6 +1027,9 @@ public class KotlinTypeMapper { else if (isLocalFunction(descriptor) || isFunctionExpression(descriptor)) { return OperatorNameConventions.INVOKE.asString(); } + else if (OwnerKind.ERASED_INLINE_CLASS == kind && descriptor instanceof ConstructorDescriptor) { + return JvmAbi.ERASED_INLINE_CONSTRUCTOR_NAME; + } else { return mangleMemberNameIfRequired(descriptor.getName().asString(), descriptor); } @@ -1222,7 +1231,14 @@ public class KotlinTypeMapper { writeParameter(sw, JvmMethodParameterKind.CONSTRUCTOR_MARKER, DEFAULT_CONSTRUCTOR_MARKER); } - writeVoidReturn(sw); + if (OwnerKind.ERASED_INLINE_CLASS == kind) { + sw.writeReturnType(); + sw.writeAsmType(mapType(((ClassConstructorDescriptor) f).getContainingDeclaration())); + sw.writeReturnTypeEnd(); + } + else { + writeVoidReturn(sw); + } } else { CallableMemberDescriptor directMember = DescriptorUtils.getDirectMember(f); @@ -1263,7 +1279,7 @@ public class KotlinTypeMapper { sw.writeReturnTypeEnd(); } - JvmMethodGenericSignature signature = sw.makeJvmMethodSignature(mapFunctionName(f)); + JvmMethodGenericSignature signature = sw.makeJvmMethodSignature(mapFunctionName(f, kind)); if (kind != OwnerKind.DEFAULT_IMPLS && kind != OwnerKind.ERASED_INLINE_CLASS && !hasSpecialBridge) { SpecialSignatureInfo specialSignatureInfo = BuiltinMethodsWithSpecialGenericSignature.getSpecialSignatureInfo(f); diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmStaticAnnotationLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmStaticAnnotationLowering.kt index 0606208a170..f70bcdb7c23 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmStaticAnnotationLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmStaticAnnotationLowering.kt @@ -56,7 +56,7 @@ private class CompanionObjectJvmStaticLowering(val context: JvmBackendContext) : companion?.declarations?.filter(::isJvmStaticFunction)?.forEach { val jvmStaticFunction = it as IrSimpleFunction - val newName = Name.identifier(context.state.typeMapper.mapFunctionName(jvmStaticFunction.symbol.descriptor)) + val newName = Name.identifier(context.state.typeMapper.mapFunctionName(jvmStaticFunction.symbol.descriptor, null)) if (AsmUtil.getVisibilityAccessFlag(jvmStaticFunction.descriptor) != Opcodes.ACC_PUBLIC) { // TODO: Synthetic accessor creation logic should be supported in SyntheticAccessorLowering in the future. val accessorName = Name.identifier("access\$$newName") diff --git a/compiler/testData/codegen/box/inlineClasses/kt25246.kt b/compiler/testData/codegen/box/inlineClasses/kt25246.kt new file mode 100644 index 00000000000..3abf4966284 --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/kt25246.kt @@ -0,0 +1,40 @@ +// !LANGUAGE: +InlineClasses +// IGNORE_BACKEND: JVM_IR, JS_IR + +inline class Rgba(val value: Int) { + inline val r: Int get() = (value shr 0) and 0xFF + inline val g: Int get() = (value shr 8) and 0xFF + inline val b: Int get() = (value shr 16) and 0xFF + inline val a: Int get() = (value shr 24) and 0xFF +} + +fun Rgba(r: Int, g: Int, b: Int, a: Int): Rgba { + return Rgba( + ((r and 0xFF) shl 0) or ((g and 0xFF) shl 8) or ((b and 0xFF) shl 16) or ((a and 0xFF) shl 24) + ) +} + +fun Rgba.withR(r: Int) = Rgba(r, g, b, a) +fun Rgba.withG(g: Int) = Rgba(r, g, b, a) +fun Rgba.withB(b: Int) = Rgba(r, g, b, a) +fun Rgba.withA(a: Int) = Rgba(r, g, b, a) + +inline class RgbaArray(val array: IntArray) { + constructor(size: Int) : this(IntArray(size)) + operator fun get(index: Int): Rgba = Rgba(array[index]) + operator fun set(index: Int, color: Rgba) { + array[index] = color.value + } +} + +fun box(): String { + val result1 = RgbaArray(32) + val result2 = RgbaArray(IntArray(32)) + val color = Rgba(128, 128, 0, 255) + result1[0] = color.withG(64).withA(0) + result2[0] = color.withG(64).withA(0) + if (result1[0].value != result2[0].value) return "Fail 1" + if (result1[0].value != 16512) return "Fail 2" + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/secondaryConstructorsInsideInlineClass.kt b/compiler/testData/codegen/box/inlineClasses/secondaryConstructorsInsideInlineClass.kt new file mode 100644 index 00000000000..8b6e6d3d69e --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/secondaryConstructorsInsideInlineClass.kt @@ -0,0 +1,29 @@ +// !LANGUAGE: +InlineClasses +// IGNORE_BACKEND: JVM_IR + +var global = "wrong" + +inline class Foo(val x: String) { + constructor(y: Int) : this(y.toString()) + constructor(z: Long) : this(z.toInt() + 1) + constructor(other: Char) : this(other.toInt().toString()) { + global = "OK" + } + constructor(a: Int, b: Int) : this((a + b).toString()) +} + +fun box(): String { + var f = Foo(42) + if (f.x != "42") return "Fail 1: ${f.x}" + + f = Foo(43L) + if (f.x != "44") return "Fail 2: ${f.x}" + + f = Foo('a') + if (f.x != "97") return "Fail 3: ${f.x}" + + f = Foo(1, 2) + if (f.x != "3") return "Fail 4: ${f.x}" + + return global +} \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/companionObjectInsideInlineClass.txt b/compiler/testData/codegen/bytecodeListing/inlineClasses/companionObjectInsideInlineClass.txt index 416e384f13c..8c1aaf4ef55 100644 --- a/compiler/testData/codegen/bytecodeListing/inlineClasses/companionObjectInsideInlineClass.txt +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/companionObjectInsideInlineClass.txt @@ -9,6 +9,7 @@ public final class Foo$Companion { @kotlin.Metadata public final static class Foo$Erased { public final static @org.jetbrains.annotations.NotNull method box(p0: int): Foo + public static method constructor(p0: int): int public final static method inInlineClass(p0: int): void } diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/computablePropertiesInsideInlineClass.txt b/compiler/testData/codegen/bytecodeListing/inlineClasses/computablePropertiesInsideInlineClass.txt index 0c286604a0e..f9755e53e69 100644 --- a/compiler/testData/codegen/bytecodeListing/inlineClasses/computablePropertiesInsideInlineClass.txt +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/computablePropertiesInsideInlineClass.txt @@ -1,6 +1,7 @@ @kotlin.Metadata public final static class Foo$Erased { public final static @org.jetbrains.annotations.NotNull method box(p0: int): Foo + public static method constructor(p0: int): int public final static method getAsThis(p0: int): int public final static method getProp(p0: int): int } diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/noBridgesForErasedInlineClass.txt b/compiler/testData/codegen/bytecodeListing/inlineClasses/noBridgesForErasedInlineClass.txt index 21e4fa431fe..56917b18bde 100644 --- a/compiler/testData/codegen/bytecodeListing/inlineClasses/noBridgesForErasedInlineClass.txt +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/noBridgesForErasedInlineClass.txt @@ -6,6 +6,7 @@ public interface A { @kotlin.Metadata public final static class Foo$Erased { public final static @org.jetbrains.annotations.NotNull method box(p0: long): Foo + public static method constructor(p0: long): long public static method foo(p0: long, p1: long): void } diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/shapeOfInlineClassWithPrimitive.txt b/compiler/testData/codegen/bytecodeListing/inlineClasses/shapeOfInlineClassWithPrimitive.txt index 94d688d8843..e479540ee91 100644 --- a/compiler/testData/codegen/bytecodeListing/inlineClasses/shapeOfInlineClassWithPrimitive.txt +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/shapeOfInlineClassWithPrimitive.txt @@ -1,6 +1,7 @@ @kotlin.Metadata public final static class Foo$Erased { public final static @org.jetbrains.annotations.NotNull method box(p0: long): Foo + public static method constructor(p0: long): long public final static method empty(p0: long): void public final static method extension(p0: long, @org.jetbrains.annotations.NotNull p1: java.lang.Object, @org.jetbrains.annotations.NotNull p2: java.lang.String): void public final static method param(p0: long, p1: double): void diff --git a/compiler/testData/codegen/bytecodeText/inlineClasses/assertionsForParametersOfInlineClassTypes.kt b/compiler/testData/codegen/bytecodeText/inlineClasses/assertionsForParametersOfInlineClassTypes.kt index cbe6995ef99..6b462abec91 100644 --- a/compiler/testData/codegen/bytecodeText/inlineClasses/assertionsForParametersOfInlineClassTypes.kt +++ b/compiler/testData/codegen/bytecodeText/inlineClasses/assertionsForParametersOfInlineClassTypes.kt @@ -1,7 +1,7 @@ // !LANGUAGE: +InlineClasses inline class AsNonNullPrimitive(val i: Int) -inline class AsNonNullReference(val s: String) // 2 assertions (constructor, box method) +inline class AsNonNullReference(val s: String) // 3 assertions (constructor, box method, static constructor in $Erased classs) fun nonNullPrimitive(a: AsNonNullPrimitive) {} @@ -11,4 +11,4 @@ fun AsNonNullReference.nonNullReferenceExtension(b1: AsNonNullReference) {} // 2 fun asNullablePrimitive(c: AsNonNullPrimitive?) {} fun asNullableReference(c: AsNonNullReference?) {} -// 5 checkParameterIsNotNull \ No newline at end of file +// 6 checkParameterIsNotNull \ No newline at end of file diff --git a/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java index cd73880263a..ef0928283c3 100644 --- a/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java @@ -11343,6 +11343,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/inlineClasses/iterateOverListOfInlineClassValues.kt"); } + @TestMetadata("kt25246.kt") + public void testKt25246() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/kt25246.kt"); + } + @TestMetadata("noAssertionsOnInlineClassBasedOnNullableType.kt") public void testNoAssertionsOnInlineClassBasedOnNullableType() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/noAssertionsOnInlineClassBasedOnNullableType.kt"); @@ -11373,6 +11378,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/inlineClasses/referToUnderlyingPropertyOfInlineClass.kt"); } + @TestMetadata("secondaryConstructorsInsideInlineClass.kt") + public void testSecondaryConstructorsInsideInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/secondaryConstructorsInsideInlineClass.kt"); + } + @TestMetadata("typeChecksForInlineClasses.kt") public void testTypeChecksForInlineClasses() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/typeChecksForInlineClasses.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java index a20ed45420f..3ccbd4ced02 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -11343,6 +11343,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/inlineClasses/iterateOverListOfInlineClassValues.kt"); } + @TestMetadata("kt25246.kt") + public void testKt25246() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/kt25246.kt"); + } + @TestMetadata("noAssertionsOnInlineClassBasedOnNullableType.kt") public void testNoAssertionsOnInlineClassBasedOnNullableType() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/noAssertionsOnInlineClassBasedOnNullableType.kt"); @@ -11373,6 +11378,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/inlineClasses/referToUnderlyingPropertyOfInlineClass.kt"); } + @TestMetadata("secondaryConstructorsInsideInlineClass.kt") + public void testSecondaryConstructorsInsideInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/secondaryConstructorsInsideInlineClass.kt"); + } + @TestMetadata("typeChecksForInlineClasses.kt") public void testTypeChecksForInlineClasses() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/typeChecksForInlineClasses.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index b51cfc09c11..94b84dbb766 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -11343,6 +11343,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/inlineClasses/iterateOverListOfInlineClassValues.kt"); } + @TestMetadata("kt25246.kt") + public void testKt25246() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/kt25246.kt"); + } + @TestMetadata("noAssertionsOnInlineClassBasedOnNullableType.kt") public void testNoAssertionsOnInlineClassBasedOnNullableType() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/noAssertionsOnInlineClassBasedOnNullableType.kt"); @@ -11373,6 +11378,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/inlineClasses/referToUnderlyingPropertyOfInlineClass.kt"); } + @TestMetadata("secondaryConstructorsInsideInlineClass.kt") + public void testSecondaryConstructorsInsideInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/secondaryConstructorsInsideInlineClass.kt"); + } + @TestMetadata("typeChecksForInlineClasses.kt") public void testTypeChecksForInlineClasses() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/typeChecksForInlineClasses.kt"); diff --git a/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/JvmAbi.java b/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/JvmAbi.java index a787d3a293a..f48c6104eff 100644 --- a/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/JvmAbi.java +++ b/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/JvmAbi.java @@ -25,7 +25,8 @@ import static org.jetbrains.kotlin.resolve.DescriptorUtils.isCompanionObject; public final class JvmAbi { public static final String DEFAULT_IMPLS_CLASS_NAME = "DefaultImpls"; - public static final String ERASED_INLINE_CLASS_NAME = "Erased"; + public static final String ERASED_INLINE_CONSTRUCTOR_NAME = "constructor"; + private static final String ERASED_INLINE_CLASS_NAME = "Erased"; public static final FqName JVM_FIELD_ANNOTATION_FQ_NAME = new FqName("kotlin.jvm.JvmField"); /** diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/IrJsCodegenBoxTestGenerated.java index ee925789526..366e5c1f512 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/IrJsCodegenBoxTestGenerated.java @@ -9973,6 +9973,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/inlineClasses/iterateOverListOfInlineClassValues.kt"); } + @TestMetadata("kt25246.kt") + public void testKt25246() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/kt25246.kt"); + } + @TestMetadata("noAssertionsOnInlineClassBasedOnNullableType.kt") public void testNoAssertionsOnInlineClassBasedOnNullableType() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/noAssertionsOnInlineClassBasedOnNullableType.kt"); @@ -10003,6 +10008,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/inlineClasses/referToUnderlyingPropertyOfInlineClass.kt"); } + @TestMetadata("secondaryConstructorsInsideInlineClass.kt") + public void testSecondaryConstructorsInsideInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/secondaryConstructorsInsideInlineClass.kt"); + } + @TestMetadata("typeChecksForInlineClasses.kt") public void testTypeChecksForInlineClasses() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/typeChecksForInlineClasses.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index 6b1c206c88e..01d2b6aeb64 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -10968,6 +10968,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/inlineClasses/iterateOverListOfInlineClassValues.kt"); } + @TestMetadata("kt25246.kt") + public void testKt25246() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/kt25246.kt"); + } + @TestMetadata("noAssertionsOnInlineClassBasedOnNullableType.kt") public void testNoAssertionsOnInlineClassBasedOnNullableType() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/noAssertionsOnInlineClassBasedOnNullableType.kt"); @@ -10998,6 +11003,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/inlineClasses/referToUnderlyingPropertyOfInlineClass.kt"); } + @TestMetadata("secondaryConstructorsInsideInlineClass.kt") + public void testSecondaryConstructorsInsideInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/secondaryConstructorsInsideInlineClass.kt"); + } + @TestMetadata("typeChecksForInlineClasses.kt") public void testTypeChecksForInlineClasses() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/typeChecksForInlineClasses.kt");