check super type qualifier
even if super resolve is unsuccessful
This commit is contained in:
+13
-5
@@ -481,19 +481,19 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
|
||||
@Override
|
||||
public JetTypeInfo visitSuperExpression(JetSuperExpression expression, ExpressionTypingContext context) {
|
||||
LabelResolver.LabeledReceiverResolutionResult resolutionResult = resolveToReceiver(expression, context, true);
|
||||
|
||||
if (!context.namespacesAllowed) {
|
||||
context.trace.report(SUPER_IS_NOT_AN_EXPRESSION.on(expression, expression.getText()));
|
||||
return JetTypeInfo.create(null, context.dataFlowInfo);
|
||||
return errorInSuper(expression, context);
|
||||
}
|
||||
|
||||
LabelResolver.LabeledReceiverResolutionResult resolutionResult = resolveToReceiver(expression, context, true);
|
||||
switch (resolutionResult.getCode()) {
|
||||
case LABEL_RESOLUTION_ERROR:
|
||||
// The error is already reported
|
||||
return JetTypeInfo.create(null, context.dataFlowInfo);
|
||||
return errorInSuper(expression, context);
|
||||
case NO_THIS:
|
||||
context.trace.report(SUPER_NOT_AVAILABLE.on(expression));
|
||||
return JetTypeInfo.create(null, context.dataFlowInfo);
|
||||
return errorInSuper(expression, context);
|
||||
case SUCCESS:
|
||||
JetType result = checkPossiblyQualifiedSuper(expression, context, resolutionResult.getReceiverParameterDescriptor());
|
||||
if (result != null) {
|
||||
@@ -504,6 +504,14 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
throw new IllegalStateException("Unknown code: " + resolutionResult.getCode());
|
||||
}
|
||||
|
||||
private JetTypeInfo errorInSuper(JetSuperExpression expression, ExpressionTypingContext context) {
|
||||
JetTypeReference superTypeQualifier = expression.getSuperTypeQualifier();
|
||||
if (superTypeQualifier != null) {
|
||||
context.expressionTypingServices.getTypeResolver().resolveType(context.scope, superTypeQualifier, context.trace, true);
|
||||
}
|
||||
return JetTypeInfo.create(null, context.dataFlowInfo);
|
||||
}
|
||||
|
||||
private JetType checkPossiblyQualifiedSuper(
|
||||
JetSuperExpression expression,
|
||||
ExpressionTypingContext context,
|
||||
|
||||
@@ -11,7 +11,7 @@ class A<E>() : C(), T {
|
||||
|
||||
fun test() {
|
||||
<!SUPER_IS_NOT_AN_EXPRESSION!>super<!>
|
||||
<!SUPER_IS_NOT_AN_EXPRESSION!>super<<!DEBUG_INFO_MISSING_UNRESOLVED!>T<!>><!>
|
||||
<!SUPER_IS_NOT_AN_EXPRESSION!>super<T><!>
|
||||
<!AMBIGUOUS_SUPER!>super<!>.foo()
|
||||
super<T>.foo()
|
||||
super<C>.bar()
|
||||
@@ -23,8 +23,8 @@ class A<E>() : C(), T {
|
||||
super<<!SYNTAX!><!>>.foo()
|
||||
super<<!NOT_A_SUPERTYPE!>() -> Unit<!>>.foo()
|
||||
super<<!NOT_A_SUPERTYPE!>Unit<!>>.foo()
|
||||
<!DEBUG_INFO_MISSING_UNRESOLVED!>super<!><<!DEBUG_INFO_MISSING_UNRESOLVED!>T<!>><!UNRESOLVED_REFERENCE!>@B<!>.foo()
|
||||
<!DEBUG_INFO_MISSING_UNRESOLVED!>super<!><<!DEBUG_INFO_MISSING_UNRESOLVED!>C<!>><!UNRESOLVED_REFERENCE!>@B<!>.bar()
|
||||
<!DEBUG_INFO_MISSING_UNRESOLVED!>super<!><T><!UNRESOLVED_REFERENCE!>@B<!>.foo()
|
||||
<!DEBUG_INFO_MISSING_UNRESOLVED!>super<!><C><!UNRESOLVED_REFERENCE!>@B<!>.bar()
|
||||
}
|
||||
|
||||
class B : T {
|
||||
@@ -37,7 +37,7 @@ class A<E>() : C(), T {
|
||||
super<<!NOT_A_SUPERTYPE!>C<!>>@B.foo()
|
||||
super.foo()
|
||||
<!SUPER_IS_NOT_AN_EXPRESSION!>super<!>
|
||||
<!SUPER_IS_NOT_AN_EXPRESSION!>super<<!DEBUG_INFO_MISSING_UNRESOLVED!>T<!>><!>
|
||||
<!SUPER_IS_NOT_AN_EXPRESSION!>super<T><!>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
fun foo() {
|
||||
<!SUPER_IS_NOT_AN_EXPRESSION!>super<!>
|
||||
<!SUPER_NOT_AVAILABLE!>super<!>.foo()
|
||||
<!SUPER_NOT_AVAILABLE!>super<<!DEBUG_INFO_MISSING_UNRESOLVED!>Nothing<!>><!>.foo()
|
||||
<!SUPER_NOT_AVAILABLE!>super<Nothing><!>.foo()
|
||||
}
|
||||
Reference in New Issue
Block a user