KT-156 Fix the this<Super> syntax

This commit is contained in:
Andrey Breslav
2011-10-20 18:38:51 +04:00
parent ec6dec0d37
commit d445a09a80
2 changed files with 18 additions and 1 deletions
@@ -365,7 +365,9 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
context.trace.report(AMBIGUOUS_SUPER.on(expression));
}
else {
result = substitutor.substitute(supertypes.iterator().next(), Variance.INVARIANT);
// supertypes may be empty when all the supertypes are error types (are not resolved, for example)
JetType type = supertypes.isEmpty() ? JetStandardClasses.getAnyType() : supertypes.iterator().next();
result = substitutor.substitute(type, Variance.INVARIANT);
}
}
if (result != null) {
@@ -60,3 +60,18 @@ class CG : G<Int> {
super<<!NOT_A_SUPERTYPE!>G<String><!>>.foo() // Error
}
}
// The case when no supertype is resolved
class ERROR<E>() : <!UNRESOLVED_REFERENCE!>UR<!> {
fun test() {
super.<!UNRESOLVED_REFERENCE!>foo<!>()
}
}
// No supertype at all
class A1 {
fun test() {
super.equals(null)
}
}