From d2508c8710666f58f3815f14d46699988b15c7d1 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Thu, 28 May 2015 22:17:00 +0300 Subject: [PATCH] Do not report irrelevant diagnostics on unresolved supertypes Previously the confusing "trait with superclass" was reported when an unresolved classifier appeared in interface supertypes --- .../kotlin/resolve/BodyResolver.java | 2 ++ .../tests/subtyping/unresolvedSupertype.kt | 7 ++++ .../tests/subtyping/unresolvedSupertype.txt | 34 +++++++++++++++++++ .../checkers/JetDiagnosticsTestGenerated.java | 6 ++++ 4 files changed, 49 insertions(+) create mode 100644 compiler/testData/diagnostics/tests/subtyping/unresolvedSupertype.kt create mode 100644 compiler/testData/diagnostics/tests/subtyping/unresolvedSupertype.txt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/BodyResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/BodyResolver.java index 7d52a06ef37..2bf35337124 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/BodyResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/BodyResolver.java @@ -429,6 +429,8 @@ public class BodyResolver { ClassDescriptor classDescriptor = TypeUtils.getClassDescriptor(supertype); if (classDescriptor != null) { + if (ErrorUtils.isError(classDescriptor)) continue; + if (classDescriptor.getKind() != ClassKind.INTERFACE) { if (supertypeOwner.getKind() == ClassKind.ENUM_CLASS) { trace.report(CLASS_IN_SUPERTYPE_FOR_ENUM.on(typeReference)); diff --git a/compiler/testData/diagnostics/tests/subtyping/unresolvedSupertype.kt b/compiler/testData/diagnostics/tests/subtyping/unresolvedSupertype.kt new file mode 100644 index 00000000000..8d34086f741 --- /dev/null +++ b/compiler/testData/diagnostics/tests/subtyping/unresolvedSupertype.kt @@ -0,0 +1,7 @@ +interface A1 : B + +interface A2 : B() + +class A3 : B, B + +enum class A4 : B diff --git a/compiler/testData/diagnostics/tests/subtyping/unresolvedSupertype.txt b/compiler/testData/diagnostics/tests/subtyping/unresolvedSupertype.txt new file mode 100644 index 00000000000..e8374984d40 --- /dev/null +++ b/compiler/testData/diagnostics/tests/subtyping/unresolvedSupertype.txt @@ -0,0 +1,34 @@ +package + +internal interface A1 { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal interface A2 { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal final class A3 { + public constructor A3() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal final enum class A4 : kotlin.Enum { + private constructor A4() + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: A4): kotlin.Int + public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): A4 + public final /*synthesized*/ fun values(): kotlin.Array +} diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java index be00a022092..922b765458c 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java @@ -12929,6 +12929,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/subtyping/topLevelAnonymousObjects.kt"); doTest(fileName); } + + @TestMetadata("unresolvedSupertype.kt") + public void testUnresolvedSupertype() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/subtyping/unresolvedSupertype.kt"); + doTest(fileName); + } } @TestMetadata("compiler/testData/diagnostics/tests/suppress")