From f9618db9e24b44e50d0614d24b3e76944ff14fd7 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Thu, 11 Mar 2021 10:03:30 +0300 Subject: [PATCH] FIR: rearrange functions in BodyResolveContext --- .../kotlin/fir/resolve/calls/FirReceivers.kt | 9 +- .../resolve/transformers/TransformUtils.kt | 2 +- .../body/resolve/BodyResolveContext.kt | 463 ++++++++++-------- .../FirDeclarationsResolveTransformer.kt | 20 - 4 files changed, 248 insertions(+), 246 deletions(-) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirReceivers.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirReceivers.kt index 87e3f5c15ef..0ce7b7d1813 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirReceivers.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirReceivers.kt @@ -137,11 +137,4 @@ class InaccessibleImplicitReceiverValue( type: ConeKotlinType, useSiteSession: FirSession, scopeSession: ScopeSession -) : ImplicitReceiverValue>(boundSymbol, type, useSiteSession, scopeSession) { - internal constructor( - boundSymbol: FirClassSymbol<*>, useSiteSession: FirSession, scopeSession: ScopeSession - ) : this( - boundSymbol, boundSymbol.constructType(typeArguments = emptyArray(), isNullable = false), - useSiteSession, scopeSession - ) -} +) : ImplicitReceiverValue>(boundSymbol, type, useSiteSession, scopeSession) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/TransformUtils.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/TransformUtils.kt index 144b62c3e63..b4c4bd395bc 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/TransformUtils.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/TransformUtils.kt @@ -122,7 +122,7 @@ internal fun FirTypedDeclaration.transformTypeToArrayType() { ) } -inline fun withScopeCleanup(scopes: MutableList<*>, crossinline l: () -> T): T { +inline fun withScopeCleanup(scopes: MutableList<*>, l: () -> T): T { val sizeBefore = scopes.size return try { l() diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/BodyResolveContext.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/BodyResolveContext.kt index cf2d5c92e02..75412810e2c 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/BodyResolveContext.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/BodyResolveContext.kt @@ -45,26 +45,28 @@ class BodyResolveContext( val targetedLocalClasses: Set> = emptySet(), val outerLocalClassForNested: MutableMap, FirClassLikeSymbol<*>> = mutableMapOf() ) { - private val mutableFileImportsScope: MutableList = mutableListOf() - - val fileImportsScope: List - get() = mutableFileImportsScope + val fileImportsScope: MutableList = mutableListOf() @set:PrivateForInline lateinit var file: FirFile - private set - @set:PrivateForInline - var towerDataContextsForClassParts: FirTowerDataContextsForClassParts = - FirTowerDataContextsForClassParts(forMemberDeclarations = FirTowerDataContext()) + var towerDataContextsForClassParts = FirTowerDataContextsForClassParts(forMemberDeclarations = FirTowerDataContext()) + private set val towerDataContext: FirTowerDataContext get() = towerDataContextsForClassParts.currentContext + @OptIn(PrivateForInline::class) + var towerDataMode: FirTowerDataMode + get() = towerDataContextsForClassParts.mode + set(value) { + towerDataContextsForClassParts.mode = value + } + val implicitReceiverStack: ImplicitReceiverStack get() = towerDataContext.implicitReceiverStack - val towerDataContextForAnonymousFunctions: MutableMap + private val towerDataContextForAnonymousFunctions: MutableMap get() = towerDataContextsForClassParts.towerDataContextForAnonymousFunctions private val towerDataContextForCallableReferences: MutableMap @@ -81,6 +83,188 @@ class BodyResolveContext( val anonymousFunctionsAnalyzedInDependentContext: MutableSet> = mutableSetOf() + private inline fun withNewTowerDataForClassParts(newContexts: FirTowerDataContextsForClassParts, f: () -> T): T { + val old = towerDataContextsForClassParts + towerDataContextsForClassParts = newContexts + return try { + f() + } finally { + + towerDataContextsForClassParts = old + } + } + + private inline fun withLambdaBeingAnalyzedInDependentContext(lambda: FirAnonymousFunctionSymbol, l: () -> R): R { + anonymousFunctionsAnalyzedInDependentContext.add(lambda) + return try { + l() + } finally { + anonymousFunctionsAnalyzedInDependentContext.remove(lambda) + } + } + + @PrivateForInline + inline fun withContainer(declaration: FirDeclaration, f: () -> T): T { + val oldContainers = containers + containers = containers.add(declaration) + return try { + f() + } finally { + containers = oldContainers + } + } + + @PrivateForInline + inline fun withTowerDataCleanup(l: () -> R): R { + val initialContext = towerDataContext + return try { + l() + } finally { + replaceTowerDataContext(initialContext) + } + } + + @PrivateForInline + inline fun withTowerDataMode(mode: FirTowerDataMode, f: () -> T): T { + return withTowerModeCleanup { + towerDataMode = mode + f() + } + } + + @PrivateForInline + inline fun withTowerModeCleanup(l: () -> R): R { + val initialMode = towerDataMode + return try { + l() + } finally { + towerDataMode = initialMode + } + } + + @PrivateForInline + fun replaceTowerDataContext(newContext: FirTowerDataContext) { + towerDataContextsForClassParts.currentContext = newContext + } + + @PrivateForInline + fun clear() { + towerDataContextForAnonymousFunctions.clear() + towerDataContextForCallableReferences.clear() + dataFlowAnalyzerContext.reset() + } + + @PrivateForInline + fun addNonLocalTowerDataElement(element: FirTowerDataElement) { + replaceTowerDataContext(towerDataContext.addNonLocalTowerDataElements(listOf(element))) + } + + @PrivateForInline + fun addNonLocalTowerDataElements(newElements: List) { + replaceTowerDataContext(towerDataContext.addNonLocalTowerDataElements(newElements)) + } + + @PrivateForInline + fun addLocalScope(localScope: FirLocalScope) { + replaceTowerDataContext(towerDataContext.addLocalScope(localScope)) + } + + @PrivateForInline + fun addReceiver(name: Name?, implicitReceiverValue: ImplicitReceiverValue<*>) { + replaceTowerDataContext(towerDataContext.addReceiver(name, implicitReceiverValue)) + } + + @PrivateForInline + private inline fun updateLastScope(transform: FirLocalScope.() -> FirLocalScope) { + val lastScope = towerDataContext.localScopes.lastOrNull() ?: return + replaceTowerDataContext(towerDataContext.setLastLocalScope(lastScope.transform())) + } + + @PrivateForInline + fun storeFunction(function: FirSimpleFunction) { + updateLastScope { storeFunction(function) } + } + + @PrivateForInline + private inline fun withLabelAndReceiverType( + labelName: Name?, + owner: FirCallableDeclaration<*>, + type: ConeKotlinType?, + holder: SessionHolder, + f: () -> T + ): T = withTowerDataCleanup { + if (type != null) { + val receiver = ImplicitExtensionReceiverValue( + owner.symbol, + type, + holder.session, + holder.scopeSession + ) + addReceiver(labelName, receiver) + } + + f() + } + + @PrivateForInline + inline fun withTypeParametersOf(declaration: FirMemberDeclaration, l: () -> T): T { + if (declaration.typeParameters.isEmpty()) return l() + val scope = FirMemberTypeParameterScope(declaration) + return withTowerDataCleanup { + addNonLocalTowerDataElement(scope.asTowerDataElement(isLocal = false)) + l() + } + } + + private fun FirMemberDeclaration.typeParameterScope(): FirMemberTypeParameterScope? { + if (typeParameters.isEmpty()) return null + return FirMemberTypeParameterScope(this) + } + + private fun buildSecondaryConstructorParametersScope(constructor: FirConstructor): FirLocalScope = + constructor.valueParameters.fold(FirLocalScope()) { acc, param -> acc.storeVariable(param) } + + @PrivateForInline + fun addInaccessibleImplicitReceiverValue( + owningClass: FirRegularClass?, + holder: SessionHolder, + ) { + if (owningClass == null) return + addReceiver( + name = null, + implicitReceiverValue = InaccessibleImplicitReceiverValue( + owningClass.symbol, + owningClass.defaultType(), + holder.session, + holder.scopeSession + ) + ) + } + + @PrivateForInline + private fun storeBackingField(property: FirProperty) { + updateLastScope { storeBackingField(property) } + } + + // ANALYSIS PUBLIC API + + fun getPrimaryConstructorPureParametersScope(): FirLocalScope? = + towerDataContextsForClassParts.primaryConstructorPureParametersScope + + fun getPrimaryConstructorAllParametersScope(): FirLocalScope? = + towerDataContextsForClassParts.primaryConstructorAllParametersScope + + @OptIn(PrivateForInline::class) + fun storeClassIfNotNested(klass: FirRegularClass) { + if (containerIfAny is FirClass<*>) return + updateLastScope { storeClass(klass) } + } + + @OptIn(PrivateForInline::class) + fun storeVariable(variable: FirVariable<*>) { + updateLastScope { storeVariable(variable) } + } + @OptIn(PrivateForInline::class) inline fun withInferenceSession(inferenceSession: FirInferenceSession, block: () -> R): R { val oldSession = this.inferenceSession @@ -93,51 +277,6 @@ class BodyResolveContext( } @OptIn(PrivateForInline::class) - inline fun withNewTowerDataForClassParts(newContexts: FirTowerDataContextsForClassParts, f: () -> T): T { - val old = towerDataContextsForClassParts - towerDataContextsForClassParts = newContexts - return try { - f() - } finally { - - towerDataContextsForClassParts = old - } - } - - fun getPrimaryConstructorPureParametersScope(): FirLocalScope? = - towerDataContextsForClassParts.primaryConstructorPureParametersScope - - fun getPrimaryConstructorAllParametersScope(): FirLocalScope? = - towerDataContextsForClassParts.primaryConstructorAllParametersScope - - @OptIn(PrivateForInline::class) - inline fun withContainer(declaration: FirDeclaration, crossinline f: () -> T): T { - val oldContainers = containers - containers = containers.add(declaration) - return try { - f() - } finally { - containers = oldContainers - } - } - - @OptIn(PrivateForInline::class) - inline fun withTowerDataCleanup(l: () -> R): R { - val initialContext = towerDataContext - return try { - l() - } finally { - replaceTowerDataContext(initialContext) - } - } - - inline fun withTowerDataMode(mode: FirTowerDataMode, f: () -> T): T { - return withTowerModeCleanup { - towerDataMode = mode - f() - } - } - inline fun withAnonymousFunctionTowerDataContext(symbol: FirAnonymousFunctionSymbol, f: () -> T): T { return withTowerModeCleanup { towerDataContextsForClassParts.setAnonymousFunctionContext(symbol) @@ -145,6 +284,7 @@ class BodyResolveContext( } } + @OptIn(PrivateForInline::class) inline fun withCallableReferenceTowerDataContext(access: FirCallableReferenceAccess, f: () -> T): T { return withTowerModeCleanup { towerDataContextsForClassParts.setCallableReferenceContextIfAny(access) @@ -152,84 +292,10 @@ class BodyResolveContext( } } - inline fun withTowerModeCleanup(l: () -> R): R { - val initialMode = towerDataMode - return try { - l() - } finally { - towerDataMode = initialMode - } - } - - @OptIn(PrivateForInline::class) - inline fun withLambdaBeingAnalyzedInDependentContext(lambda: FirAnonymousFunctionSymbol, l: () -> R): R { - anonymousFunctionsAnalyzedInDependentContext.add(lambda) - return try { - l() - } finally { - anonymousFunctionsAnalyzedInDependentContext.remove(lambda) - } - } - - var towerDataMode: FirTowerDataMode - get() = towerDataContextsForClassParts.mode - set(value) { - towerDataContextsForClassParts.mode = value - } - - @OptIn(PrivateForInline::class) - fun replaceTowerDataContext(newContext: FirTowerDataContext) { - towerDataContextsForClassParts.currentContext = newContext - } - - fun addNonLocalTowerDataElement(element: FirTowerDataElement) { - replaceTowerDataContext(towerDataContext.addNonLocalTowerDataElements(listOf(element))) - } - - fun addNonLocalTowerDataElements(newElements: List) { - replaceTowerDataContext(towerDataContext.addNonLocalTowerDataElements(newElements)) - } - - fun addLocalScope(localScope: FirLocalScope) { - replaceTowerDataContext(towerDataContext.addLocalScope(localScope)) - } - - fun addReceiver(name: Name?, implicitReceiverValue: ImplicitReceiverValue<*>) { - replaceTowerDataContext(towerDataContext.addReceiver(name, implicitReceiverValue)) - } - - fun storeClassIfNotNested(klass: FirRegularClass) { - if (containerIfAny is FirClass<*>) return - updateLastScope { storeClass(klass) } - } - - fun storeFunction(function: FirSimpleFunction) { - updateLastScope { storeFunction(function) } - } - - fun storeVariable(variable: FirVariable<*>) { - updateLastScope { storeVariable(variable) } - } - - fun storeBackingField(property: FirProperty) { - updateLastScope { storeBackingField(property) } - } - fun dropContextForAnonymousFunction(anonymousFunction: FirAnonymousFunction) { towerDataContextForAnonymousFunctions.remove(anonymousFunction.symbol) } - fun clear() { - towerDataContextForAnonymousFunctions.clear() - towerDataContextForCallableReferences.clear() - dataFlowAnalyzerContext.reset() - } - - private inline fun updateLastScope(transform: FirLocalScope.() -> FirLocalScope) { - val lastScope = towerDataContext.localScopes.lastOrNull() ?: return - replaceTowerDataContext(towerDataContext.setLastLocalScope(lastScope.transform())) - } - @OptIn(PrivateForInline::class) fun createSnapshotForLocalClasses( returnTypeCalculator: ReturnTypeCalculator, @@ -244,31 +310,32 @@ class BodyResolveContext( anonymousFunctionsAnalyzedInDependentContext.addAll(this@BodyResolveContext.anonymousFunctionsAnalyzedInDependentContext) } - // WITH FirElement functions + // withElement PUBLIC API - internal inline fun withFile( + @OptIn(PrivateForInline::class) + inline fun withFile( file: FirFile, holder: SessionHolder, - crossinline f: () -> T + f: () -> T ): T { clear() - @OptIn(PrivateForInline::class) this.file = file - return withScopeCleanup(mutableFileImportsScope) { + return withScopeCleanup(fileImportsScope) { withTowerDataCleanup { val importingScopes = createImportingScopes(file, holder.session, holder.scopeSession) - mutableFileImportsScope += importingScopes + fileImportsScope += importingScopes addNonLocalTowerDataElements(importingScopes.map { it.asTowerDataElement(isLocal = false) }) f() } } } - inline fun withRegularClass( + @OptIn(PrivateForInline::class) + fun withRegularClass( regularClass: FirRegularClass, holder: SessionHolder, forContracts: Boolean = false, - crossinline f: () -> T + f: () -> T ): T { storeClassIfNotNested(regularClass) if (forContracts) { @@ -291,6 +358,7 @@ class BodyResolveContext( } } + @OptIn(PrivateForInline::class) inline fun withAnonymousObject( anonymousObject: FirAnonymousObject, holder: SessionHolder, @@ -301,7 +369,7 @@ class BodyResolveContext( } } - inline fun withScopesForClass( + fun withScopesForClass( owner: FirClass<*>, holder: SessionHolder, f: () -> T @@ -362,7 +430,7 @@ class BodyResolveContext( } } - fun FirConstructor.scopesWithPrimaryConstructorParameters( + private fun FirConstructor.scopesWithPrimaryConstructorParameters( ownerClass: FirClass<*> ): Pair { var parameterScope = FirLocalScope() @@ -378,9 +446,10 @@ class BodyResolveContext( return parameterScope to allScope } + @OptIn(PrivateForInline::class) inline fun withSimpleFunction( simpleFunction: FirSimpleFunction, - crossinline f: () -> T + f: () -> T ): T { if (containerIfAny !is FirClass<*>) { storeFunction(simpleFunction) @@ -391,10 +460,11 @@ class BodyResolveContext( } } - inline fun forFunctionBody( + @OptIn(PrivateForInline::class) + fun forFunctionBody( function: FirFunction<*>, holder: SessionHolder, - crossinline f: () -> T + f: () -> T ): T { return withTowerDataCleanup { addLocalScope(FirLocalScope()) @@ -407,9 +477,10 @@ class BodyResolveContext( } } - inline fun forConstructorBody( + @OptIn(PrivateForInline::class) + fun forConstructorBody( constructor: FirConstructor, - crossinline f: () -> T + f: () -> T ): T { return if (constructor.isPrimary) { /* @@ -429,11 +500,12 @@ class BodyResolveContext( } } - inline fun withAnonymousFunction( + @OptIn(PrivateForInline::class) + fun withAnonymousFunction( anonymousFunction: FirAnonymousFunction, holder: SessionHolder, mode: ResolutionMode, - crossinline f: () -> T + f: () -> T ): T { if (mode !is ResolutionMode.LambdaResolution) { towerDataContextForAnonymousFunctions[anonymousFunction.symbol] = towerDataContext @@ -457,9 +529,10 @@ class BodyResolveContext( } } + @OptIn(PrivateForInline::class) inline fun withField( field: FirField, - crossinline f: () -> T + f: () -> T ): T { return withTowerDataMode(FirTowerDataMode.CONSTRUCTOR_HEADER) { withContainer(field) { @@ -471,13 +544,15 @@ class BodyResolveContext( } } + @OptIn(PrivateForInline::class) inline fun forEnumEntry( - crossinline f: () -> T + f: () -> T ): T = withTowerDataMode(FirTowerDataMode.CONSTRUCTOR_HEADER, f) + @OptIn(PrivateForInline::class) inline fun withAnonymousInitializer( anonymousInitializer: FirAnonymousInitializer, - crossinline f: () -> T + f: () -> T ): T { return withTowerDataCleanup { getPrimaryConstructorPureParametersScope()?.let { addLocalScope(it) } @@ -486,29 +561,32 @@ class BodyResolveContext( } } + @OptIn(PrivateForInline::class) inline fun withValueParameter( valueParameter: FirValueParameter, - crossinline f: () -> T + f: () -> T ): T { storeVariable(valueParameter) return withContainer(valueParameter, f) } + @OptIn(PrivateForInline::class) inline fun withProperty( property: FirProperty, - crossinline f: () -> T + f: () -> T ): T { return withTypeParametersOf(property) { withContainer(property, f) } } - inline fun withPropertyAccessor( + @OptIn(PrivateForInline::class) + fun withPropertyAccessor( property: FirProperty, accessor: FirPropertyAccessor, holder: SessionHolder, forContracts: Boolean = false, - crossinline f: () -> T + f: () -> T ): T { if (accessor is FirDefaultPropertyAccessor || accessor.body == null) { return withContainer(accessor, f) @@ -527,7 +605,8 @@ class BodyResolveContext( } } - inline fun forPropertyInitializer(crossinline f: () -> T): T { + @OptIn(PrivateForInline::class) + inline fun forPropertyInitializer(f: () -> T): T { return withTowerDataCleanup { getPrimaryConstructorPureParametersScope()?.let { addLocalScope(it) } f() @@ -539,7 +618,7 @@ class BodyResolveContext( delegateExpression: FirExpression, resolutionContext: ResolutionContext, callCompleter: FirCallCompleter, - crossinline f: FirDelegatedPropertyInferenceSession.() -> T + f: FirDelegatedPropertyInferenceSession.() -> T ) { val inferenceSession = FirDelegatedPropertyInferenceSession( property, @@ -553,60 +632,21 @@ class BodyResolveContext( } } - inline fun withLabelAndReceiverType( - labelName: Name?, - owner: FirCallableDeclaration<*>, - type: ConeKotlinType?, - holder: SessionHolder, - f: () -> T - ): T = withTowerDataCleanup { - if (type != null) { - val receiver = ImplicitExtensionReceiverValue( - owner.symbol, - type, - holder.session, - holder.scopeSession - ) - addReceiver(labelName, receiver) - } - - f() - } - - inline fun withTypeParametersOf(declaration: FirMemberDeclaration, crossinline l: () -> T): T { - val scope = declaration.typeParameterScope() - return withTowerDataCleanup { - scope?.let { addNonLocalTowerDataElement(it.asTowerDataElement(isLocal = false)) } - l() - } - } - - fun FirMemberDeclaration.typeParameterScope(): FirMemberTypeParameterScope? { - if (typeParameters.isEmpty()) return null - return FirMemberTypeParameterScope(this) - } - - inline fun withConstructor(constructor: FirConstructor, crossinline f: () -> T): T = + @OptIn(PrivateForInline::class) + inline fun withConstructor(constructor: FirConstructor, f: () -> T): T = withContainer(constructor, f) + @OptIn(PrivateForInline::class) inline fun forConstructorParameters( constructor: FirConstructor, owningClass: FirRegularClass?, holder: SessionHolder, - crossinline f: () -> T + f: () -> T ): T { // Default values of constructor can't access members of constructing class return withTowerDataMode(FirTowerDataMode.CONSTRUCTOR_HEADER) { - if (owningClass != null && !constructor.isPrimary) { - addReceiver( - null, - InaccessibleImplicitReceiverValue( - owningClass.symbol, - owningClass.defaultType(), - holder.session, - holder.scopeSession - ) - ) + if (!constructor.isPrimary) { + addInaccessibleImplicitReceiverValue(owningClass, holder) } withTowerDataCleanup { addLocalScope(FirLocalScope()) @@ -615,11 +655,12 @@ class BodyResolveContext( } } - inline fun forDelegatedConstructor( + @OptIn(PrivateForInline::class) + fun forDelegatedConstructor( constructor: FirConstructor, owningClass: FirRegularClass?, holder: SessionHolder, - crossinline f: () -> T + f: () -> T ): T { return withTowerDataMode(FirTowerDataMode.CONSTRUCTOR_HEADER) { if (constructor.isPrimary) { @@ -630,17 +671,7 @@ class BodyResolveContext( } } ?: f() } else { - if (owningClass != null) { - addReceiver( - null, - InaccessibleImplicitReceiverValue( - owningClass.symbol, - owningClass.defaultType(), - holder.session, - holder.scopeSession - ) - ) - } + addInaccessibleImplicitReceiverValue(owningClass, holder) withTowerDataCleanup { addLocalScope(buildSecondaryConstructorParametersScope(constructor)) constructor.valueParameters.forEach { storeVariable(it) } @@ -650,9 +681,6 @@ class BodyResolveContext( } } - fun buildSecondaryConstructorParametersScope(constructor: FirConstructor): FirLocalScope = - constructor.valueParameters.fold(FirLocalScope()) { acc, param -> acc.storeVariable(param) } - fun storeCallableReferenceContext(callableReferenceAccess: FirCallableReferenceAccess) { towerDataContextForCallableReferences[callableReferenceAccess] = towerDataContext } @@ -661,12 +689,13 @@ class BodyResolveContext( towerDataContextForCallableReferences.remove(callableReferenceAccess) } - inline fun withWhenExpression(whenExpression: FirWhenExpression, crossinline f: () -> T): T { + fun withWhenExpression(whenExpression: FirWhenExpression, f: () -> T): T { if (whenExpression.subjectVariable == null) return f() return forBlock(f) } - inline fun forBlock(crossinline f: () -> T): T { + @OptIn(PrivateForInline::class) + inline fun forBlock(f: () -> T): T { return withTowerDataCleanup { addLocalScope(FirLocalScope()) f() diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt index 8d9357c4059..b6a8fbd1d75 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt @@ -21,7 +21,6 @@ import org.jetbrains.kotlin.fir.expressions.builder.buildUnitExpression import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference import org.jetbrains.kotlin.fir.resolve.* import org.jetbrains.kotlin.fir.resolve.calls.FirNamedReferenceWithCandidate -import org.jetbrains.kotlin.fir.resolve.calls.ImplicitExtensionReceiverValue import org.jetbrains.kotlin.fir.resolve.dfa.FirControlFlowGraphReferenceImpl import org.jetbrains.kotlin.fir.resolve.inference.extractLambdaInfoFromFunctionalType import org.jetbrains.kotlin.fir.resolve.inference.isSuspendFunctionType @@ -773,25 +772,6 @@ open class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransfor return this } - protected inline fun withLabelAndReceiverType( - labelName: Name?, - owner: FirCallableDeclaration<*>, - type: ConeKotlinType?, - block: () -> T - ): T = context.withTowerDataCleanup { - if (type != null) { - val receiver = ImplicitExtensionReceiverValue( - owner.symbol, - type, - components.session, - components.scopeSession - ) - context.addReceiver(labelName, receiver) - } - - block() - } - private fun storeVariableReturnType(variable: FirVariable<*>) { val initializer = variable.initializer if (variable.returnTypeRef is FirImplicitTypeRef) {