Introduction of CastedClassReceiver and its handling in codegen #KT-6744 Fixed
ClassReceiver converted to Kotlin Also #KT-7617 Fixed
This commit is contained in:
@@ -359,7 +359,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
|
||||
@Override
|
||||
public StackValue visitSuperExpression(@NotNull KtSuperExpression expression, StackValue data) {
|
||||
return StackValue.thisOrOuter(this, getSuperCallLabelTarget(context, expression), true, true);
|
||||
return StackValue.thisOrOuter(this, getSuperCallLabelTarget(context, expression), true, false);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -2572,7 +2572,8 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
}
|
||||
}
|
||||
else {
|
||||
return StackValue.thisOrOuter(this, receiverDescriptor, isSuper, isEnumEntry(receiverDescriptor));
|
||||
return StackValue.thisOrOuter(this, receiverDescriptor, isSuper,
|
||||
receiverValue instanceof CastClassReceiver || isEnumEntry(receiverDescriptor));
|
||||
}
|
||||
}
|
||||
else if (receiverValue instanceof ScriptReceiver) {
|
||||
|
||||
@@ -460,11 +460,11 @@ public abstract class StackValue {
|
||||
@NotNull ExpressionCodegen codegen,
|
||||
@NotNull ClassDescriptor descriptor,
|
||||
boolean isSuper,
|
||||
boolean isExplicit
|
||||
boolean castReceiver
|
||||
) {
|
||||
// Coerce explicit 'this' for the case when it is smart cast.
|
||||
// Coerce 'this' for the case when it is smart cast.
|
||||
// Do not coerce for other cases due to the 'protected' access issues (JVMS 7, 4.9.2 Structural Constraints).
|
||||
boolean coerceType = descriptor.getKind() == ClassKind.INTERFACE || (isExplicit && !isSuper);
|
||||
boolean coerceType = descriptor.getKind() == ClassKind.INTERFACE || (castReceiver && !isSuper);
|
||||
return new ThisOuter(codegen, descriptor, isSuper, coerceType);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user