Fix class literals of objects in super constructor calls
In an expression such as "Obj::class" where Obj is an object, it's fine to consider Obj either an expression or a type and generate either Obj.INSTANCE.getClass() or Obj.class correspondingly. However, the former fails in the object's super constructor call because the INSTANCE field is not yet initialized. Thus, we force generation of Obj.class in case when Obj is an object. Note that this has been reproduced in our project, see KotlinMetadataVersionIndex
This commit is contained in:
@@ -3290,10 +3290,10 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
@Override
|
||||
public Unit invoke(InstructionAdapter v) {
|
||||
KotlinType type = lhs.getType();
|
||||
if (lhs instanceof DoubleColonLHS.Expression) {
|
||||
if (lhs instanceof DoubleColonLHS.Expression && !((DoubleColonLHS.Expression) lhs).isObject()) {
|
||||
JavaClassProperty.INSTANCE.generateImpl(v, gen(receiverExpression));
|
||||
}
|
||||
else if (lhs instanceof DoubleColonLHS.Type) {
|
||||
else {
|
||||
if (TypeUtils.isTypeParameter(type)) {
|
||||
assert TypeUtils.isReifiedTypeParameter(type) :
|
||||
"Non-reified type parameter under ::class should be rejected by type checker: " + type;
|
||||
|
||||
Reference in New Issue
Block a user