FIR type transformer: minor optimization: do not create empty scopes
This commit is contained in:
+14
-6
@@ -81,22 +81,30 @@ class FirTypeResolveTransformer(val superTypesOnly: Boolean = false) : FirTransf
|
|||||||
|
|
||||||
override fun transformTypeAlias(typeAlias: FirTypeAlias, data: Nothing?): CompositeTransformResult<FirDeclaration> {
|
override fun transformTypeAlias(typeAlias: FirTypeAlias, data: Nothing?): CompositeTransformResult<FirDeclaration> {
|
||||||
classLikeName = classLikeName.child(typeAlias.name)
|
classLikeName = classLikeName.child(typeAlias.name)
|
||||||
scope = FirCompositeScope(mutableListOf(scope))
|
if (typeAlias.typeParameters.isNotEmpty()) {
|
||||||
scope.scopes += FirClassLikeTypeParameterScope(typeAlias)
|
scope = FirCompositeScope(mutableListOf(scope))
|
||||||
|
scope.scopes += FirClassLikeTypeParameterScope(typeAlias)
|
||||||
|
}
|
||||||
|
|
||||||
resolveSuperTypesAndExpansions(typeAlias)
|
resolveSuperTypesAndExpansions(typeAlias)
|
||||||
|
|
||||||
scope = scope.scopes[0] as FirCompositeScope
|
if (typeAlias.typeParameters.isNotEmpty()) {
|
||||||
|
scope = scope.scopes[0] as FirCompositeScope
|
||||||
|
}
|
||||||
classLikeName = classLikeName.parent()
|
classLikeName = classLikeName.parent()
|
||||||
return super.transformTypeAlias(typeAlias, data)
|
return super.transformTypeAlias(typeAlias, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun transformNamedFunction(namedFunction: FirNamedFunction, data: Nothing?): CompositeTransformResult<FirDeclaration> {
|
override fun transformNamedFunction(namedFunction: FirNamedFunction, data: Nothing?): CompositeTransformResult<FirDeclaration> {
|
||||||
scope = FirCompositeScope(mutableListOf(scope))
|
if (namedFunction.typeParameters.isNotEmpty()) {
|
||||||
scope.scopes += FirFunctionTypeParameterScope(namedFunction)
|
scope = FirCompositeScope(mutableListOf(scope))
|
||||||
|
scope.scopes += FirFunctionTypeParameterScope(namedFunction)
|
||||||
|
}
|
||||||
|
|
||||||
val result = super.transformNamedFunction(namedFunction, data)
|
val result = super.transformNamedFunction(namedFunction, data)
|
||||||
scope = scope.scopes[0] as FirCompositeScope
|
if (namedFunction.typeParameters.isNotEmpty()) {
|
||||||
|
scope = scope.scopes[0] as FirCompositeScope
|
||||||
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user