From 39234b4d3ec211adf7b973df7ddad3a5646a8fc6 Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Thu, 23 Jan 2014 10:21:03 +0400 Subject: [PATCH] Delegated members should not be synthetic Otherwise they are invisible to Java code --- .../org/jetbrains/jet/codegen/FunctionCodegen.java | 2 +- .../compileJavaAgainstKotlin/method/Delegation.java | 7 +++++++ .../compileJavaAgainstKotlin/method/Delegation.kt | 11 +++++++++++ .../CompileJavaAgainstKotlinTestGenerated.java | 5 +++++ 4 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 compiler/testData/compileJavaAgainstKotlin/method/Delegation.java create mode 100644 compiler/testData/compileJavaAgainstKotlin/method/Delegation.kt diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/FunctionCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/FunctionCodegen.java index f245b2945be..cf641f1ebb1 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/FunctionCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/FunctionCodegen.java @@ -737,7 +737,7 @@ public class FunctionCodegen extends ParentCodegenAwareImpl { Method overriddenMethod = jvmOverriddenMethodSignature.getAsmMethod(); Method delegateMethod = jvmDelegateMethodSignature.getAsmMethod(); - int flags = ACC_PUBLIC | ACC_SYNTHETIC; // TODO. + int flags = ACC_PUBLIC; MethodVisitor mv = v.newMethod(null, flags, delegateMethod.getName(), delegateMethod.getDescriptor(), null, null); if (state.getClassBuilderMode() != ClassBuilderMode.FULL) return; diff --git a/compiler/testData/compileJavaAgainstKotlin/method/Delegation.java b/compiler/testData/compileJavaAgainstKotlin/method/Delegation.java new file mode 100644 index 00000000000..fe227e84c7a --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/method/Delegation.java @@ -0,0 +1,7 @@ +class JavaClass { + public static void main(String[] args) { + Test test = new Test(); + test.foo(); + test.getBar(); + } +} \ No newline at end of file diff --git a/compiler/testData/compileJavaAgainstKotlin/method/Delegation.kt b/compiler/testData/compileJavaAgainstKotlin/method/Delegation.kt new file mode 100644 index 00000000000..579e031b8d2 --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/method/Delegation.kt @@ -0,0 +1,11 @@ +trait Trait { + fun foo() + val bar: Int +} + +class Impl: Trait { + override fun foo() {} + override val bar = 1 +} + +class Test : Trait by Impl() \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/jet/jvm/compiler/CompileJavaAgainstKotlinTestGenerated.java b/compiler/tests/org/jetbrains/jet/jvm/compiler/CompileJavaAgainstKotlinTestGenerated.java index 6f7d0e7bafb..629f4d8bc60 100644 --- a/compiler/tests/org/jetbrains/jet/jvm/compiler/CompileJavaAgainstKotlinTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/jvm/compiler/CompileJavaAgainstKotlinTestGenerated.java @@ -112,6 +112,11 @@ public class CompileJavaAgainstKotlinTestGenerated extends AbstractCompileJavaAg doTest("compiler/testData/compileJavaAgainstKotlin/method/ArrayOfIntegerArray.kt"); } + @TestMetadata("Delegation.kt") + public void testDelegation() throws Exception { + doTest("compiler/testData/compileJavaAgainstKotlin/method/Delegation.kt"); + } + @TestMetadata("GenericArray.kt") public void testGenericArray() throws Exception { doTest("compiler/testData/compileJavaAgainstKotlin/method/GenericArray.kt");