diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/AsmUtil.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/AsmUtil.java index 3ddfb676595..690b578eeb2 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/AsmUtil.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/AsmUtil.java @@ -20,6 +20,7 @@ import org.jetbrains.kotlin.codegen.context.CodegenContext; import org.jetbrains.kotlin.codegen.intrinsics.HashCode; import org.jetbrains.kotlin.codegen.intrinsics.IntrinsicMethods; import org.jetbrains.kotlin.codegen.state.GenerationState; +import org.jetbrains.kotlin.codegen.state.InlineClassManglingUtilsKt; import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper; import org.jetbrains.kotlin.config.JvmTarget; import org.jetbrains.kotlin.descriptors.*; @@ -402,6 +403,14 @@ public class AsmUtil { return ACC_PRIVATE; } + if (kind != OwnerKind.ERASED_INLINE_CLASS && + memberDescriptor instanceof ConstructorDescriptor && + !(memberDescriptor instanceof AccessorForConstructorDescriptor) && + InlineClassManglingUtilsKt.shouldHideConstructorDueToInlineClassTypeValueParameters((ConstructorDescriptor) memberDescriptor) + ) { + return ACC_PRIVATE; + } + if (isEffectivelyInlineOnly(memberDescriptor)) { return ACC_PRIVATE; } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ConstructorCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ConstructorCodegen.java index b05eb601d52..e643b13aa2c 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ConstructorCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ConstructorCodegen.java @@ -12,6 +12,7 @@ import org.jetbrains.kotlin.codegen.context.ConstructorContext; import org.jetbrains.kotlin.codegen.context.FieldOwnerContext; import org.jetbrains.kotlin.codegen.context.MethodContext; import org.jetbrains.kotlin.codegen.state.GenerationState; +import org.jetbrains.kotlin.codegen.state.InlineClassManglingUtilsKt; import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper; import org.jetbrains.kotlin.descriptors.*; import org.jetbrains.kotlin.psi.*; @@ -108,9 +109,16 @@ public class ConstructorCodegen { functionCodegen.generateDefaultIfNeeded(constructorContext, constructorDescriptor, OwnerKind.IMPLEMENTATION, DefaultParameterValueLoader.DEFAULT, null); + registerAccessorForHiddenConstructorIfNeeded(constructorDescriptor); + new DefaultParameterValueSubstitutor(state).generatePrimaryConstructorOverloadsIfNeeded(constructorDescriptor, v, memberCodegen, kind, myClass); } + private void registerAccessorForHiddenConstructorIfNeeded(ClassConstructorDescriptor descriptor) { + if (!InlineClassManglingUtilsKt.shouldHideConstructorDueToInlineClassTypeValueParameters(descriptor)) return; + context.getAccessor(descriptor, AccessorKind.NORMAL, null, null); + } + public void generateSecondaryConstructor( @NotNull ClassConstructorDescriptor constructorDescriptor, @NotNull Type superClassAsmType @@ -138,6 +146,8 @@ public class ConstructorCodegen { new DefaultParameterValueSubstitutor(state).generateOverloadsIfNeeded( constructor, constructorDescriptor, constructorDescriptor, kind, v, memberCodegen ); + + registerAccessorForHiddenConstructorIfNeeded(constructorDescriptor); } private void generateDelegatorToConstructorCall( diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java index 36326fac561..bc0bfa25f5d 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java @@ -36,6 +36,7 @@ import org.jetbrains.kotlin.codegen.range.forLoop.ForLoopGenerator; import org.jetbrains.kotlin.codegen.signature.BothSignatureWriter; import org.jetbrains.kotlin.codegen.signature.JvmSignatureWriter; import org.jetbrains.kotlin.codegen.state.GenerationState; +import org.jetbrains.kotlin.codegen.state.InlineClassManglingUtilsKt; import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper; import org.jetbrains.kotlin.codegen.when.SwitchCodegen; import org.jetbrains.kotlin.codegen.when.SwitchCodegenProvider; @@ -2256,10 +2257,23 @@ public class ExpressionCodegen extends KtVisitor impleme descriptor = CoroutineCodegenUtilKt.unwrapInitialDescriptorForSuspendFunction(descriptor); - // $default method is not private, so you need no accessor to call it - return CallUtilKt.usesDefaultArguments(resolvedCall) - ? descriptor - : context.accessibleDescriptor(descriptor, getSuperCallTarget(resolvedCall.getCall())); + if (CallUtilKt.usesDefaultArguments(resolvedCall)) { + // $default method is not private, so you need no accessor to call it + return descriptor; + } + else if (InlineClassManglingUtilsKt.shouldHideConstructorDueToInlineClassTypeValueParameters(descriptor)) { + // Constructors with inline class type value parameters should always be called using an accessor. + // NB this will require accessors even if the constructor itself is in a different module. + return new AccessorForConstructorDescriptor( + (ClassConstructorDescriptor) descriptor, + descriptor.getContainingDeclaration(), + getSuperCallTarget(resolvedCall.getCall()), + AccessorKind.NORMAL + ); + } + else { + return context.accessibleDescriptor(descriptor, getSuperCallTarget(resolvedCall.getCall())); + } } @NotNull diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/inlineClassManglingUtils.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/inlineClassManglingUtils.kt index 9b5790c6f4e..e252ddbb164 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/inlineClassManglingUtils.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/inlineClassManglingUtils.kt @@ -27,6 +27,16 @@ fun getInlineClassSignatureManglingSuffix(descriptor: CallableMemberDescriptor): return getInlineClassSignatureManglingSuffix(actualValueParameterTypes) } +fun shouldHideConstructorDueToInlineClassTypeValueParameters(descriptor: CallableMemberDescriptor): Boolean { + if (descriptor !is ClassConstructorDescriptor) return false + if (Visibilities.isPrivate(descriptor.visibility)) return false + if (descriptor.constructedClass.isInline) return false + + // TODO inner class in inline class + + return descriptor.valueParameters.any { it.type.requiresFunctionNameMangling() } +} + fun getInlineClassSignatureManglingSuffix(valueParameterTypes: List) = if (valueParameterTypes.none { it.requiresFunctionNameMangling() }) null diff --git a/compiler/testData/codegen/box/inlineClasses/hiddenConstructor/constructorWithDefaultParameters.kt b/compiler/testData/codegen/box/inlineClasses/hiddenConstructor/constructorWithDefaultParameters.kt new file mode 100644 index 00000000000..cb2496dbad0 --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/hiddenConstructor/constructorWithDefaultParameters.kt @@ -0,0 +1,9 @@ +// !LANGUAGE: +InlineClasses + +inline class S(val string: String) + +class Test(val x: S, val y: S = S("K")) { + val test = x.string + y.string +} + +fun box() = Test(S("O")).test \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/hiddenConstructor/delegatingSuperConstructorCall.kt b/compiler/testData/codegen/box/inlineClasses/hiddenConstructor/delegatingSuperConstructorCall.kt new file mode 100644 index 00000000000..3b50d927159 --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/hiddenConstructor/delegatingSuperConstructorCall.kt @@ -0,0 +1,9 @@ +// !LANGUAGE: +InlineClasses + +inline class S(val string: String) + +abstract class Base(val x: S) + +class Test(x: S) : Base(x) + +fun box() = Test(S("OK")).x.string \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/hiddenConstructor/delegatingSuperConstructorCallInSecondaryConstructor.kt b/compiler/testData/codegen/box/inlineClasses/hiddenConstructor/delegatingSuperConstructorCallInSecondaryConstructor.kt new file mode 100644 index 00000000000..21fffac8e8e --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/hiddenConstructor/delegatingSuperConstructorCallInSecondaryConstructor.kt @@ -0,0 +1,11 @@ +// !LANGUAGE: +InlineClasses + +inline class S(val string: String) + +abstract class Base(val x: S) + +class Test : Base { + constructor() : super(S("OK")) +} + +fun box() = Test().x.string \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/hiddenConstructor/delegatingThisConstructorCall.kt b/compiler/testData/codegen/box/inlineClasses/hiddenConstructor/delegatingThisConstructorCall.kt new file mode 100644 index 00000000000..12010ff4ba1 --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/hiddenConstructor/delegatingThisConstructorCall.kt @@ -0,0 +1,11 @@ +// !LANGUAGE: +InlineClasses + +inline class S(val string: String) + +class Test(val x: S, val y: S) { + constructor(x: S) : this(x, S("K")) + + val test = x.string + y.string +} + +fun box() = Test(S("O")).test \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/hiddenConstructor/enumClassConstructor.kt b/compiler/testData/codegen/box/inlineClasses/hiddenConstructor/enumClassConstructor.kt new file mode 100644 index 00000000000..498a7ef8e29 --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/hiddenConstructor/enumClassConstructor.kt @@ -0,0 +1,9 @@ +// !LANGUAGE: +InlineClasses + +inline class S(val string: String) + +enum class Test(val s: S) { + OK(S("OK")) +} + +fun box() = Test.OK.s.string \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/hiddenConstructor/innerClassConstructor.kt b/compiler/testData/codegen/box/inlineClasses/hiddenConstructor/innerClassConstructor.kt new file mode 100644 index 00000000000..171b43dbd47 --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/hiddenConstructor/innerClassConstructor.kt @@ -0,0 +1,11 @@ +// !LANGUAGE: +InlineClasses + +inline class S(val string: String) + +class Outer(val s1: S) { + inner class Inner(val s2: S) { + val test = s1.string + s2.string + } +} + +fun box() = Outer(S("O")).Inner(S("K")).test \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/hiddenConstructor/primaryConstructor.kt b/compiler/testData/codegen/box/inlineClasses/hiddenConstructor/primaryConstructor.kt new file mode 100644 index 00000000000..880b1408082 --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/hiddenConstructor/primaryConstructor.kt @@ -0,0 +1,7 @@ +// !LANGUAGE: +InlineClasses + +inline class S(val string: String) + +class Test(val s: S) + +fun box() = Test(S("OK")).s.string \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/hiddenConstructor/privateConstructor.kt b/compiler/testData/codegen/box/inlineClasses/hiddenConstructor/privateConstructor.kt new file mode 100644 index 00000000000..c94047d5493 --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/hiddenConstructor/privateConstructor.kt @@ -0,0 +1,11 @@ +// !LANGUAGE: +InlineClasses + +inline class S(val string: String) + +class Outer private constructor(val s: S) { + class Nested { + fun test(s: S) = Outer(s) + } +} + +fun box() = Outer.Nested().test(S("OK")).s.string \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/hiddenConstructor/sealedClassConstructor.kt b/compiler/testData/codegen/box/inlineClasses/hiddenConstructor/sealedClassConstructor.kt new file mode 100644 index 00000000000..bbe0e046b17 --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/hiddenConstructor/sealedClassConstructor.kt @@ -0,0 +1,9 @@ +// !LANGUAGE: +InlineClasses + +inline class S(val string: String) + +sealed class Sealed(val x: S) + +class Test(x: S) : Sealed(x) + +fun box() = Test(S("OK")).x.string \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/hiddenConstructor/secondaryConstructor.kt b/compiler/testData/codegen/box/inlineClasses/hiddenConstructor/secondaryConstructor.kt new file mode 100644 index 00000000000..5fa46b3101e --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/hiddenConstructor/secondaryConstructor.kt @@ -0,0 +1,9 @@ +// !LANGUAGE: +InlineClasses + +inline class S(val string: String) + +class Test(val s: S) { + constructor(x: String, s: S) : this(S(x + s.string)) +} + +fun box() = Test("O", S("K")).s.string \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineClassTypeParametersInConstructor.kt b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineClassTypeParametersInConstructor.kt new file mode 100644 index 00000000000..c8f0b7ffcba --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineClassTypeParametersInConstructor.kt @@ -0,0 +1,26 @@ +// !LANGUAGE: +InlineClasses + +inline class Z(val x: Int) + +interface PublicMarker +interface ProtectedMarker +interface PrivateMarker + + +open class TestBasic(val z: Z) { + constructor(z1: Z, publicMarker: PublicMarker) : this(z1) + protected constructor(z: Z, protectedMarker: ProtectedMarker) : this(z) + private constructor(z: Z, privateMarker: PrivateMarker) : this(z) +} + +sealed class TestSealed(val z: Z) { + class Case(z: Z) : TestSealed(z) +} + +enum class TestEnum(val z: Z) { + ANSWER(Z(42)) +} + +class TestInner { + inner class Inner(val z: Z) +} \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineClassTypeParametersInConstructor.txt b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineClassTypeParametersInConstructor.txt new file mode 100644 index 00000000000..b4eb187c274 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineClassTypeParametersInConstructor.txt @@ -0,0 +1,82 @@ +@kotlin.Metadata +public interface PrivateMarker + +@kotlin.Metadata +public interface ProtectedMarker + +@kotlin.Metadata +public interface PublicMarker + +@kotlin.Metadata +public class TestBasic { + private final field z: int + private method (p0: int): void + public synthetic method (p0: int, @org.jetbrains.annotations.NotNull p1: ProtectedMarker, p2: kotlin.jvm.internal.DefaultConstructorMarker): void + public synthetic method (p0: int, @org.jetbrains.annotations.NotNull p1: PublicMarker, p2: kotlin.jvm.internal.DefaultConstructorMarker): void + private method (p0: int, p1: PrivateMarker): void + private method (p0: int, p1: ProtectedMarker): void + private method (p0: int, p1: PublicMarker): void + public synthetic method (p0: int, p1: kotlin.jvm.internal.DefaultConstructorMarker): void + public final method getZ(): int +} + +@kotlin.Metadata +public final enum class TestEnum { + private synthetic final static field $VALUES: TestEnum[] + public final static field ANSWER: TestEnum + private final field z: int + static method (): void + protected method (p0: java.lang.String, p1: int, p2: int): void + public final method getZ(): int + public static method valueOf(p0: java.lang.String): TestEnum + public static method values(): TestEnum[] +} + +@kotlin.Metadata +public final class TestInner$Inner { + synthetic final field this$0: TestInner + private final field z: int + inner class TestInner$Inner + private method (p0: TestInner, p1: int): void + public synthetic method (p0: TestInner, p1: int, p2: kotlin.jvm.internal.DefaultConstructorMarker): void + public final method getZ(): int +} + +@kotlin.Metadata +public final class TestInner { + inner class TestInner$Inner + public method (): void +} + +@kotlin.Metadata +public final class TestSealed$Case { + inner class TestSealed$Case + private method (p0: int): void + public synthetic method (p0: int, p1: kotlin.jvm.internal.DefaultConstructorMarker): void +} + +@kotlin.Metadata +public abstract class TestSealed { + private final field z: int + inner class TestSealed$Case + private method (p0: int): void + public synthetic method (p0: int, p1: kotlin.jvm.internal.DefaultConstructorMarker): void + public final method getZ(): int +} + +@kotlin.Metadata +public final class Z { + private final field x: int + private synthetic method (p0: int): void + public synthetic final static @org.jetbrains.annotations.NotNull method box-impl(p0: int): Z + public static method constructor-impl(p0: int): int + public method equals(p0: java.lang.Object): boolean + public static method equals-impl(p0: int, @org.jetbrains.annotations.Nullable p1: java.lang.Object): boolean + public final static method equals-impl0(p0: int, p1: int): boolean + public final method getX(): int + public method hashCode(): int + public static method hashCode-impl(p0: int): int + public method toString(): java.lang.String + public static @org.jetbrains.annotations.NotNull method toString-impl(p0: int): java.lang.String + public synthetic final method unbox-impl(): int +} diff --git a/compiler/testData/compileKotlinAgainstKotlin/constructorWithInlineClassParametersInBinaryDependencies.kt b/compiler/testData/compileKotlinAgainstKotlin/constructorWithInlineClassParametersInBinaryDependencies.kt new file mode 100644 index 00000000000..164be2e2171 --- /dev/null +++ b/compiler/testData/compileKotlinAgainstKotlin/constructorWithInlineClassParametersInBinaryDependencies.kt @@ -0,0 +1,12 @@ +// !LANGUAGE: +InlineClasses +// FILE: A.kt +package lib + +inline class S(val string: String) + +class Test(val s: S) + +// FILE: B.kt +import lib.* + +fun box() = Test(S("OK")).s.string \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inlineClasses/constructorsJvmSignaturesClash.kt b/compiler/testData/diagnostics/tests/inlineClasses/constructorsJvmSignaturesClash.kt new file mode 100644 index 00000000000..113b9a76c9c --- /dev/null +++ b/compiler/testData/diagnostics/tests/inlineClasses/constructorsJvmSignaturesClash.kt @@ -0,0 +1,18 @@ +// !LANGUAGE: +InlineClasses +// !DIAGNOSTICS: -UNUSED_PARAMETER + +inline class X(val x: Int) +inline class Z(val x: Int) + +class TestOk1(val a: Int, val b: Int) { + constructor(x: X) : this(x.x, 1) +} + +class TestErr1(val a: Int) { + constructor(x: X) : this(x.x) +} + +class TestErr2(val a: Int, val b: Int) { + constructor(x: X) : this(x.x, 1) + constructor(z: Z) : this(z.x, 2) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inlineClasses/constructorsJvmSignaturesClash.txt b/compiler/testData/diagnostics/tests/inlineClasses/constructorsJvmSignaturesClash.txt new file mode 100644 index 00000000000..ad532517a91 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inlineClasses/constructorsJvmSignaturesClash.txt @@ -0,0 +1,47 @@ +package + +public final class TestErr1 { + public constructor TestErr1(/*0*/ x: X) + public constructor TestErr1(/*0*/ a: kotlin.Int) + public final val a: kotlin.Int + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public final class TestErr2 { + public constructor TestErr2(/*0*/ x: X) + public constructor TestErr2(/*0*/ z: Z) + public constructor TestErr2(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Int) + public final val a: kotlin.Int + public final val b: kotlin.Int + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public final class TestOk1 { + public constructor TestOk1(/*0*/ x: X) + public constructor TestOk1(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Int) + public final val a: kotlin.Int + public final val b: kotlin.Int + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public final inline class X { + public constructor X(/*0*/ x: kotlin.Int) + public final val x: kotlin.Int + public open override /*1*/ /*synthesized*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*synthesized*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*synthesized*/ fun toString(): kotlin.String +} + +public final inline class Z { + public constructor Z(/*0*/ x: kotlin.Int) + public final val x: kotlin.Int + public open override /*1*/ /*synthesized*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*synthesized*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*synthesized*/ fun toString(): kotlin.String +} diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java index dc786b94988..5ddf4e1d261 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java @@ -10872,6 +10872,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { runTest("compiler/testData/diagnostics/tests/inlineClasses/basicInlineClassDeclarationDisabled.kt"); } + @TestMetadata("constructorsJvmSignaturesClash.kt") + public void testConstructorsJvmSignaturesClash() throws Exception { + runTest("compiler/testData/diagnostics/tests/inlineClasses/constructorsJvmSignaturesClash.kt"); + } + @TestMetadata("delegatedPropertyInInlineClass.kt") public void testDelegatedPropertyInInlineClass() throws Exception { runTest("compiler/testData/diagnostics/tests/inlineClasses/delegatedPropertyInInlineClass.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java index a95c9690631..be9492537b6 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java @@ -10872,6 +10872,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing runTest("compiler/testData/diagnostics/tests/inlineClasses/basicInlineClassDeclarationDisabled.kt"); } + @TestMetadata("constructorsJvmSignaturesClash.kt") + public void testConstructorsJvmSignaturesClash() throws Exception { + runTest("compiler/testData/diagnostics/tests/inlineClasses/constructorsJvmSignaturesClash.kt"); + } + @TestMetadata("delegatedPropertyInInlineClass.kt") public void testDelegatedPropertyInInlineClass() throws Exception { runTest("compiler/testData/diagnostics/tests/inlineClasses/delegatedPropertyInInlineClass.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java index e158503d8be..29a2ef964c4 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -11938,6 +11938,69 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/syntheticAccessorsForPropertyOfInlineClassType.kt"); } } + + @TestMetadata("compiler/testData/codegen/box/inlineClasses/hiddenConstructor") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class HiddenConstructor extends AbstractBlackBoxCodegenTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); + } + + public void testAllFilesPresentInHiddenConstructor() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/hiddenConstructor"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true); + } + + @TestMetadata("constructorWithDefaultParameters.kt") + public void testConstructorWithDefaultParameters() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/hiddenConstructor/constructorWithDefaultParameters.kt"); + } + + @TestMetadata("delegatingSuperConstructorCall.kt") + public void testDelegatingSuperConstructorCall() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/hiddenConstructor/delegatingSuperConstructorCall.kt"); + } + + @TestMetadata("delegatingSuperConstructorCallInSecondaryConstructor.kt") + public void testDelegatingSuperConstructorCallInSecondaryConstructor() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/hiddenConstructor/delegatingSuperConstructorCallInSecondaryConstructor.kt"); + } + + @TestMetadata("delegatingThisConstructorCall.kt") + public void testDelegatingThisConstructorCall() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/hiddenConstructor/delegatingThisConstructorCall.kt"); + } + + @TestMetadata("enumClassConstructor.kt") + public void testEnumClassConstructor() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/hiddenConstructor/enumClassConstructor.kt"); + } + + @TestMetadata("innerClassConstructor.kt") + public void testInnerClassConstructor() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/hiddenConstructor/innerClassConstructor.kt"); + } + + @TestMetadata("primaryConstructor.kt") + public void testPrimaryConstructor() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/hiddenConstructor/primaryConstructor.kt"); + } + + @TestMetadata("privateConstructor.kt") + public void testPrivateConstructor() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/hiddenConstructor/privateConstructor.kt"); + } + + @TestMetadata("sealedClassConstructor.kt") + public void testSealedClassConstructor() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/hiddenConstructor/sealedClassConstructor.kt"); + } + + @TestMetadata("secondaryConstructor.kt") + public void testSecondaryConstructor() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/hiddenConstructor/secondaryConstructor.kt"); + } + } } @TestMetadata("compiler/testData/codegen/box/innerNested") diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeListingTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeListingTestGenerated.java index cfe5c78fc69..730074b492a 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeListingTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeListingTestGenerated.java @@ -289,6 +289,11 @@ public class BytecodeListingTestGenerated extends AbstractBytecodeListingTest { runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/inlineClassMembersVisibility.kt"); } + @TestMetadata("inlineClassTypeParametersInConstructor.kt") + public void testInlineClassTypeParametersInConstructor() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/inlineClassTypeParametersInConstructor.kt"); + } + @TestMetadata("inlineClassWithInlineClassUnderlyingType.kt") public void testInlineClassWithInlineClassUnderlyingType() throws Exception { runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/inlineClassWithInlineClassUnderlyingType.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstKotlinTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstKotlinTestGenerated.java index a4e5a9d5c4c..e7417feb83f 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstKotlinTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstKotlinTestGenerated.java @@ -78,6 +78,11 @@ public class CompileKotlinAgainstKotlinTestGenerated extends AbstractCompileKotl runTest("compiler/testData/compileKotlinAgainstKotlin/constructorVararg.kt"); } + @TestMetadata("constructorWithInlineClassParametersInBinaryDependencies.kt") + public void testConstructorWithInlineClassParametersInBinaryDependencies() throws Exception { + runTest("compiler/testData/compileKotlinAgainstKotlin/constructorWithInlineClassParametersInBinaryDependencies.kt"); + } + @TestMetadata("copySamOnInline.kt") public void testCopySamOnInline() throws Exception { runTest("compiler/testData/compileKotlinAgainstKotlin/copySamOnInline.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index f2c75c9fdbb..82e60a4f708 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -11938,6 +11938,69 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/syntheticAccessorsForPropertyOfInlineClassType.kt"); } } + + @TestMetadata("compiler/testData/codegen/box/inlineClasses/hiddenConstructor") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class HiddenConstructor extends AbstractLightAnalysisModeTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); + } + + public void testAllFilesPresentInHiddenConstructor() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/hiddenConstructor"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true); + } + + @TestMetadata("constructorWithDefaultParameters.kt") + public void testConstructorWithDefaultParameters() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/hiddenConstructor/constructorWithDefaultParameters.kt"); + } + + @TestMetadata("delegatingSuperConstructorCall.kt") + public void testDelegatingSuperConstructorCall() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/hiddenConstructor/delegatingSuperConstructorCall.kt"); + } + + @TestMetadata("delegatingSuperConstructorCallInSecondaryConstructor.kt") + public void testDelegatingSuperConstructorCallInSecondaryConstructor() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/hiddenConstructor/delegatingSuperConstructorCallInSecondaryConstructor.kt"); + } + + @TestMetadata("delegatingThisConstructorCall.kt") + public void testDelegatingThisConstructorCall() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/hiddenConstructor/delegatingThisConstructorCall.kt"); + } + + @TestMetadata("enumClassConstructor.kt") + public void testEnumClassConstructor() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/hiddenConstructor/enumClassConstructor.kt"); + } + + @TestMetadata("innerClassConstructor.kt") + public void testInnerClassConstructor() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/hiddenConstructor/innerClassConstructor.kt"); + } + + @TestMetadata("primaryConstructor.kt") + public void testPrimaryConstructor() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/hiddenConstructor/primaryConstructor.kt"); + } + + @TestMetadata("privateConstructor.kt") + public void testPrivateConstructor() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/hiddenConstructor/privateConstructor.kt"); + } + + @TestMetadata("sealedClassConstructor.kt") + public void testSealedClassConstructor() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/hiddenConstructor/sealedClassConstructor.kt"); + } + + @TestMetadata("secondaryConstructor.kt") + public void testSecondaryConstructor() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/hiddenConstructor/secondaryConstructor.kt"); + } + } } @TestMetadata("compiler/testData/codegen/box/innerNested") diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java index 48aafbca736..4194e7e49ba 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java @@ -11938,6 +11938,69 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/syntheticAccessorsForPropertyOfInlineClassType.kt"); } } + + @TestMetadata("compiler/testData/codegen/box/inlineClasses/hiddenConstructor") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class HiddenConstructor extends AbstractIrBlackBoxCodegenTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInHiddenConstructor() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/hiddenConstructor"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM_IR, true); + } + + @TestMetadata("constructorWithDefaultParameters.kt") + public void testConstructorWithDefaultParameters() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/hiddenConstructor/constructorWithDefaultParameters.kt"); + } + + @TestMetadata("delegatingSuperConstructorCall.kt") + public void testDelegatingSuperConstructorCall() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/hiddenConstructor/delegatingSuperConstructorCall.kt"); + } + + @TestMetadata("delegatingSuperConstructorCallInSecondaryConstructor.kt") + public void testDelegatingSuperConstructorCallInSecondaryConstructor() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/hiddenConstructor/delegatingSuperConstructorCallInSecondaryConstructor.kt"); + } + + @TestMetadata("delegatingThisConstructorCall.kt") + public void testDelegatingThisConstructorCall() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/hiddenConstructor/delegatingThisConstructorCall.kt"); + } + + @TestMetadata("enumClassConstructor.kt") + public void testEnumClassConstructor() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/hiddenConstructor/enumClassConstructor.kt"); + } + + @TestMetadata("innerClassConstructor.kt") + public void testInnerClassConstructor() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/hiddenConstructor/innerClassConstructor.kt"); + } + + @TestMetadata("primaryConstructor.kt") + public void testPrimaryConstructor() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/hiddenConstructor/primaryConstructor.kt"); + } + + @TestMetadata("privateConstructor.kt") + public void testPrivateConstructor() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/hiddenConstructor/privateConstructor.kt"); + } + + @TestMetadata("sealedClassConstructor.kt") + public void testSealedClassConstructor() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/hiddenConstructor/sealedClassConstructor.kt"); + } + + @TestMetadata("secondaryConstructor.kt") + public void testSecondaryConstructor() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/hiddenConstructor/secondaryConstructor.kt"); + } + } } @TestMetadata("compiler/testData/codegen/box/innerNested") 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 76a4cd415c7..e96dc407ead 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 @@ -10473,6 +10473,69 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/syntheticAccessorsForPropertyOfInlineClassType.kt"); } } + + @TestMetadata("compiler/testData/codegen/box/inlineClasses/hiddenConstructor") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class HiddenConstructor extends AbstractIrJsCodegenBoxTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath); + } + + public void testAllFilesPresentInHiddenConstructor() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/hiddenConstructor"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JS_IR, true); + } + + @TestMetadata("constructorWithDefaultParameters.kt") + public void testConstructorWithDefaultParameters() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/hiddenConstructor/constructorWithDefaultParameters.kt"); + } + + @TestMetadata("delegatingSuperConstructorCall.kt") + public void testDelegatingSuperConstructorCall() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/hiddenConstructor/delegatingSuperConstructorCall.kt"); + } + + @TestMetadata("delegatingSuperConstructorCallInSecondaryConstructor.kt") + public void testDelegatingSuperConstructorCallInSecondaryConstructor() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/hiddenConstructor/delegatingSuperConstructorCallInSecondaryConstructor.kt"); + } + + @TestMetadata("delegatingThisConstructorCall.kt") + public void testDelegatingThisConstructorCall() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/hiddenConstructor/delegatingThisConstructorCall.kt"); + } + + @TestMetadata("enumClassConstructor.kt") + public void testEnumClassConstructor() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/hiddenConstructor/enumClassConstructor.kt"); + } + + @TestMetadata("innerClassConstructor.kt") + public void testInnerClassConstructor() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/hiddenConstructor/innerClassConstructor.kt"); + } + + @TestMetadata("primaryConstructor.kt") + public void testPrimaryConstructor() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/hiddenConstructor/primaryConstructor.kt"); + } + + @TestMetadata("privateConstructor.kt") + public void testPrivateConstructor() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/hiddenConstructor/privateConstructor.kt"); + } + + @TestMetadata("sealedClassConstructor.kt") + public void testSealedClassConstructor() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/hiddenConstructor/sealedClassConstructor.kt"); + } + + @TestMetadata("secondaryConstructor.kt") + public void testSecondaryConstructor() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/hiddenConstructor/secondaryConstructor.kt"); + } + } } @TestMetadata("compiler/testData/codegen/box/innerNested") 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 eaa4aa6b588..2d9d249a4da 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 @@ -11538,6 +11538,69 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/syntheticAccessorsForPropertyOfInlineClassType.kt"); } } + + @TestMetadata("compiler/testData/codegen/box/inlineClasses/hiddenConstructor") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class HiddenConstructor extends AbstractJsCodegenBoxTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath); + } + + public void testAllFilesPresentInHiddenConstructor() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/hiddenConstructor"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JS, true); + } + + @TestMetadata("constructorWithDefaultParameters.kt") + public void testConstructorWithDefaultParameters() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/hiddenConstructor/constructorWithDefaultParameters.kt"); + } + + @TestMetadata("delegatingSuperConstructorCall.kt") + public void testDelegatingSuperConstructorCall() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/hiddenConstructor/delegatingSuperConstructorCall.kt"); + } + + @TestMetadata("delegatingSuperConstructorCallInSecondaryConstructor.kt") + public void testDelegatingSuperConstructorCallInSecondaryConstructor() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/hiddenConstructor/delegatingSuperConstructorCallInSecondaryConstructor.kt"); + } + + @TestMetadata("delegatingThisConstructorCall.kt") + public void testDelegatingThisConstructorCall() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/hiddenConstructor/delegatingThisConstructorCall.kt"); + } + + @TestMetadata("enumClassConstructor.kt") + public void testEnumClassConstructor() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/hiddenConstructor/enumClassConstructor.kt"); + } + + @TestMetadata("innerClassConstructor.kt") + public void testInnerClassConstructor() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/hiddenConstructor/innerClassConstructor.kt"); + } + + @TestMetadata("primaryConstructor.kt") + public void testPrimaryConstructor() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/hiddenConstructor/primaryConstructor.kt"); + } + + @TestMetadata("privateConstructor.kt") + public void testPrivateConstructor() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/hiddenConstructor/privateConstructor.kt"); + } + + @TestMetadata("sealedClassConstructor.kt") + public void testSealedClassConstructor() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/hiddenConstructor/sealedClassConstructor.kt"); + } + + @TestMetadata("secondaryConstructor.kt") + public void testSecondaryConstructor() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/hiddenConstructor/secondaryConstructor.kt"); + } + } } @TestMetadata("compiler/testData/codegen/box/innerNested")