FIR: don't call a graph builder method in finally

If an exception is thrown, trying to add more nodes to a graph that's
already missing entire subgraphs may not end well.
This commit is contained in:
pyos
2022-11-24 17:09:01 +01:00
committed by teamcity
parent 38c1ef30bc
commit c231477375
@@ -1122,9 +1122,7 @@ open class FirExpressionsResolveTransformer(transformer: FirAbstractBodyResolveT
} }
dataFlowAnalyzer.enterDelegatedConstructorCall() dataFlowAnalyzer.enterDelegatedConstructorCall()
var callCompleted = true
var result = delegatedConstructorCall
try {
val lastDispatchReceiver = implicitReceiverStack.lastDispatchReceiver() val lastDispatchReceiver = implicitReceiverStack.lastDispatchReceiver()
context.forDelegatedConstructorCall(containingConstructor, containingClass as? FirRegularClass, components) { context.forDelegatedConstructorCall(containingConstructor, containingClass as? FirRegularClass, components) {
delegatedConstructorCall.transformChildren(transformer, ResolutionMode.ContextDependent) delegatedConstructorCall.transformChildren(transformer, ResolutionMode.ContextDependent)
@@ -1151,13 +1149,9 @@ open class FirExpressionsResolveTransformer(transformer: FirAbstractBodyResolveT
// it seems that we may leave this code as is // it seems that we may leave this code as is
// without adding `context.withTowerDataContext(context.getTowerDataContextForConstructorResolution())` // without adding `context.withTowerDataContext(context.getTowerDataContextForConstructorResolution())`
val completionResult = callCompleter.completeCall(resolvedCall, noExpectedType) val (result, callCompleted) = callCompleter.completeCall(resolvedCall, noExpectedType)
result = completionResult.result
callCompleted = completionResult.callCompleted
return result
} finally {
dataFlowAnalyzer.exitDelegatedConstructorCall(result, callCompleted) dataFlowAnalyzer.exitDelegatedConstructorCall(result, callCompleted)
} return result
} }
private fun extractSuperTypeDeclaration(typeRef: FirTypeRef): FirRegularClass? { private fun extractSuperTypeDeclaration(typeRef: FirTypeRef): FirRegularClass? {