namespace property initializers are written directly to backing fields
This commit is contained in:
@@ -49,7 +49,7 @@ public class ClassFileFactory {
|
||||
String fqName = namespace.getFQName();
|
||||
NamespaceCodegen codegen = ns2codegen.get(fqName);
|
||||
if (codegen == null) {
|
||||
codegen = new NamespaceCodegen(project, newVisitor(NamespaceCodegen.getJVMClassName(fqName) + ".class"), fqName, state);
|
||||
codegen = new NamespaceCodegen(newVisitor(NamespaceCodegen.getJVMClassName(fqName) + ".class"), fqName, state);
|
||||
ns2codegen.put(fqName, codegen);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.jetbrains.jet.codegen;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import org.jetbrains.jet.lang.descriptors.PropertyDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.objectweb.asm.ClassVisitor;
|
||||
@@ -13,12 +12,10 @@ import org.objectweb.asm.commons.InstructionAdapter;
|
||||
* @author max
|
||||
*/
|
||||
public class NamespaceCodegen {
|
||||
private final Project project;
|
||||
private final ClassVisitor v;
|
||||
private final GenerationState state;
|
||||
|
||||
public NamespaceCodegen(Project project, ClassVisitor v, String fqName, GenerationState state) {
|
||||
this.project = project;
|
||||
public NamespaceCodegen(ClassVisitor v, String fqName, GenerationState state) {
|
||||
this.v = v;
|
||||
this.state = state;
|
||||
|
||||
@@ -80,7 +77,7 @@ public class NamespaceCodegen {
|
||||
if (initializer != null && !(initializer instanceof JetConstantExpression)) {
|
||||
final PropertyDescriptor descriptor = (PropertyDescriptor) state.getBindingContext().getVariableDescriptor((JetProperty) declaration);
|
||||
codegen.genToJVMStack(initializer);
|
||||
codegen.intermediateValueForProperty(descriptor, false, false).store(new InstructionAdapter(mv));
|
||||
codegen.intermediateValueForProperty(descriptor, true, false).store(new InstructionAdapter(mv));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,6 +80,9 @@ public class PropertyGenTest extends CodegenTestCase {
|
||||
final Method method = generateFunction("append");
|
||||
method.invoke(null, "IntelliJ ");
|
||||
String value = (String) method.invoke(null, "IDEA");
|
||||
if (!value.equals("IntelliJ IDEA")) {
|
||||
System.out.println(generateToText());
|
||||
}
|
||||
assertEquals("IntelliJ IDEA", value);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user