generate initializer blocks
This commit is contained in:
@@ -124,6 +124,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
if (kind == OwnerKind.DELEGATING_IMPLEMENTATION) {
|
||||
String interfaceDesc = JetTypeMapper.jetInterfaceType(descriptor).getDescriptor();
|
||||
v.visitField(Opcodes.ACC_PRIVATE | Opcodes.ACC_FINAL, "$this", interfaceDesc, /*TODO*/null, null);
|
||||
iv.load(0, classType);
|
||||
iv.load(1, argTypes[0]);
|
||||
iv.putfield(classname, "$this", interfaceDesc);
|
||||
frameMap.enterTemp();
|
||||
@@ -273,6 +274,9 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
|
||||
}
|
||||
}
|
||||
else if (declaration instanceof JetClassInitializer) {
|
||||
codegen.gen(((JetClassInitializer) declaration).getBody(), Type.VOID_TYPE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
class C() {
|
||||
public var f: Int
|
||||
|
||||
{
|
||||
f = 610
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val c = new C()
|
||||
if (c.f != 610) return "fail"
|
||||
return "OK"
|
||||
}
|
||||
@@ -62,4 +62,8 @@ public class ClassGenTest extends CodegenTestCase {
|
||||
public void testInnerClass() throws Exception {
|
||||
blackBoxFile("classes/innerClass.jet");
|
||||
}
|
||||
|
||||
public void testInitializerBlock() throws Exception {
|
||||
blackBoxFile("classes/initializerBlock.jet");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user