[FIR] Use SupertypeSupplier in type resolver for calculating supertypes
This is needed to avoid problems with checking visibility of types which are used in supertypes during supertypes resolution in IDE, when supertypes of some class can be already computed, but not saved in class itself, but still lay in supertypeComputationSession There were 4 failing tests before this changes (all in `DiagnosisCompilerTestFE10TestdataTestGenerated$Tests$Exposed`): - testInternal - testInternalAndProtected - testProtected - testProtectedSameWay
This commit is contained in:
committed by
TeamCityServer
parent
499b97d51e
commit
e7c9d76163
@@ -18,7 +18,8 @@ abstract class FirTypeResolver : FirSessionComponent {
|
||||
scopeClassDeclaration: ScopeClassDeclaration,
|
||||
areBareTypesAllowed: Boolean,
|
||||
isOperandOfIsOperator: Boolean,
|
||||
useSiteFile: FirFile?
|
||||
useSiteFile: FirFile?,
|
||||
supertypeSupplier: SupertypeSupplier
|
||||
): ConeKotlinType
|
||||
}
|
||||
|
||||
|
||||
+8
-4
@@ -78,6 +78,7 @@ class FirTypeResolverImpl(private val session: FirSession) : FirTypeResolver() {
|
||||
private fun FirBasedSymbol<*>?.isVisible(
|
||||
useSiteFile: FirFile?,
|
||||
containingDeclarations: List<FirDeclaration>,
|
||||
supertypeSupplier: SupertypeSupplier
|
||||
): Boolean {
|
||||
val declaration = this?.fir
|
||||
return if (useSiteFile != null && declaration is FirMemberDeclaration) {
|
||||
@@ -86,8 +87,9 @@ class FirTypeResolverImpl(private val session: FirSession) : FirTypeResolver() {
|
||||
session,
|
||||
useSiteFile,
|
||||
containingDeclarations,
|
||||
null,
|
||||
false,
|
||||
dispatchReceiver = null,
|
||||
isCallToPropertySetter = false,
|
||||
supertypeSupplier = supertypeSupplier
|
||||
)
|
||||
} else {
|
||||
true
|
||||
@@ -98,6 +100,7 @@ class FirTypeResolverImpl(private val session: FirSession) : FirTypeResolver() {
|
||||
typeRef: FirTypeRef,
|
||||
scopeClassDeclaration: ScopeClassDeclaration,
|
||||
useSiteFile: FirFile?,
|
||||
supertypeSupplier: SupertypeSupplier
|
||||
): Pair<FirBasedSymbol<*>?, ConeSubstitutor?> {
|
||||
return when (typeRef) {
|
||||
is FirResolvedTypeRef -> {
|
||||
@@ -125,7 +128,7 @@ class FirTypeResolverImpl(private val session: FirSession) : FirTypeResolver() {
|
||||
|
||||
val resolvedSymbol = resolveSymbol(symbol, qualifier, qualifierResolver)
|
||||
|
||||
if (resolvedSymbol.isVisible(useSiteFile, containingDeclarations)) {
|
||||
if (resolvedSymbol.isVisible(useSiteFile, containingDeclarations, supertypeSupplier)) {
|
||||
acceptedSymbol = resolvedSymbol
|
||||
substitutor = substitutorFromScope
|
||||
} else {
|
||||
@@ -451,11 +454,12 @@ class FirTypeResolverImpl(private val session: FirSession) : FirTypeResolver() {
|
||||
areBareTypesAllowed: Boolean,
|
||||
isOperandOfIsOperator: Boolean,
|
||||
useSiteFile: FirFile?,
|
||||
supertypeSupplier: SupertypeSupplier
|
||||
): ConeKotlinType {
|
||||
return when (typeRef) {
|
||||
is FirResolvedTypeRef -> typeRef.type
|
||||
is FirUserTypeRef -> {
|
||||
val (symbol, substitutor) = resolveToSymbol(typeRef, scopeClassDeclaration, useSiteFile)
|
||||
val (symbol, substitutor) = resolveToSymbol(typeRef, scopeClassDeclaration, useSiteFile, supertypeSupplier)
|
||||
resolveUserType(
|
||||
typeRef,
|
||||
symbol,
|
||||
|
||||
+5
-1
@@ -13,6 +13,7 @@ import org.jetbrains.kotlin.fir.declarations.FirFile
|
||||
import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
|
||||
import org.jetbrains.kotlin.fir.diagnostics.ConeSimpleDiagnostic
|
||||
import org.jetbrains.kotlin.fir.diagnostics.ConeUnexpectedTypeArgumentsError
|
||||
import org.jetbrains.kotlin.fir.resolve.SupertypeSupplier
|
||||
import org.jetbrains.kotlin.fir.resolve.typeResolver
|
||||
import org.jetbrains.kotlin.fir.types.*
|
||||
import org.jetbrains.kotlin.fir.types.builder.buildErrorTypeRef
|
||||
@@ -21,7 +22,8 @@ import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||
|
||||
class FirSpecificTypeResolverTransformer(
|
||||
override val session: FirSession,
|
||||
private val errorTypeAsResolved: Boolean = true
|
||||
private val errorTypeAsResolved: Boolean = true,
|
||||
private val supertypeSupplier: SupertypeSupplier = SupertypeSupplier.Default
|
||||
) : FirAbstractTreeTransformer<ScopeClassDeclaration>(phase = FirResolvePhase.SUPER_TYPES) {
|
||||
private val typeResolver = session.typeResolver
|
||||
|
||||
@@ -83,6 +85,7 @@ class FirSpecificTypeResolverTransformer(
|
||||
areBareTypesAllowed,
|
||||
isOperandOfIsOperator,
|
||||
currentFile,
|
||||
supertypeSupplier
|
||||
)
|
||||
)
|
||||
}
|
||||
@@ -101,6 +104,7 @@ class FirSpecificTypeResolverTransformer(
|
||||
areBareTypesAllowed,
|
||||
isOperandOfIsOperator,
|
||||
currentFile,
|
||||
supertypeSupplier
|
||||
).takeIfAcceptable()
|
||||
return if (resolvedType != null && resolvedType !is ConeClassErrorType) {
|
||||
buildResolvedTypeRef {
|
||||
|
||||
+1
-1
@@ -344,7 +344,7 @@ open class FirSupertypeResolverVisitor(
|
||||
supertypeComputationSession.startComputingSupertypes(classLikeDeclaration)
|
||||
val scopes = prepareScopes(classLikeDeclaration)
|
||||
|
||||
val transformer = FirSpecificTypeResolverTransformer(session)
|
||||
val transformer = FirSpecificTypeResolverTransformer(session, supertypeSupplier = supertypeComputationSession.supertypesSupplier)
|
||||
val resolvedTypesRefs = transformer.withFile(useSiteFile) {
|
||||
resolveSuperTypeRefs(
|
||||
transformer,
|
||||
|
||||
Reference in New Issue
Block a user