diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ImplementationBodyCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ImplementationBodyCodegen.java index c719bf4bd22..c1d2ba706ec 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ImplementationBodyCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ImplementationBodyCodegen.java @@ -1166,7 +1166,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { KotlinType expressionType = expression != null ? bindingContext.getType(expression) : null; Type asmType = expressionType != null ? typeMapper.mapType(expressionType) : typeMapper.mapType(getSuperClass(specifier)); - result.addField((KtDelegatedSuperTypeEntry) specifier, asmType, "$delegate_" + n); + result.addField((KtDelegatedSuperTypeEntry) specifier, asmType, JvmAbi.DELEGATE_SUPER_FIELD_PREFIX + n); } n++; } diff --git a/compiler/testData/codegen/box/delegation/delegationToVal.kt b/compiler/testData/codegen/box/delegation/delegationToVal.kt index 7bba0acab37..1b0c9643d7d 100644 --- a/compiler/testData/codegen/box/delegation/delegationToVal.kt +++ b/compiler/testData/codegen/box/delegation/delegationToVal.kt @@ -24,16 +24,16 @@ class Test3() : Test2() { fun box(): String { try { - Test::class.java.getDeclaredField("\$delegate_0") - return "\$delegate_0 field generated for class Test but should not" + Test::class.java.getDeclaredField("\$\$delegate_0") + return "\$\$delegate_0 field generated for class Test but should not" } catch (e: NoSuchFieldException) { // ok } try { - Test2::class.java.getDeclaredField("\$delegate_0") - return "\$delegate_0 field generated for class Test but should not" + Test2::class.java.getDeclaredField("\$\$delegate_0") + return "\$\$delegate_0 field generated for class Test but should not" } catch (e: NoSuchFieldException) { // ok diff --git a/compiler/testData/codegen/boxInline/anonymousObject/kt13374.kt b/compiler/testData/codegen/boxInline/anonymousObject/kt13374.kt new file mode 100644 index 00000000000..5db8f48053e --- /dev/null +++ b/compiler/testData/codegen/boxInline/anonymousObject/kt13374.kt @@ -0,0 +1,37 @@ +// FILE: 1.kt + +package test + +interface IZ { + fun z() +} + +interface IZZ : IZ { + fun zz() +} + +inline fun implZZ(zImpl: IZ, crossinline zzImpl: () -> Unit): IZZ = + object : IZZ, IZ by zImpl { + override fun zz() = zzImpl() + } + + +// FILE: 2.kt + +import test.* + +var result = "fail"; + +object ZImpl : IZ { + override fun z() { + result = "O" + } +} + +fun box(): String { + val zz = implZZ(ZImpl) { result += "K" } + zz.z() + zz.zz() + return result +} + diff --git a/compiler/testData/diagnostics/tests/duplicateJvmSignature/specialNames/delegationBy.kt b/compiler/testData/diagnostics/tests/duplicateJvmSignature/specialNames/delegationBy.kt index 5ea8a8690ad..7d2e5082b32 100644 --- a/compiler/testData/diagnostics/tests/duplicateJvmSignature/specialNames/delegationBy.kt +++ b/compiler/testData/diagnostics/tests/duplicateJvmSignature/specialNames/delegationBy.kt @@ -1,5 +1,5 @@ interface Foo class Bar(f: Foo) : Foo by f { - val `$delegate_0`: Foo? = null + val `$$delegate_0`: Foo? = null } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/duplicateJvmSignature/specialNames/delegationBy.txt b/compiler/testData/diagnostics/tests/duplicateJvmSignature/specialNames/delegationBy.txt index 07e299703a1..f04fe51ca4e 100644 --- a/compiler/testData/diagnostics/tests/duplicateJvmSignature/specialNames/delegationBy.txt +++ b/compiler/testData/diagnostics/tests/duplicateJvmSignature/specialNames/delegationBy.txt @@ -2,7 +2,7 @@ package public final class Bar : Foo { public constructor Bar(/*0*/ f: Foo) - public final val `$delegate_0`: Foo? = null + public final val `$$delegate_0`: Foo? = null 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 diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java index a61bf411acb..5ef1d4993bf 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java @@ -133,6 +133,12 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo doTest(fileName); } + @TestMetadata("kt13374.kt") + public void testKt13374() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/anonymousObject/kt13374.kt"); + doTest(fileName); + } + @TestMetadata("kt6552.kt") public void testKt6552() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/anonymousObject/kt6552.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java index 1cf8da5abeb..b9126f86c3b 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java @@ -133,6 +133,12 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi doTest(fileName); } + @TestMetadata("kt13374.kt") + public void testKt13374() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/anonymousObject/kt13374.kt"); + doTest(fileName); + } + @TestMetadata("kt6552.kt") public void testKt6552() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/anonymousObject/kt6552.kt"); diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/JvmAbi.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/JvmAbi.java index 50220fe334f..7a8702e7a8e 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/JvmAbi.java +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/JvmAbi.java @@ -43,6 +43,7 @@ public final class JvmAbi { public static final String DELEGATED_PROPERTY_NAME_SUFFIX = "$delegate"; public static final String DELEGATED_PROPERTIES_ARRAY_NAME = "$$delegatedProperties"; + public static final String DELEGATE_SUPER_FIELD_PREFIX = "$$delegate_"; public static final String ANNOTATED_PROPERTY_METHOD_NAME_SUFFIX = "$annotations"; public static final String INSTANCE_FIELD = "INSTANCE";