From d445a09a80c4ebd39abf233a8adc717b972baf2d Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Thu, 20 Oct 2011 18:38:51 +0400 Subject: [PATCH] KT-156 Fix the this syntax --- .../expressions/BasicExpressionTypingVisitor.java | 4 +++- .../checkerWithErrorTypes/quick/Super.jet | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) rename {idea => compiler}/testData/checkerWithErrorTypes/quick/Super.jet (86%) diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/BasicExpressionTypingVisitor.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/BasicExpressionTypingVisitor.java index 6828fada9ce..74466a6e266 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/BasicExpressionTypingVisitor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/BasicExpressionTypingVisitor.java @@ -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) { diff --git a/idea/testData/checkerWithErrorTypes/quick/Super.jet b/compiler/testData/checkerWithErrorTypes/quick/Super.jet similarity index 86% rename from idea/testData/checkerWithErrorTypes/quick/Super.jet rename to compiler/testData/checkerWithErrorTypes/quick/Super.jet index 65087a0a4d4..5ec4cfdcb00 100644 --- a/idea/testData/checkerWithErrorTypes/quick/Super.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/Super.jet @@ -60,3 +60,18 @@ class CG : G { super<G>.foo() // Error } } + +// The case when no supertype is resolved +class ERROR() : UR { + + fun test() { + super.foo() + } +} + +// No supertype at all +class A1 { + fun test() { + super.equals(null) + } +} \ No newline at end of file