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)
|
ConeResolutionToClassifierError(fir.symbol)
|
||||||
} else {
|
} else {
|
||||||
val coneType = explicitReceiver?.typeRef?.coneType
|
val coneType = explicitReceiver?.typeRef?.coneType
|
||||||
if (coneType != null && !coneType.isUnit) {
|
when {
|
||||||
ConeFunctionExpectedError(
|
coneType != null && !coneType.isUnit -> {
|
||||||
name.asString(),
|
ConeFunctionExpectedError(
|
||||||
(fir as? FirTypedDeclaration)?.returnTypeRef?.coneType ?: coneType
|
name.asString(),
|
||||||
)
|
(fir as? FirTypedDeclaration)?.returnTypeRef?.coneType ?: coneType
|
||||||
} else {
|
)
|
||||||
ConeUnresolvedNameError(name)
|
}
|
||||||
|
singleExpectedCandidate != null && !singleExpectedCandidate.currentApplicability.isSuccess -> {
|
||||||
|
createConeDiagnosticForCandidateWithError(
|
||||||
|
singleExpectedCandidate.currentApplicability,
|
||||||
|
singleExpectedCandidate
|
||||||
|
)
|
||||||
|
}
|
||||||
|
else -> ConeUnresolvedNameError(name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -702,13 +709,7 @@ class FirCallResolver(
|
|||||||
|
|
||||||
!applicability.isSuccess -> {
|
!applicability.isSuccess -> {
|
||||||
val candidate = candidates.single()
|
val candidate = candidates.single()
|
||||||
val diagnostic = when (applicability) {
|
val diagnostic = createConeDiagnosticForCandidateWithError(applicability, candidate)
|
||||||
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)
|
|
||||||
}
|
|
||||||
createErrorReferenceWithExistingCandidate(
|
createErrorReferenceWithExistingCandidate(
|
||||||
candidate,
|
candidate,
|
||||||
diagnostic,
|
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(
|
private fun buildErrorReference(
|
||||||
callInfo: CallInfo,
|
callInfo: CallInfo,
|
||||||
diagnostic: ConeDiagnostic,
|
diagnostic: ConeDiagnostic,
|
||||||
|
|||||||
+1
-1
@@ -40,7 +40,7 @@ fun test() {
|
|||||||
baz {
|
baz {
|
||||||
y()
|
y()
|
||||||
|
|
||||||
<!UNRESOLVED_REFERENCE!>x<!>()
|
<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>x<!>()
|
||||||
|
|
||||||
with(D()) {
|
with(D()) {
|
||||||
x()
|
x()
|
||||||
|
|||||||
+1
-1
@@ -36,7 +36,7 @@ fun test() {
|
|||||||
baz {
|
baz {
|
||||||
y()
|
y()
|
||||||
|
|
||||||
<!UNRESOLVED_REFERENCE!>x<!>()
|
<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>x<!>()
|
||||||
|
|
||||||
with(D()) {
|
with(D()) {
|
||||||
x()
|
x()
|
||||||
|
|||||||
Reference in New Issue
Block a user