[FIR] Extract withScopesCleanup from FirAbstractBodyResolveTransformer
This commit is contained in:
+14
-1
@@ -97,4 +97,17 @@ internal fun FirValueParameter.transformVarargTypeToArrayType() {
|
|||||||
returnTypeRef.withReplacedConeType(ConeKotlinTypeProjectionOut(returnType).createArrayOf(session))
|
returnTypeRef.withReplacedConeType(ConeKotlinTypeProjectionOut(returnType).createArrayOf(session))
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline fun <T> withScopeCleanup(scopes: MutableList<*>, crossinline l: () -> T): T {
|
||||||
|
val sizeBefore = scopes.size
|
||||||
|
return try {
|
||||||
|
l()
|
||||||
|
} finally {
|
||||||
|
val size = scopes.size
|
||||||
|
assert(size >= sizeBefore)
|
||||||
|
repeat(size - sizeBefore) {
|
||||||
|
scopes.let { it.removeAt(it.size - 1) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
-13
@@ -41,19 +41,6 @@ abstract class FirAbstractBodyResolveTransformer(phase: FirResolvePhase) : FirAb
|
|||||||
return phasedFir(requiredPhase)
|
return phasedFir(requiredPhase)
|
||||||
}
|
}
|
||||||
|
|
||||||
protected inline fun <T> withScopeCleanup(scopes: MutableList<*>, crossinline l: () -> T): T {
|
|
||||||
val sizeBefore = scopes.size
|
|
||||||
return try {
|
|
||||||
l()
|
|
||||||
} finally {
|
|
||||||
val size = scopes.size
|
|
||||||
assert(size >= sizeBefore)
|
|
||||||
repeat(size - sizeBefore) {
|
|
||||||
scopes.let { it.removeAt(it.size - 1) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected inline fun <T> withLocalScopeCleanup(crossinline l: () -> T): T {
|
protected inline fun <T> withLocalScopeCleanup(crossinline l: () -> T): T {
|
||||||
return context.withLocalScopesCleanup(l)
|
return context.withLocalScopesCleanup(l)
|
||||||
}
|
}
|
||||||
|
|||||||
+1
@@ -13,6 +13,7 @@ import org.jetbrains.kotlin.fir.resolve.ScopeSession
|
|||||||
import org.jetbrains.kotlin.fir.resolve.dfa.DataFlowAnalyzerContext
|
import org.jetbrains.kotlin.fir.resolve.dfa.DataFlowAnalyzerContext
|
||||||
import org.jetbrains.kotlin.fir.resolve.transformers.ReturnTypeCalculator
|
import org.jetbrains.kotlin.fir.resolve.transformers.ReturnTypeCalculator
|
||||||
import org.jetbrains.kotlin.fir.resolve.transformers.ReturnTypeCalculatorForFullBodyResolve
|
import org.jetbrains.kotlin.fir.resolve.transformers.ReturnTypeCalculatorForFullBodyResolve
|
||||||
|
import org.jetbrains.kotlin.fir.resolve.transformers.withScopeCleanup
|
||||||
import org.jetbrains.kotlin.fir.scopes.addImportingScopes
|
import org.jetbrains.kotlin.fir.scopes.addImportingScopes
|
||||||
import org.jetbrains.kotlin.fir.types.FirImplicitTypeRef
|
import org.jetbrains.kotlin.fir.types.FirImplicitTypeRef
|
||||||
import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef
|
import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef
|
||||||
|
|||||||
Reference in New Issue
Block a user