Allow top-level local delegated properties in scripts
This commit is contained in:
@@ -445,6 +445,10 @@ public class PropertyCodegen {
|
||||
else if (parent instanceof KtFile) {
|
||||
container = (KtFile) parent;
|
||||
}
|
||||
else if (KtPsiUtil.isScriptDeclaration(property)) {
|
||||
container = KtPsiUtil.getScript(property);
|
||||
assert container != null : "Script declaration for property '" + property.getText() + "' should be not null!";
|
||||
}
|
||||
else {
|
||||
throw new UnsupportedOperationException("Unknown delegated property container: " + parent);
|
||||
}
|
||||
|
||||
@@ -69,6 +69,7 @@ public class ScriptCodegen extends MemberCodegen<KtScript> {
|
||||
private final KtScript scriptDeclaration;
|
||||
private final ScriptContext context;
|
||||
private final ScriptDescriptor scriptDescriptor;
|
||||
private final Type classAsmType;
|
||||
|
||||
private ScriptCodegen(
|
||||
@NotNull KtScript scriptDeclaration,
|
||||
@@ -80,16 +81,15 @@ public class ScriptCodegen extends MemberCodegen<KtScript> {
|
||||
this.scriptDeclaration = scriptDeclaration;
|
||||
this.context = context;
|
||||
this.scriptDescriptor = context.getScriptDescriptor();
|
||||
classAsmType = typeMapper.mapClass(context.getContextDescriptor());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void generateDeclaration() {
|
||||
Type classType = typeMapper.mapClass(context.getContextDescriptor());
|
||||
|
||||
v.defineClass(scriptDeclaration,
|
||||
V1_6,
|
||||
ACC_PUBLIC | ACC_SUPER,
|
||||
classType.getInternalName(),
|
||||
classAsmType.getInternalName(),
|
||||
null,
|
||||
"java/lang/Object",
|
||||
ArrayUtil.EMPTY_STRING_ARRAY);
|
||||
@@ -103,6 +103,11 @@ public class ScriptCodegen extends MemberCodegen<KtScript> {
|
||||
context.intoFunction(scriptDescriptor.getUnsubstitutedPrimaryConstructor()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void generateSyntheticParts() {
|
||||
generatePropertyMetadataArrayFieldIfNeeded(classAsmType);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void generateKotlinMetadataAnnotation() {
|
||||
// TODO
|
||||
|
||||
Reference in New Issue
Block a user