From 7b01ce5acba02173176544e38b0315bc4b4eecb0 Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Fri, 7 Sep 2012 14:48:50 +0400 Subject: [PATCH] Test for KT-2532 Exception on trying to override delegated member. #KT-2532 Fixed --- compiler/testData/codegen/classes/kt2532.kt | 15 +++++++++++++++ .../org/jetbrains/jet/codegen/ClassGenTest.java | 5 +++++ 2 files changed, 20 insertions(+) create mode 100644 compiler/testData/codegen/classes/kt2532.kt diff --git a/compiler/testData/codegen/classes/kt2532.kt b/compiler/testData/codegen/classes/kt2532.kt new file mode 100644 index 00000000000..a1f3eb7edf5 --- /dev/null +++ b/compiler/testData/codegen/classes/kt2532.kt @@ -0,0 +1,15 @@ +package foo + +trait B { + val c: Int + get() = 2 +} + +class A(val b: B) : B by b { + override val c: Int = 3 +} + +fun box(): String { + val c = A(object: B {}).c + return if (c == 3) "OK" else "fail: $c" +} \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/jet/codegen/ClassGenTest.java b/compiler/tests/org/jetbrains/jet/codegen/ClassGenTest.java index ada396c5175..c6aa5d9b5c0 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/ClassGenTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/ClassGenTest.java @@ -122,6 +122,11 @@ public class ClassGenTest extends CodegenTestCase { blackBoxFile("classes/inheritedInnerClass.jet"); } + public void testKt2532() throws Exception { + createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); + blackBoxFile("classes/kt2532.kt"); + } + public void testInitializerBlock() throws Exception { createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); blackBoxFile("classes/initializerBlock.jet");