Don't put outer instance twice for anonymous object extending inner
#KT-5343 In Progress
This commit is contained in:
@@ -1413,7 +1413,11 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
|
||||
ResolvedCall<ConstructorDescriptor> superCall = closure.getSuperCall();
|
||||
if (superCall != null) {
|
||||
pushClosureOnStack(superCall.getResultingDescriptor().getContainingDeclaration(), putThis, callGenerator);
|
||||
pushClosureOnStack(
|
||||
superCall.getResultingDescriptor().getContainingDeclaration(),
|
||||
putThis && closure.getCaptureThis() == null,
|
||||
callGenerator
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
class A {
|
||||
fun box(): String {
|
||||
class Local : Inner() {
|
||||
val u = foo()
|
||||
}
|
||||
val u = Local().u
|
||||
return if (u == 42) "OK" else "Fail $u"
|
||||
}
|
||||
|
||||
open inner class Inner
|
||||
fun foo() = 42
|
||||
}
|
||||
|
||||
fun box() = A().box()
|
||||
@@ -0,0 +1,12 @@
|
||||
class A {
|
||||
val x: Any get() {
|
||||
return object : Inner() {
|
||||
override fun toString() = foo()
|
||||
}
|
||||
}
|
||||
|
||||
open inner class Inner
|
||||
fun foo() = "OK"
|
||||
}
|
||||
|
||||
fun box(): String = A().x.toString()
|
||||
@@ -4251,6 +4251,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("localExtendsInnerAndReferencesOuterMember.kt")
|
||||
public void testLocalExtendsInnerAndReferencesOuterMember() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/localClasses/localExtendsInnerAndReferencesOuterMember.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("noclosure.kt")
|
||||
public void testNoclosure() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/localClasses/noclosure.kt");
|
||||
@@ -5005,6 +5011,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("objectExtendsInnerAndReferencesOuterMember.kt")
|
||||
public void testObjectExtendsInnerAndReferencesOuterMember() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/objects/objectExtendsInnerAndReferencesOuterMember.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("objectInLocalAnonymousObject.kt")
|
||||
public void testObjectInLocalAnonymousObject() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/objects/objectInLocalAnonymousObject.kt");
|
||||
|
||||
Reference in New Issue
Block a user