FIR: Transform synthetic calls children even without incomplete candidate
It might be necessary for cases like
run @l1{
run {
if (...) return@l1 1
}
}
"if" is a synthetic call, but without candidate since there's just one branch
But return@l1 1 is incomplete because it's resolved in dependent context
and "1" is hang incomplete integer literal
This commit is contained in:
+9
-2
@@ -534,9 +534,16 @@ class FirCallCompletionResultsWriterTransformer(
|
||||
syntheticCall: D,
|
||||
data: ExpectedArgumentType?,
|
||||
): CompositeTransformResult<FirStatement> where D : FirResolvable, D : FirExpression {
|
||||
val calleeReference = syntheticCall.calleeReference as? FirNamedReferenceWithCandidate ?: return syntheticCall.compose()
|
||||
val calleeReference = syntheticCall.calleeReference as? FirNamedReferenceWithCandidate
|
||||
val declaration = calleeReference?.candidate?.symbol?.fir as? FirSimpleFunction
|
||||
|
||||
val declaration = calleeReference.candidate.symbol.fir as? FirSimpleFunction ?: return syntheticCall.compose()
|
||||
if (calleeReference == null || declaration == null) {
|
||||
syntheticCall.transformChildren(
|
||||
this,
|
||||
data = data?.getExpectedType(syntheticCall)?.toExpectedType() ?: syntheticCall.typeRef.coneType.toExpectedType()
|
||||
)
|
||||
return syntheticCall.compose()
|
||||
}
|
||||
|
||||
val typeRef = typeCalculator.tryCalculateReturnType(declaration)
|
||||
syntheticCall.replaceTypeRefWithSubstituted(calleeReference, typeRef)
|
||||
|
||||
@@ -5,7 +5,7 @@ fun <M> materialize(): M = TODO()
|
||||
|
||||
fun test(b: Boolean) {
|
||||
<!INAPPLICABLE_CANDIDATE!>id<!>(if (b) {
|
||||
id(<!UNRESOLVED_REFERENCE!>unresolved<!>)
|
||||
<!INAPPLICABLE_CANDIDATE!>id<!>(<!UNRESOLVED_REFERENCE!>unresolved<!>)
|
||||
} else {
|
||||
id(
|
||||
materialize()
|
||||
|
||||
Reference in New Issue
Block a user