[FIR] use whileAnalysing instead of direct exception handling

This commit is contained in:
Ilya Kirillov
2022-12-28 14:51:33 +01:00
committed by Space Team
parent 79fe4100aa
commit 4a31f82b14
2 changed files with 10 additions and 12 deletions
@@ -13,7 +13,10 @@ import org.jetbrains.kotlin.fir.declarations.builder.buildConstructorCopy
import org.jetbrains.kotlin.fir.declarations.builder.buildReceiverParameter
import org.jetbrains.kotlin.fir.declarations.utils.isInner
import org.jetbrains.kotlin.fir.languageVersionSettings
import org.jetbrains.kotlin.fir.resolve.*
import org.jetbrains.kotlin.fir.resolve.BodyResolveComponents
import org.jetbrains.kotlin.fir.resolve.fullyExpandedType
import org.jetbrains.kotlin.fir.resolve.originalConstructorIfTypeAlias
import org.jetbrains.kotlin.fir.resolve.scope
import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor
import org.jetbrains.kotlin.fir.scopes.FakeOverrideTypeCalculator
import org.jetbrains.kotlin.fir.scopes.FirScope
@@ -21,11 +24,13 @@ import org.jetbrains.kotlin.fir.scopes.processClassifiersByName
import org.jetbrains.kotlin.fir.scopes.scopeForClass
import org.jetbrains.kotlin.fir.symbols.impl.*
import org.jetbrains.kotlin.fir.symbols.lazyResolveToPhase
import org.jetbrains.kotlin.fir.types.*
import org.jetbrains.kotlin.fir.types.ConeClassLikeType
import org.jetbrains.kotlin.fir.types.coneTypeUnsafe
import org.jetbrains.kotlin.fir.types.withReplacedConeType
import org.jetbrains.kotlin.fir.visibilityChecker
import org.jetbrains.kotlin.fir.whileAnalysing
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.deprecation.DeprecationLevelValue
import org.jetbrains.kotlin.util.shouldIjPlatformExceptionBeRethrown
private operator fun <T> Pair<T, *>?.component1() = this?.first
private operator fun <T> Pair<*, T>?.component2() = this?.second
@@ -166,7 +171,7 @@ private fun processConstructors(
bodyResolveComponents: BodyResolveComponents,
includeInnerConstructors: Boolean
) {
try {
whileAnalysing(session, matchedSymbol.fir) {
val scope = when (matchedSymbol) {
is FirTypeAliasSymbol -> {
matchedSymbol.lazyResolveToPhase(FirResolvePhase.TYPES)
@@ -205,9 +210,6 @@ private fun processConstructors(
processor(it)
}
}
} catch (e: Throwable) {
if (shouldIjPlatformExceptionBeRethrown(e)) throw e
throw RuntimeException("While processing constructors", e)
}
}
@@ -51,7 +51,6 @@ import org.jetbrains.kotlin.types.AbstractTypeChecker
import org.jetbrains.kotlin.types.ConstantValueKind
import org.jetbrains.kotlin.types.TypeApproximatorConfiguration
import org.jetbrains.kotlin.util.OperatorNameConventions
import org.jetbrains.kotlin.util.shouldIjPlatformExceptionBeRethrown
open class FirExpressionsResolveTransformer(transformer: FirAbstractBodyResolveTransformerDispatcher) : FirPartialBodyResolveTransformer(transformer) {
private inline val builtinTypes: BuiltinTypes get() = session.builtinTypes
@@ -398,7 +397,7 @@ open class FirExpressionsResolveTransformer(transformer: FirAbstractBodyResolveT
functionCall.replaceLambdaArgumentInvocationKinds(session)
functionCall.transformTypeArguments(transformer, ResolutionMode.ContextIndependent)
val (completeInference, callCompleted) =
try {
run {
val initialExplicitReceiver = functionCall.explicitReceiver
val withTransformedArguments = if (!resolvingAugmentedAssignment) {
dataFlowAnalyzer.enterCallArguments(functionCall, functionCall.arguments)
@@ -416,9 +415,6 @@ open class FirExpressionsResolveTransformer(transformer: FirAbstractBodyResolveT
callCompleter.completeCall(resultExplicitReceiver, noExpectedType)
}
callCompleter.completeCall(resultExpression, data)
} catch (e: Throwable) {
if (shouldIjPlatformExceptionBeRethrown(e)) throw e
throw RuntimeException("While resolving call ${functionCall.render()}", e)
}
val result = completeInference.transformToIntegerOperatorCallOrApproximateItIfNeeded(data)
if (!resolvingAugmentedAssignment) {