From d8bc29e6c69b7fb73560179dae4323c9808fe869 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Fri, 27 Mar 2020 18:16:01 +0300 Subject: [PATCH] [FIR] Eliminate obsolete NO_SUPERTYPE diagnostic from builder --- .../testData/resolve/diagnostics/superNotAvailable.kt | 8 ++++---- .../components/ErrorNodeDiagnosticCollectorComponent.kt | 1 - .../fir/analysis/diagnostics/FirDefaultErrorMessages.kt | 2 -- .../kotlin/fir/analysis/diagnostics/FirErrors.kt | 1 - .../body/resolve/FirExpressionsResolveTransformer.kt | 4 +++- .../kotlin/fir/diagnostics/ConeSimpleDiagnostic.kt | 1 - .../tests/thisAndSuper/superInExtensionFunction.fir.kt | 4 ++-- .../tests/thisAndSuper/superInToplevelFunction.fir.kt | 4 ++-- .../tests/thisAndSuper/superIsNotAnExpression.fir.kt | 8 ++++---- 9 files changed, 15 insertions(+), 18 deletions(-) diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/superNotAvailable.kt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/superNotAvailable.kt index 2afd9af2a99..d3767bc0fa7 100644 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/superNotAvailable.kt +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/superNotAvailable.kt @@ -1,11 +1,11 @@ fun String.f() { - super@f.compareTo("") - super.compareTo("") + super@f.compareTo("") + super.compareTo("") } fun foo() { - super - super.foo() + super + super.foo() super.foo() } diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/components/ErrorNodeDiagnosticCollectorComponent.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/components/ErrorNodeDiagnosticCollectorComponent.kt index d34fefec677..adf19dee341 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/components/ErrorNodeDiagnosticCollectorComponent.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/components/ErrorNodeDiagnosticCollectorComponent.kt @@ -72,7 +72,6 @@ class ErrorNodeDiagnosticCollectorComponent(collector: AbstractDiagnosticCollect IllegalConstExpression -> FirErrors.ILLEGAL_CONST_EXPRESSION DeserializationError -> FirErrors.DESERIALIZATION_ERROR InferenceError -> FirErrors.INFERENCE_ERROR - NoSupertype -> FirErrors.NO_SUPERTYPE TypeParameterAsSupertype -> FirErrors.TYPE_PARAMETER_AS_SUPERTYPE EnumAsSupertype -> FirErrors.ENUM_AS_SUPERTYPE RecursionInSupertypes -> FirErrors.RECURSION_IN_SUPERTYPES diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt index f92ad4994bd..5cb3612f2f6 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt @@ -20,7 +20,6 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.ILLEGAL_CONST_EXP import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INAPPLICABLE_CANDIDATE import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INCOMPATIBLE_MODIFIERS import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INFERENCE_ERROR -import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.NO_SUPERTYPE import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.OTHER_ERROR import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.RECURSION_IN_IMPLICIT_TYPES import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.RECURSION_IN_SUPERTYPES @@ -49,7 +48,6 @@ class FirDefaultErrorMessages : DefaultErrorMessages.Extension { map.put(ILLEGAL_CONST_EXPRESSION, "Illegal const expression") map.put(DESERIALIZATION_ERROR, "Deserialization error") map.put(INFERENCE_ERROR, "Inference error") - map.put(NO_SUPERTYPE, "No supertype") map.put(TYPE_PARAMETER_AS_SUPERTYPE, "Type parameter as supertype") map.put(ENUM_AS_SUPERTYPE, "Enum as supertype") map.put(RECURSION_IN_SUPERTYPES, "Recursion in supertypes") diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt index 7b0c0863c2c..3075a4721b2 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt @@ -23,7 +23,6 @@ object FirErrors { val ILLEGAL_CONST_EXPRESSION by error0() val DESERIALIZATION_ERROR by error0() val INFERENCE_ERROR by error0() - val NO_SUPERTYPE by error0() val TYPE_PARAMETER_AS_SUPERTYPE by error0() val ENUM_AS_SUPERTYPE by error0() val RECURSION_IN_SUPERTYPES by error0() diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt index 12b36c5fa00..7ae24ba419d 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt @@ -10,6 +10,7 @@ import org.jetbrains.kotlin.fir.* import org.jetbrains.kotlin.fir.declarations.FirTypeParametersOwner import org.jetbrains.kotlin.fir.diagnostics.DiagnosticKind import org.jetbrains.kotlin.fir.diagnostics.ConeSimpleDiagnostic +import org.jetbrains.kotlin.fir.diagnostics.ConeStubDiagnostic import org.jetbrains.kotlin.fir.expressions.* import org.jetbrains.kotlin.fir.expressions.builder.buildErrorExpression import org.jetbrains.kotlin.fir.expressions.builder.buildFunctionCall @@ -93,7 +94,8 @@ class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransformer) : superTypeRefs?.isNotEmpty() != true -> { buildErrorTypeRef { source = qualifiedAccessExpression.source - diagnostic = ConeSimpleDiagnostic("No super type", DiagnosticKind.NoSupertype) + // NB: NOT_A_SUPERTYPE is reported by a separate checker + diagnostic = ConeStubDiagnostic(ConeSimpleDiagnostic("No super type", DiagnosticKind.Other)) } } superTypeRefs.size == 1 -> { diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/diagnostics/ConeSimpleDiagnostic.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/diagnostics/ConeSimpleDiagnostic.kt index 10612cd88fb..73e3a3a38e5 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/diagnostics/ConeSimpleDiagnostic.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/diagnostics/ConeSimpleDiagnostic.kt @@ -19,7 +19,6 @@ enum class DiagnosticKind { IllegalConstExpression, DeserializationError, InferenceError, - NoSupertype, TypeParameterAsSupertype, EnumAsSupertype, RecursionInSupertypes, diff --git a/compiler/testData/diagnostics/tests/thisAndSuper/superInExtensionFunction.fir.kt b/compiler/testData/diagnostics/tests/thisAndSuper/superInExtensionFunction.fir.kt index 5793824a7e6..f5aba60cce7 100644 --- a/compiler/testData/diagnostics/tests/thisAndSuper/superInExtensionFunction.fir.kt +++ b/compiler/testData/diagnostics/tests/thisAndSuper/superInExtensionFunction.fir.kt @@ -1,4 +1,4 @@ fun String.f() { - super@f.compareTo("") - super.compareTo("") + super@f.compareTo("") + super.compareTo("") } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/thisAndSuper/superInToplevelFunction.fir.kt b/compiler/testData/diagnostics/tests/thisAndSuper/superInToplevelFunction.fir.kt index b5b95fd190d..bb1e91ecd86 100644 --- a/compiler/testData/diagnostics/tests/thisAndSuper/superInToplevelFunction.fir.kt +++ b/compiler/testData/diagnostics/tests/thisAndSuper/superInToplevelFunction.fir.kt @@ -1,5 +1,5 @@ fun foo() { - super - super.foo() + super + super.foo() super.foo() } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/thisAndSuper/superIsNotAnExpression.fir.kt b/compiler/testData/diagnostics/tests/thisAndSuper/superIsNotAnExpression.fir.kt index 6315871138c..925c8b1ca7f 100644 --- a/compiler/testData/diagnostics/tests/thisAndSuper/superIsNotAnExpression.fir.kt +++ b/compiler/testData/diagnostics/tests/thisAndSuper/superIsNotAnExpression.fir.kt @@ -1,11 +1,11 @@ fun any(a : Any) {} fun notAnExpression() { - any(super) // not an expression - if (super) {} else {} // not an expression - val x = super // not an expression + any(super) // not an expression + if (super) {} else {} // not an expression + val x = super // not an expression when (1) { - super -> 1 // not an expression + super -> 1 // not an expression else -> {} }