FIR: transform other parts of function call even though callee is an error

This commit is contained in:
Jinseong Jeon
2021-02-09 22:11:13 -08:00
committed by Mikhail Glukhikh
parent 27c942a0ff
commit a841a0bbca
3 changed files with 11 additions and 4 deletions
@@ -13,8 +13,8 @@ FILE: superIsNotAnExpression.kt
public final fun act(): R|kotlin/Unit| {
<Super cannot be a callee>#()
<Unresolved name: invoke>#()
<Super cannot be a callee>#(<L> = <Super cannot be a callee>@fun <implicit>.<anonymous>(): <implicit> {
println#(ERROR_EXPR(Incorrect character: 'weird'))
<Super cannot be a callee>#(<L> = <Super cannot be a callee>@fun <anonymous>(): R|ERROR CLASS: Unresolved name: println| {
^ <Unresolved name: println>#(ERROR_EXPR(Incorrect character: 'weird'))
}
)
}
@@ -7,7 +7,7 @@ class B: A() {
<!UNRESOLVED_REFERENCE{LT}!><!UNRESOLVED_REFERENCE{PSI}!>invoke<!>()<!>
<!SUPER_IS_NOT_AN_EXPRESSION!>super<!> {
println(<!ILLEGAL_CONST_EXPRESSION!>'weird'<!>)
<!UNRESOLVED_REFERENCE{LT}!><!UNRESOLVED_REFERENCE{PSI}!>println<!>(<!ILLEGAL_CONST_EXPRESSION!>'weird'<!>)<!>
}
}
}
@@ -262,7 +262,14 @@ open class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransform
if (functionCall.calleeReference is FirResolvedNamedReference && functionCall.resultType is FirImplicitTypeRef) {
storeTypeFromCallee(functionCall)
}
if (functionCall.calleeReference !is FirSimpleNamedReference) return functionCall.compose()
if (functionCall.calleeReference !is FirSimpleNamedReference) {
// The callee reference can be resolved as an error very early, e.g., `super` as a callee during raw FIR creation.
// We still need to visit/transform other parts, e.g., call arguments, to check if any other errors are there.
if (functionCall.calleeReference !is FirResolvedNamedReference) {
functionCall.transformChildren(transformer, data)
}
return functionCall.compose()
}
if (functionCall.calleeReference is FirNamedReferenceWithCandidate) return functionCall.compose()
dataFlowAnalyzer.enterCall()
functionCall.transformAnnotations(transformer, data)