Use proper type for context 'this'
Bug in 'generateThisOrOuterFromContext', it worked while instance of a class was always an object. #KT-27078
This commit is contained in:
@@ -1105,7 +1105,8 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
ClassDescriptor captureThis = closure.getCapturedOuterClassDescriptor();
|
||||
if (captureThis != null) {
|
||||
StackValue thisOrOuter = generateThisOrOuter(captureThis, false);
|
||||
assert !isPrimitive(thisOrOuter.type) : "This or outer should be non primitive: " + thisOrOuter.type;
|
||||
assert !isPrimitive(thisOrOuter.type) || captureThis.isInline() :
|
||||
"This or outer for " + captureThis + " should be non-primitive: " + thisOrOuter.type;
|
||||
callGenerator.putCapturedValueOnStack(thisOrOuter, thisOrOuter.type, paramIndex++);
|
||||
}
|
||||
}
|
||||
@@ -2844,8 +2845,8 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
|
||||
private StackValue generateThisOrOuterFromContext(@NotNull ClassDescriptor thisOrOuterClass, boolean isSuper, boolean forceOuter) {
|
||||
CodegenContext cur = context;
|
||||
SimpleType thisType = thisOrOuterClass.getDefaultType();
|
||||
StackValue result = StackValue.local(0, asmType(thisType), thisType);
|
||||
SimpleType contextType = cur.getThisDescriptor().getDefaultType();
|
||||
StackValue result = StackValue.local(0, asmType(contextType), contextType);
|
||||
boolean inStartConstructorContext = cur instanceof ConstructorContext;
|
||||
while (cur != null) {
|
||||
ClassDescriptor thisDescriptor = cur.getThisDescriptor();
|
||||
|
||||
Reference in New Issue
Block a user