FIR: Add ConeDiagnosticWithCandidates and

ConeDiagnosticWithSingleCandidate to ConeDiagnostic type hierarchy.
This commit is contained in:
Mark Punzalan
2021-08-24 08:07:35 +00:00
committed by Ilya Kirillov
parent db38cd95da
commit 16eabf0ff1
8 changed files with 87 additions and 79 deletions
@@ -47,16 +47,6 @@ internal fun FirNamedReference.getCandidateSymbols(): Collection<FirBasedSymbol<
internal fun ConeDiagnostic.getCandidateSymbols(): Collection<FirBasedSymbol<*>> =
when (this) {
is ConeInapplicableCandidateError -> listOf(candidate.symbol)
is ConeHiddenCandidateError -> listOf(candidateSymbol)
is ConeAmbiguityError -> candidates.map { it.symbol }
is ConeOperatorAmbiguityError -> candidates
is ConeUnsupportedCallableReferenceTarget -> listOf(fir.symbol)
is ConeUnmatchedTypeArgumentsError -> listOf(symbol)
is ConeConstraintSystemHasContradiction -> listOf(candidate.symbol)
is ConeDeprecated -> listOf(symbol)
is ConeNoTypeArgumentsOnRhsError -> listOf(symbol)
is ConeResolutionToClassifierError -> listOf(classSymbol)
is ConeWrongNumberOfTypeArgumentsError -> listOf(symbol)
is ConeDiagnosticWithCandidates -> candidateSymbols
else -> emptyList()
}
@@ -56,7 +56,7 @@ internal object FirReferenceResolveHelper {
val symbol = resolvedSymbol ?: run {
val diagnostic = (this as? FirErrorTypeRef)?.diagnostic
(diagnostic as? ConeUnmatchedTypeArgumentsError)?.symbol
(diagnostic as? ConeUnmatchedTypeArgumentsError)?.candidateSymbol
}
return symbol?.fir?.buildSymbol(symbolBuilder)