diff --git a/compiler/backend-common/src/org/jetbrains/jet/backend/common/CodegenUtilKt.kt b/compiler/backend-common/src/org/jetbrains/jet/backend/common/CodegenUtilKt.kt index fef8c0699fe..dd165616915 100644 --- a/compiler/backend-common/src/org/jetbrains/jet/backend/common/CodegenUtilKt.kt +++ b/compiler/backend-common/src/org/jetbrains/jet/backend/common/CodegenUtilKt.kt @@ -25,7 +25,7 @@ import org.jetbrains.jet.utils.keysToMapExceptNulls import org.jetbrains.jet.lang.resolve.DescriptorUtils import org.jetbrains.jet.lang.resolve.MemberComparator import java.util.Comparator -import org.jetbrains.jet.lang.resolve.scopes.JetScope +import org.jetbrains.jet.lang.types.isDynamic public object CodegenUtilKt { @@ -39,6 +39,7 @@ public object CodegenUtilKt { toTrait: ClassDescriptor, delegateExpressionType: JetType? = null ): Map { + if (delegateExpressionType?.isDynamic() ?: false) return mapOf(); return descriptor.getDefaultType().getMemberScope().getDescriptors().stream() .filterIsInstance(javaClass()) diff --git a/compiler/testData/diagnostics/tests/dynamicTypes/delegationBy.kt b/compiler/testData/diagnostics/tests/dynamicTypes/delegationBy.kt new file mode 100644 index 00000000000..31f77fa7ee2 --- /dev/null +++ b/compiler/testData/diagnostics/tests/dynamicTypes/delegationBy.kt @@ -0,0 +1,5 @@ +trait Tr { + fun foo() +} + +class C(d: dynamic) : Tr by d \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/dynamicTypes/delegationBy.txt b/compiler/testData/diagnostics/tests/dynamicTypes/delegationBy.txt new file mode 100644 index 00000000000..ad197003b18 --- /dev/null +++ b/compiler/testData/diagnostics/tests/dynamicTypes/delegationBy.txt @@ -0,0 +1,16 @@ +package + +internal final class C : Tr { + public constructor C(/*0*/ d: dynamic) + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + internal open override /*1*/ /*delegation*/ fun foo(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal trait Tr { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + internal abstract fun foo(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/delegationBy.kt b/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/delegationBy.kt new file mode 100644 index 00000000000..bf23d780a78 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/delegationBy.kt @@ -0,0 +1,5 @@ +trait Tr { + fun foo() +} + +class C(d: dynamic) : Tr by d \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/delegationBy.txt b/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/delegationBy.txt new file mode 100644 index 00000000000..ad197003b18 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/delegationBy.txt @@ -0,0 +1,16 @@ +package + +internal final class C : Tr { + public constructor C(/*0*/ d: dynamic) + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + internal open override /*1*/ /*delegation*/ fun foo(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal trait Tr { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + internal abstract fun foo(): kotlin.Unit + 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/jet/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java index 556204102b2..e6c889ab030 100644 --- a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java @@ -3716,6 +3716,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/dynamicTypes"), Pattern.compile("^(.+)\\.kt$"), true); } + @TestMetadata("delegationBy.kt") + public void testDelegationBy() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/dynamicTypes/delegationBy.kt"); + doTest(fileName); + } + @TestMetadata("unsupported.kt") public void testUnsupported() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/dynamicTypes/unsupported.kt"); diff --git a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestWithJsStdLibGenerated.java b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestWithJsStdLibGenerated.java index 602e2020410..9871abe70c1 100644 --- a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestWithJsStdLibGenerated.java +++ b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestWithJsStdLibGenerated.java @@ -75,6 +75,12 @@ public class JetDiagnosticsTestWithJsStdLibGenerated extends AbstractJetDiagnost doTest(fileName); } + @TestMetadata("delegationBy.kt") + public void testDelegationBy() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/delegationBy.kt"); + doTest(fileName); + } + @TestMetadata("dynamicCalls.kt") public void testDynamicCalls() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/dynamicCalls.kt");