[FIR] Don't call inline lambda twice in withFullBodyResolve

This commit is contained in:
Dmitriy Novozhilov
2020-09-15 16:27:04 +03:00
parent f9de2621b2
commit 748049daa3
2 changed files with 18 additions and 13 deletions
@@ -59,12 +59,16 @@ abstract class FirAbstractBodyResolveTransformer(phase: FirResolvePhase) : FirAb
@OptIn(PrivateForInline::class) @OptIn(PrivateForInline::class)
internal inline fun <T> withFullBodyResolve(crossinline l: () -> T): T { internal inline fun <T> withFullBodyResolve(crossinline l: () -> T): T {
if (!implicitTypeOnly) return l() val shouldSwitchMode = implicitTypeOnly
implicitTypeOnly = false if (shouldSwitchMode) {
implicitTypeOnly = false
}
return try { return try {
l() l()
} finally { } finally {
implicitTypeOnly = true if (shouldSwitchMode) {
implicitTypeOnly = true
}
} }
} }
@@ -91,10 +91,9 @@ open class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransfor
} }
protected inline fun <T> withTypeParametersOf(declaration: FirMemberDeclaration, crossinline l: () -> T): T { protected inline fun <T> withTypeParametersOf(declaration: FirMemberDeclaration, crossinline l: () -> T): T {
val scope = createTypeParameterScope(declaration) ?: return l() val scope = createTypeParameterScope(declaration)
return context.withTowerDataCleanup { return context.withTowerDataCleanup {
context.addNonLocalTowerDataElement(scope.asTowerDataElement(isLocal = false)) scope?.let { context.addNonLocalTowerDataElement(it.asTowerDataElement(isLocal = false)) }
l() l()
} }
} }
@@ -111,14 +110,16 @@ open class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransfor
} }
return property.compose() return property.compose()
} }
if (property.isLocal) {
prepareSignatureForBodyResolve(property)
property.transformStatus(this, property.resolveStatus(property.status).mode())
property.getter?.let { it.transformStatus(this, it.resolveStatus(it.status).mode()) }
property.setter?.let { it.transformStatus(this, it.resolveStatus(it.status).mode()) }
return transformLocalVariable(property)
}
return withTypeParametersOf(property) { return withTypeParametersOf(property) {
if (property.isLocal) {
prepareSignatureForBodyResolve(property)
property.transformStatus(this, property.resolveStatus(property.status).mode())
property.getter?.let { it.transformStatus(this, it.resolveStatus(it.status).mode()) }
property.setter?.let { it.transformStatus(this, it.resolveStatus(it.status).mode()) }
return@withTypeParametersOf transformLocalVariable(property)
}
val returnTypeRef = property.returnTypeRef val returnTypeRef = property.returnTypeRef
if (returnTypeRef !is FirImplicitTypeRef && implicitTypeOnly) return@withTypeParametersOf property.compose() if (returnTypeRef !is FirImplicitTypeRef && implicitTypeOnly) return@withTypeParametersOf property.compose()
if (property.resolvePhase == transformerPhase) return@withTypeParametersOf property.compose() if (property.resolvePhase == transformerPhase) return@withTypeParametersOf property.compose()