[FIR] Eliminate ClassId.isSame call from FirClass.isSubclassOf
^KT-55664 Fixed
This commit is contained in:
committed by
Space Team
parent
6c24436657
commit
e232cc92f9
@@ -375,7 +375,7 @@ abstract class FirVisibilityChecker : FirSessionComponent {
|
|||||||
for (declaration in containingDeclarationOfUseSite) {
|
for (declaration in containingDeclarationOfUseSite) {
|
||||||
if (declaration !is FirClass) continue
|
if (declaration !is FirClass) continue
|
||||||
val boundSymbol = declaration.symbol
|
val boundSymbol = declaration.symbol
|
||||||
if (boundSymbol.classId.isSame(ownerLookupTag.classId)) {
|
if (boundSymbol.toLookupTag() == ownerLookupTag) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ package org.jetbrains.kotlin.fir.resolve
|
|||||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||||
import org.jetbrains.kotlin.fir.FirSession
|
import org.jetbrains.kotlin.fir.FirSession
|
||||||
import org.jetbrains.kotlin.fir.declarations.*
|
import org.jetbrains.kotlin.fir.declarations.*
|
||||||
import org.jetbrains.kotlin.fir.declarations.utils.classId
|
|
||||||
import org.jetbrains.kotlin.fir.declarations.utils.expandedConeType
|
import org.jetbrains.kotlin.fir.declarations.utils.expandedConeType
|
||||||
import org.jetbrains.kotlin.fir.declarations.utils.isLocal
|
import org.jetbrains.kotlin.fir.declarations.utils.isLocal
|
||||||
import org.jetbrains.kotlin.fir.declarations.utils.superConeTypes
|
import org.jetbrains.kotlin.fir.declarations.utils.superConeTypes
|
||||||
@@ -109,7 +108,7 @@ fun FirClass.isSubclassOf(
|
|||||||
supertypeSupplier: SupertypeSupplier = SupertypeSupplier.Default,
|
supertypeSupplier: SupertypeSupplier = SupertypeSupplier.Default,
|
||||||
lookupInterfaces: Boolean = true,
|
lookupInterfaces: Boolean = true,
|
||||||
): Boolean {
|
): Boolean {
|
||||||
if (classId.isSame(ownerLookupTag.classId)) {
|
if (symbol.toLookupTag() == ownerLookupTag) {
|
||||||
return !isStrict
|
return !isStrict
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,15 +120,11 @@ fun FirClass.isSubclassOf(
|
|||||||
substituteTypes = false,
|
substituteTypes = false,
|
||||||
supertypeSupplier
|
supertypeSupplier
|
||||||
).any { superType ->
|
).any { superType ->
|
||||||
// Note: We check just classId here, so type substitution isn't needed
|
// Note: We just check lookupTag here, so type substitution isn't needed
|
||||||
superType.lookupTag.classId.isSame(ownerLookupTag.classId)
|
superType.lookupTag == ownerLookupTag
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 'local' isn't taken into account here
|
|
||||||
fun ClassId.isSame(other: ClassId): Boolean =
|
|
||||||
packageFqName == other.packageFqName && relativeClassName == other.relativeClassName
|
|
||||||
|
|
||||||
fun FirClass.isThereLoopInSupertypes(session: FirSession): Boolean {
|
fun FirClass.isThereLoopInSupertypes(session: FirSession): Boolean {
|
||||||
val visitedSymbols: MutableSet<FirClassifierSymbol<*>> = SmartSet.create()
|
val visitedSymbols: MutableSet<FirClassifierSymbol<*>> = SmartSet.create()
|
||||||
val inProcess: MutableSet<FirClassifierSymbol<*>> = mutableSetOf()
|
val inProcess: MutableSet<FirClassifierSymbol<*>> = mutableSetOf()
|
||||||
|
|||||||
Reference in New Issue
Block a user