KT-413 proper visibility of this$0
This commit is contained in:
@@ -140,7 +140,7 @@ public class ClosureCodegen extends ObjectOrClosureCodegen {
|
|||||||
final Method constructor = generateConstructor(funClass, fun);
|
final Method constructor = generateConstructor(funClass, fun);
|
||||||
|
|
||||||
if (captureThis) {
|
if (captureThis) {
|
||||||
cv.newField(fun, 0, "this$0", enclosingType.getDescriptor(), null, null);
|
cv.newField(fun, ACC_FINAL, "this$0", enclosingType.getDescriptor(), null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isConst()) {
|
if(isConst()) {
|
||||||
|
|||||||
@@ -593,7 +593,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
final Type type = typeMapper.mapType(outerDescriptor.getDefaultType(), OwnerKind.IMPLEMENTATION);
|
final Type type = typeMapper.mapType(outerDescriptor.getDefaultType(), OwnerKind.IMPLEMENTATION);
|
||||||
String interfaceDesc = type.getDescriptor();
|
String interfaceDesc = type.getDescriptor();
|
||||||
final String fieldName = "this$0";
|
final String fieldName = "this$0";
|
||||||
v.newField(myClass, ACC_PRIVATE | ACC_FINAL, fieldName, interfaceDesc, null, null);
|
v.newField(myClass, ACC_FINAL, fieldName, interfaceDesc, null, null);
|
||||||
iv.load(0, classType);
|
iv.load(0, classType);
|
||||||
iv.load(frameMap.getOuterThisIndex(), type);
|
iv.load(frameMap.getOuterThisIndex(), type);
|
||||||
iv.putfield(classname, fieldName, interfaceDesc);
|
iv.putfield(classname, fieldName, interfaceDesc);
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package t
|
||||||
|
|
||||||
|
trait I{
|
||||||
|
fun f()
|
||||||
|
}
|
||||||
|
|
||||||
|
class Test{
|
||||||
|
fun foo(){
|
||||||
|
val i : I = object : I {
|
||||||
|
override fun f() {
|
||||||
|
fun local(){
|
||||||
|
bar()
|
||||||
|
}
|
||||||
|
local()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
i.f()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun bar(){}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box() : String {
|
||||||
|
Test().foo()
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
@@ -86,6 +86,10 @@ public class FunctionGenTest extends CodegenTestCase {
|
|||||||
blackBoxFile("regressions/kt873.kt");
|
blackBoxFile("regressions/kt873.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testKt1413 () {
|
||||||
|
blackBoxFile("regressions/kt1413.kt");
|
||||||
|
}
|
||||||
|
|
||||||
public void testKt1199 () {
|
public void testKt1199 () {
|
||||||
blackBoxFile("regressions/kt1199.kt");
|
blackBoxFile("regressions/kt1199.kt");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user