FIR: preserve diagnostics in createResolvedNamedReference
This commit is contained in:
committed by
TeamCityServer
parent
1b6fa4303f
commit
7aaac2573c
@@ -656,13 +656,20 @@ class FirCallResolver(
|
||||
ConeResolutionToClassifierError(fir.symbol)
|
||||
} else {
|
||||
val coneType = explicitReceiver?.typeRef?.coneType
|
||||
if (coneType != null && !coneType.isUnit) {
|
||||
ConeFunctionExpectedError(
|
||||
name.asString(),
|
||||
(fir as? FirTypedDeclaration)?.returnTypeRef?.coneType ?: coneType
|
||||
)
|
||||
} else {
|
||||
ConeUnresolvedNameError(name)
|
||||
when {
|
||||
coneType != null && !coneType.isUnit -> {
|
||||
ConeFunctionExpectedError(
|
||||
name.asString(),
|
||||
(fir as? FirTypedDeclaration)?.returnTypeRef?.coneType ?: coneType
|
||||
)
|
||||
}
|
||||
singleExpectedCandidate != null && !singleExpectedCandidate.currentApplicability.isSuccess -> {
|
||||
createConeDiagnosticForCandidateWithError(
|
||||
singleExpectedCandidate.currentApplicability,
|
||||
singleExpectedCandidate
|
||||
)
|
||||
}
|
||||
else -> ConeUnresolvedNameError(name)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -702,13 +709,7 @@ class FirCallResolver(
|
||||
|
||||
!applicability.isSuccess -> {
|
||||
val candidate = candidates.single()
|
||||
val diagnostic = when (applicability) {
|
||||
CandidateApplicability.HIDDEN -> ConeHiddenCandidateError(candidate.symbol)
|
||||
CandidateApplicability.VISIBILITY_ERROR -> ConeVisibilityError(candidate.symbol)
|
||||
CandidateApplicability.INAPPLICABLE_WRONG_RECEIVER -> ConeInapplicableWrongReceiver(listOf(candidate.symbol))
|
||||
CandidateApplicability.NO_COMPANION_OBJECT -> ConeNoCompanionObject(candidate.symbol as FirRegularClassSymbol)
|
||||
else -> ConeInapplicableCandidateError(applicability, candidate)
|
||||
}
|
||||
val diagnostic = createConeDiagnosticForCandidateWithError(applicability, candidate)
|
||||
createErrorReferenceWithExistingCandidate(
|
||||
candidate,
|
||||
diagnostic,
|
||||
@@ -759,6 +760,19 @@ class FirCallResolver(
|
||||
}
|
||||
}
|
||||
|
||||
private fun createConeDiagnosticForCandidateWithError(
|
||||
applicability: CandidateApplicability,
|
||||
candidate: Candidate
|
||||
): ConeDiagnosticWithCandidates {
|
||||
return when (applicability) {
|
||||
CandidateApplicability.HIDDEN -> ConeHiddenCandidateError(candidate.symbol)
|
||||
CandidateApplicability.VISIBILITY_ERROR -> ConeVisibilityError(candidate.symbol)
|
||||
CandidateApplicability.INAPPLICABLE_WRONG_RECEIVER -> ConeInapplicableWrongReceiver(listOf(candidate.symbol))
|
||||
CandidateApplicability.NO_COMPANION_OBJECT -> ConeNoCompanionObject(candidate.symbol as FirRegularClassSymbol)
|
||||
else -> ConeInapplicableCandidateError(applicability, candidate)
|
||||
}
|
||||
}
|
||||
|
||||
private fun buildErrorReference(
|
||||
callInfo: CallInfo,
|
||||
diagnostic: ConeDiagnostic,
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ fun test() {
|
||||
baz {
|
||||
y()
|
||||
|
||||
<!UNRESOLVED_REFERENCE!>x<!>()
|
||||
<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>x<!>()
|
||||
|
||||
with(D()) {
|
||||
x()
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ fun test() {
|
||||
baz {
|
||||
y()
|
||||
|
||||
<!UNRESOLVED_REFERENCE!>x<!>()
|
||||
<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>x<!>()
|
||||
|
||||
with(D()) {
|
||||
x()
|
||||
|
||||
Reference in New Issue
Block a user