[FIR] Report missed diagnostics from FirSyntheticCallGenerator
#KT-58207 Fixed
This commit is contained in:
committed by
Space Team
parent
cb825f664f
commit
4afc5315ca
@@ -19,6 +19,8 @@ import org.jetbrains.kotlin.fir.expressions.*
|
||||
import org.jetbrains.kotlin.fir.expressions.builder.*
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirUnitExpression
|
||||
import org.jetbrains.kotlin.fir.references.*
|
||||
import org.jetbrains.kotlin.fir.references.builder.buildErrorNamedReference
|
||||
import org.jetbrains.kotlin.fir.references.builder.buildResolvedErrorReference
|
||||
import org.jetbrains.kotlin.fir.resolve.calls.Candidate
|
||||
import org.jetbrains.kotlin.fir.resolve.calls.FirNamedReferenceWithCandidate
|
||||
import org.jetbrains.kotlin.fir.resolve.calls.FirPropertyWithExplicitBackingFieldResolvedNamedReference
|
||||
@@ -610,3 +612,19 @@ fun createConeDiagnosticForCandidateWithError(
|
||||
else -> ConeInapplicableCandidateError(applicability, candidate)
|
||||
}
|
||||
}
|
||||
|
||||
fun FirNamedReferenceWithCandidate.toErrorReference(diagnostic: ConeDiagnostic): FirNamedReference {
|
||||
val calleeReference = this
|
||||
return when (calleeReference.candidateSymbol) {
|
||||
is FirErrorPropertySymbol, is FirErrorFunctionSymbol -> buildErrorNamedReference {
|
||||
source = calleeReference.source
|
||||
this.diagnostic = diagnostic
|
||||
}
|
||||
else -> buildResolvedErrorReference {
|
||||
source = calleeReference.source
|
||||
name = calleeReference.name
|
||||
resolvedSymbol = calleeReference.candidateSymbol
|
||||
this.diagnostic = diagnostic
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-17
@@ -385,22 +385,6 @@ class FirCallCompletionResultsWriterTransformer(
|
||||
}
|
||||
}
|
||||
|
||||
private fun FirNamedReferenceWithCandidate.toErrorReference(diagnostic: ConeDiagnostic): FirNamedReference {
|
||||
val calleeReference = this
|
||||
return when (calleeReference.candidateSymbol) {
|
||||
is FirErrorPropertySymbol, is FirErrorFunctionSymbol -> buildErrorNamedReference {
|
||||
source = calleeReference.source
|
||||
this.diagnostic = diagnostic
|
||||
}
|
||||
else -> buildResolvedErrorReference {
|
||||
source = calleeReference.source
|
||||
name = calleeReference.name
|
||||
resolvedSymbol = calleeReference.candidateSymbol
|
||||
this.diagnostic = diagnostic
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun transformSmartCastExpression(smartCastExpression: FirSmartCastExpression, data: ExpectedArgumentType?): FirStatement {
|
||||
return smartCastExpression.transformOriginalExpression(this, data)
|
||||
}
|
||||
@@ -848,4 +832,4 @@ private fun ExpectedArgumentType.getExpectedType(argument: FirElement): ConeKotl
|
||||
ExpectedArgumentType.NoApproximation -> null
|
||||
}
|
||||
|
||||
fun ConeKotlinType.toExpectedType(): ExpectedArgumentType = ExpectedArgumentType.ExpectedType(this)
|
||||
fun ConeKotlinType.toExpectedType(): ExpectedArgumentType = ExpectedArgumentType.ExpectedType(this)
|
||||
+13
-2
@@ -22,11 +22,13 @@ import org.jetbrains.kotlin.fir.expressions.builder.buildFunctionCall
|
||||
import org.jetbrains.kotlin.fir.moduleData
|
||||
import org.jetbrains.kotlin.fir.references.FirReference
|
||||
import org.jetbrains.kotlin.fir.references.impl.FirStubReference
|
||||
import org.jetbrains.kotlin.fir.references.isError
|
||||
import org.jetbrains.kotlin.fir.resolve.BodyResolveComponents
|
||||
import org.jetbrains.kotlin.fir.resolve.ResolutionMode
|
||||
import org.jetbrains.kotlin.fir.resolve.calls.*
|
||||
import org.jetbrains.kotlin.fir.resolve.createErrorReferenceWithExistingCandidate
|
||||
import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeInapplicableCandidateError
|
||||
import org.jetbrains.kotlin.fir.resolve.toErrorReference
|
||||
import org.jetbrains.kotlin.fir.resolvedTypeFromPrototype
|
||||
import org.jetbrains.kotlin.fir.symbols.SyntheticCallableId
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol
|
||||
@@ -183,8 +185,17 @@ class FirSyntheticCallGenerator(
|
||||
this.argumentList = argumentList
|
||||
}
|
||||
|
||||
val argument = components.callCompleter.completeCall(fakeCallElement, ResolutionMode.ContextIndependent).result.argument
|
||||
return argument as FirCallableReferenceAccess?
|
||||
val result = components.callCompleter.completeCall(fakeCallElement, ResolutionMode.ContextIndependent).result
|
||||
val completedCallableReference = result.argument as FirCallableReferenceAccess?
|
||||
|
||||
val callCalleeReference = result.calleeReference
|
||||
if (callCalleeReference.isError()) {
|
||||
(completedCallableReference?.calleeReference as? FirNamedReferenceWithCandidate)
|
||||
?.toErrorReference(callCalleeReference.diagnostic)
|
||||
?.let { completedCallableReference.replaceCalleeReference(it) }
|
||||
}
|
||||
|
||||
return completedCallableReference
|
||||
}
|
||||
|
||||
private fun generateCalleeReferenceWithCandidate(
|
||||
|
||||
Reference in New Issue
Block a user