[FIR] ScopeClassDeclaration: introduce new property to avoid container clash

^KTIJ-23547
^KTIJ-24141
This commit is contained in:
Dmitrii Gridin
2023-01-18 00:27:31 +01:00
committed by Space Team
parent 6635ec33d9
commit 0420be603f
4 changed files with 13 additions and 8 deletions
@@ -224,6 +224,7 @@ class FirTypeResolverImpl(private val session: FirSession) : FirTypeResolver() {
result: TypeResolutionResult, result: TypeResolutionResult,
areBareTypesAllowed: Boolean, areBareTypesAllowed: Boolean,
topContainer: FirDeclaration?, topContainer: FirDeclaration?,
containerDeclaration: FirDeclaration?,
isOperandOfIsOperator: Boolean isOperandOfIsOperator: Boolean
): ConeKotlinType { ): ConeKotlinType {
@@ -362,7 +363,7 @@ class FirTypeResolverImpl(private val session: FirSession) : FirTypeResolver() {
return symbol.constructType( return symbol.constructType(
resultingArguments, resultingArguments,
typeRef.isMarkedNullable, typeRef.isMarkedNullable,
typeRef.annotations.computeTypeAttributes(session, containerDeclaration = topContainer) typeRef.annotations.computeTypeAttributes(session, containerDeclaration = containerDeclaration)
).also { ).also {
val lookupTag = it.lookupTag val lookupTag = it.lookupTag
if (lookupTag is ConeClassLikeLookupTagImpl && symbol is FirClassLikeSymbol<*>) { if (lookupTag is ConeClassLikeLookupTagImpl && symbol is FirClassLikeSymbol<*>) {
@@ -525,7 +526,8 @@ class FirTypeResolverImpl(private val session: FirSession) : FirTypeResolver() {
result, result,
areBareTypesAllowed, areBareTypesAllowed,
scopeClassDeclaration.topContainer ?: scopeClassDeclaration.containingDeclarations.lastOrNull(), scopeClassDeclaration.topContainer ?: scopeClassDeclaration.containingDeclarations.lastOrNull(),
isOperandOfIsOperator scopeClassDeclaration.containerDeclaration,
isOperandOfIsOperator,
) to (result as? TypeResolutionResult.Resolved)?.typeCandidate?.diagnostic ) to (result as? TypeResolutionResult.Resolved)?.typeCandidate?.diagnostic
} }
is FirFunctionTypeRef -> createFunctionalType(typeRef) to null is FirFunctionTypeRef -> createFunctionalType(typeRef) to null
@@ -25,7 +25,9 @@ import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeTypeParameterSupertype
import org.jetbrains.kotlin.fir.resolve.providers.firProvider import org.jetbrains.kotlin.fir.resolve.providers.firProvider
import org.jetbrains.kotlin.fir.resolve.providers.symbolProvider import org.jetbrains.kotlin.fir.resolve.providers.symbolProvider
import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.LocalClassesNavigationInfo import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.LocalClassesNavigationInfo
import org.jetbrains.kotlin.fir.scopes.* import org.jetbrains.kotlin.fir.scopes.FirScope
import org.jetbrains.kotlin.fir.scopes.createImportingScopes
import org.jetbrains.kotlin.fir.scopes.getNestedClassifierScope
import org.jetbrains.kotlin.fir.scopes.impl.FirMemberTypeParameterScope import org.jetbrains.kotlin.fir.scopes.impl.FirMemberTypeParameterScope
import org.jetbrains.kotlin.fir.scopes.impl.nestedClassifierScope import org.jetbrains.kotlin.fir.scopes.impl.nestedClassifierScope
import org.jetbrains.kotlin.fir.scopes.impl.wrapNestedClassifierScopeWithSubstitutionForSuperType import org.jetbrains.kotlin.fir.scopes.impl.wrapNestedClassifierScopeWithSubstitutionForSuperType
@@ -361,7 +363,7 @@ open class FirSupertypeResolverVisitor(
val resolvedTypesRefs = transformer.withFile(useSiteFile) { val resolvedTypesRefs = transformer.withFile(useSiteFile) {
resolveSuperTypeRefs( resolveSuperTypeRefs(
transformer, transformer,
ScopeClassDeclaration(scopes, classDeclarationsStack, classLikeDeclaration), ScopeClassDeclaration(scopes, classDeclarationsStack, containerDeclaration = classLikeDeclaration),
) )
} }
@@ -228,7 +228,7 @@ open class FirTypeResolveTransformer(
return typeResolverTransformer.withFile(currentFile) { return typeResolverTransformer.withFile(currentFile) {
typeRef.transform( typeRef.transform(
typeResolverTransformer, typeResolverTransformer,
ScopeClassDeclaration(towerScope, classDeclarationsStack, currentDeclaration) ScopeClassDeclaration(towerScope, classDeclarationsStack, containerDeclaration = currentDeclaration)
) )
} }
} }
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/ */
@@ -11,5 +11,6 @@ import org.jetbrains.kotlin.fir.scopes.FirScope
data class ScopeClassDeclaration( data class ScopeClassDeclaration(
val scopes: List<FirScope>, val scopes: List<FirScope>,
val containingDeclarations: List<FirDeclaration>, val containingDeclarations: List<FirDeclaration>,
val topContainer: FirDeclaration? = null val topContainer: FirDeclaration? = null,
val containerDeclaration: FirDeclaration? = null,
) )