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:
Denis.Zharkov
2021-01-14 16:26:35 +03:00
parent 5f0d00a83f
commit 5afebb4e78
2 changed files with 10 additions and 3 deletions
@@ -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()