[FIR] Implement RESOLUTION_TO_CLASSIFIER

This commit is contained in:
Ivan Kochurkin
2021-06-30 18:33:20 +03:00
parent 2574dc907c
commit d4e1cded59
51 changed files with 88 additions and 483 deletions
@@ -124,6 +124,9 @@ object DIAGNOSTICS_LIST : DiagnosticList("FirErrors") {
parameter<String>("expression")
parameter<ConeKotlinType>("type")
}
val RESOLUTION_TO_CLASSIFIER by error<PsiElement> {
parameter<FirRegularClassSymbol>("classSymbol")
}
}
val SUPER by object : DiagnosticGroup("Super") {
@@ -134,6 +134,7 @@ object FirErrors {
val ILLEGAL_SELECTOR by error0<PsiElement>()
val NO_RECEIVER_ALLOWED by error0<PsiElement>()
val FUNCTION_EXPECTED by error2<PsiElement, String, ConeKotlinType>(SourceElementPositioningStrategies.REFERENCED_NAME_BY_QUALIFIED)
val RESOLUTION_TO_CLASSIFIER by error1<PsiElement, FirRegularClassSymbol>()
// Super
val SUPER_IS_NOT_AN_EXPRESSION by error0<PsiElement>(SourceElementPositioningStrategies.REFERENCED_NAME_BY_QUALIFIED)
@@ -329,6 +329,7 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.REIFIED_TYPE_PARA
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.REPEATED_BOUND
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.REPEATED_MODIFIER
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.RESERVED_MEMBER_INSIDE_INLINE_CLASS
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.RESOLUTION_TO_CLASSIFIER
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.RESULT_TYPE_MISMATCH
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.RETURN_IN_FUNCTION_WITH_EXPRESSION_BODY
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.RETURN_NOT_ALLOWED
@@ -502,6 +503,11 @@ class FirDefaultErrorMessages {
FUNCTION_EXPECTED,
"Expression ''{0}'' of type {1} cannot be invoked as a function. The function 'invoke()' is not found", TO_STRING, RENDER_TYPE
)
map.put(
RESOLUTION_TO_CLASSIFIER,
"Constructor of inner class {0} can be called only with receiver of containing class",
SYMBOL
)
map.put(ILLEGAL_SELECTOR, "The expression cannot be a selector (occur after a dot)")
map.put(NO_RECEIVER_ALLOWED, "No receiver can be passed to this function or property")
@@ -42,6 +42,7 @@ private fun ConeDiagnostic.toFirDiagnostic(
is ConeUnresolvedQualifierError -> FirErrors.UNRESOLVED_REFERENCE.createOn(source, this.qualifier)
is ConeFunctionCallExpectedError -> FirErrors.FUNCTION_CALL_EXPECTED.createOn(source, this.name.asString(), this.hasValueParameters)
is ConeFunctionExpectedError -> FirErrors.FUNCTION_EXPECTED.createOn(source, this.expression, this.type)
is ConeResolutionToClassifierError -> FirErrors.RESOLUTION_TO_CLASSIFIER.createOn(source, this.classSymbol)
is ConeHiddenCandidateError -> FirErrors.INVISIBLE_REFERENCE.createOn(source, this.candidateSymbol)
is ConeAmbiguityError -> when {
applicability.isSuccess -> FirErrors.OVERLOAD_RESOLUTION_AMBIGUITY.createOn(source, this.candidates.map { it.symbol })