Fix nested classes codegen bug

When constructing a closure, codegen in some cases incorrectly determined if
it needed to store a reference from a nested class to the outer
This commit is contained in:
Alexander Udalov
2013-01-17 22:06:11 +04:00
parent 5c56900a09
commit c4a3963925
3 changed files with 26 additions and 8 deletions
@@ -32,8 +32,7 @@ import java.util.HashMap;
import java.util.Map;
import static org.jetbrains.jet.codegen.AsmUtil.CAPTURED_THIS_FIELD;
import static org.jetbrains.jet.codegen.binding.CodegenBinding.CLASS_FOR_FUNCTION;
import static org.jetbrains.jet.codegen.binding.CodegenBinding.FQN;
import static org.jetbrains.jet.codegen.binding.CodegenBinding.*;
import static org.jetbrains.jet.lang.resolve.java.AsmTypeConstants.OBJECT_TYPE;
public abstract class CodegenContext {
@@ -265,12 +264,12 @@ public abstract class CodegenContext {
}
protected void initOuterExpression(JetTypeMapper typeMapper, ClassDescriptor classDescriptor) {
final ClassDescriptor enclosingClass = getEnclosingClass();
outerExpression = enclosingClass != null
? StackValue
.field(typeMapper.mapType(enclosingClass), CodegenBinding.getJvmInternalName(typeMapper.getBindingTrace(), classDescriptor),
CAPTURED_THIS_FIELD,
false)
ClassDescriptor enclosingClass = getEnclosingClass();
outerExpression = enclosingClass != null && canHaveOuter(typeMapper.getBindingContext(), classDescriptor)
? StackValue.field(typeMapper.mapType(enclosingClass),
CodegenBinding.getJvmInternalName(typeMapper.getBindingTrace(), classDescriptor),
CAPTURED_THIS_FIELD,
false)
: null;
}