[FIR] Eliminate obsolete NO_SUPERTYPE diagnostic from builder

This commit is contained in:
Mikhail Glukhikh
2020-03-27 18:16:01 +03:00
parent b38d30bab0
commit d8bc29e6c6
9 changed files with 15 additions and 18 deletions
@@ -1,11 +1,11 @@
fun String.f() {
<!NO_SUPERTYPE, NO_SUPERTYPE, SUPER_NOT_AVAILABLE!>super@f<!>.<!UNRESOLVED_REFERENCE!>compareTo<!>("")
<!NO_SUPERTYPE, NO_SUPERTYPE, SUPER_NOT_AVAILABLE!>super<!>.<!UNRESOLVED_REFERENCE!>compareTo<!>("")
<!SUPER_NOT_AVAILABLE!>super@f<!>.<!UNRESOLVED_REFERENCE!>compareTo<!>("")
<!SUPER_NOT_AVAILABLE!>super<!>.<!UNRESOLVED_REFERENCE!>compareTo<!>("")
}
fun foo() {
<!NO_SUPERTYPE, NO_SUPERTYPE, SUPER_NOT_AVAILABLE!>super<!>
<!NO_SUPERTYPE, NO_SUPERTYPE, SUPER_NOT_AVAILABLE!>super<!>.<!UNRESOLVED_REFERENCE!>foo<!>()
<!SUPER_NOT_AVAILABLE!>super<!>
<!SUPER_NOT_AVAILABLE!>super<!>.<!UNRESOLVED_REFERENCE!>foo<!>()
<!SUPER_NOT_AVAILABLE!>super<Nothing><!>.<!UNRESOLVED_REFERENCE!>foo<!>()
}
@@ -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
@@ -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")
@@ -23,7 +23,6 @@ object FirErrors {
val ILLEGAL_CONST_EXPRESSION by error0<FirSourceElement, PsiElement>()
val DESERIALIZATION_ERROR by error0<FirSourceElement, PsiElement>()
val INFERENCE_ERROR by error0<FirSourceElement, PsiElement>()
val NO_SUPERTYPE by error0<FirSourceElement, PsiElement>()
val TYPE_PARAMETER_AS_SUPERTYPE by error0<FirSourceElement, PsiElement>()
val ENUM_AS_SUPERTYPE by error0<FirSourceElement, PsiElement>()
val RECURSION_IN_SUPERTYPES by error0<FirSourceElement, PsiElement>()
@@ -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 -> {
@@ -19,7 +19,6 @@ enum class DiagnosticKind {
IllegalConstExpression,
DeserializationError,
InferenceError,
NoSupertype,
TypeParameterAsSupertype,
EnumAsSupertype,
RecursionInSupertypes,
@@ -1,4 +1,4 @@
fun String.f() {
<!NO_SUPERTYPE, NO_SUPERTYPE, SUPER_NOT_AVAILABLE!>super@f<!>.<!UNRESOLVED_REFERENCE!>compareTo<!>("")
<!NO_SUPERTYPE, NO_SUPERTYPE, SUPER_NOT_AVAILABLE!>super<!>.<!UNRESOLVED_REFERENCE!>compareTo<!>("")
<!SUPER_NOT_AVAILABLE!>super@f<!>.<!UNRESOLVED_REFERENCE!>compareTo<!>("")
<!SUPER_NOT_AVAILABLE!>super<!>.<!UNRESOLVED_REFERENCE!>compareTo<!>("")
}
@@ -1,5 +1,5 @@
fun foo() {
<!NO_SUPERTYPE, NO_SUPERTYPE, SUPER_NOT_AVAILABLE!>super<!>
<!NO_SUPERTYPE, NO_SUPERTYPE, SUPER_NOT_AVAILABLE!>super<!>.<!UNRESOLVED_REFERENCE!>foo<!>()
<!SUPER_NOT_AVAILABLE!>super<!>
<!SUPER_NOT_AVAILABLE!>super<!>.<!UNRESOLVED_REFERENCE!>foo<!>()
<!SUPER_NOT_AVAILABLE!>super<Nothing><!>.<!UNRESOLVED_REFERENCE!>foo<!>()
}
@@ -1,11 +1,11 @@
fun any(a : Any) {}
fun notAnExpression() {
any(<!NO_SUPERTYPE, NO_SUPERTYPE, SUPER_NOT_AVAILABLE!>super<!>) // not an expression
if (<!NO_SUPERTYPE, NO_SUPERTYPE, SUPER_NOT_AVAILABLE!>super<!>) {} else {} // not an expression
val x = <!NO_SUPERTYPE, NO_SUPERTYPE, NO_SUPERTYPE, SUPER_NOT_AVAILABLE!>super<!> // not an expression
any(<!SUPER_NOT_AVAILABLE!>super<!>) // not an expression
if (<!SUPER_NOT_AVAILABLE!>super<!>) {} else {} // not an expression
val x = <!SUPER_NOT_AVAILABLE!>super<!> // not an expression
when (1) {
<!NO_SUPERTYPE, NO_SUPERTYPE, SUPER_NOT_AVAILABLE!>super<!> -> 1 // not an expression
<!SUPER_NOT_AVAILABLE!>super<!> -> 1 // not an expression
else -> {}
}