diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/ImplementationBodyCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/ImplementationBodyCodegen.java index 98c51812509..3b0c425c3cb 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/ImplementationBodyCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/ImplementationBodyCodegen.java @@ -1260,7 +1260,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { else { assert descriptor instanceof CallableDescriptor; if (context.getCallableDescriptorWithReceiver() != descriptor) { - context.lookupInContext(descriptor, null, state, false); + context.lookupInContext(descriptor, null, state, true); } } } diff --git a/compiler/testData/codegen/box/functions/kt3573.kt b/compiler/testData/codegen/box/functions/kt3573.kt new file mode 100644 index 00000000000..e97d3620de0 --- /dev/null +++ b/compiler/testData/codegen/box/functions/kt3573.kt @@ -0,0 +1,12 @@ +class Data + +fun newInit(f: Data.() -> Data) = Data().f() + +class TestClass { + val test: Data = newInit() { this } +} + +fun box() : String { + TestClass() + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/functions/kt3724.kt b/compiler/testData/codegen/box/functions/kt3724.kt new file mode 100644 index 00000000000..e1e5edac345 --- /dev/null +++ b/compiler/testData/codegen/box/functions/kt3724.kt @@ -0,0 +1,24 @@ +class Comment() { + var article = "" +} + +fun new(body: Comment.() -> Unit) : Comment { + val c = Comment() + c.body() + return c +} + +open class Request(val handler : Any.() -> Comment) { + val s = handler().article +} + + +class A : Request ({ + new { + this.article = "OK" + } +}) + +fun box() : String { + return A().s +} diff --git a/compiler/tests/org/jetbrains/jet/codegen/generated/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/jet/codegen/generated/BlackBoxCodegenTestGenerated.java index 30bb63fd6c1..0208214c8a3 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/generated/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/codegen/generated/BlackBoxCodegenTestGenerated.java @@ -2349,6 +2349,16 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { doTest("compiler/testData/codegen/box/functions/kt3313.kt"); } + @TestMetadata("kt3573.kt") + public void testKt3573() throws Exception { + doTest("compiler/testData/codegen/box/functions/kt3573.kt"); + } + + @TestMetadata("kt3724.kt") + public void testKt3724() throws Exception { + doTest("compiler/testData/codegen/box/functions/kt3724.kt"); + } + @TestMetadata("kt395.kt") public void testKt395() throws Exception { doTest("compiler/testData/codegen/box/functions/kt395.kt");