From 4a31f82b149f546fa95227ad1761a8af3f92805b Mon Sep 17 00:00:00 2001 From: Ilya Kirillov Date: Wed, 28 Dec 2022 14:51:33 +0100 Subject: [PATCH] [FIR] use whileAnalysing instead of direct exception handling --- .../fir/resolve/calls/ConstructorProcessing.kt | 16 +++++++++------- .../resolve/FirExpressionsResolveTransformer.kt | 6 +----- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ConstructorProcessing.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ConstructorProcessing.kt index c70c97a4f9b..4bc23e7c47c 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ConstructorProcessing.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ConstructorProcessing.kt @@ -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 Pair?.component1() = this?.first private operator fun 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) } } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt index 6ae5e1797f4..b98fc17f6b1 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt @@ -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) {