[FIR] Eliminate ClassId.isSame call from FirClass.isSubclassOf

^KT-55664 Fixed
This commit is contained in:
Kirill Rakhman
2023-02-06 11:07:14 +01:00
committed by Space Team
parent 6c24436657
commit e232cc92f9
2 changed files with 4 additions and 9 deletions
@@ -375,7 +375,7 @@ abstract class FirVisibilityChecker : FirSessionComponent {
for (declaration in containingDeclarationOfUseSite) {
if (declaration !is FirClass) continue
val boundSymbol = declaration.symbol
if (boundSymbol.classId.isSame(ownerLookupTag.classId)) {
if (boundSymbol.toLookupTag() == ownerLookupTag) {
return true
}
}
@@ -8,7 +8,6 @@ package org.jetbrains.kotlin.fir.resolve
import org.jetbrains.kotlin.descriptors.ClassKind
import org.jetbrains.kotlin.fir.FirSession
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.isLocal
import org.jetbrains.kotlin.fir.declarations.utils.superConeTypes
@@ -109,7 +108,7 @@ fun FirClass.isSubclassOf(
supertypeSupplier: SupertypeSupplier = SupertypeSupplier.Default,
lookupInterfaces: Boolean = true,
): Boolean {
if (classId.isSame(ownerLookupTag.classId)) {
if (symbol.toLookupTag() == ownerLookupTag) {
return !isStrict
}
@@ -121,15 +120,11 @@ fun FirClass.isSubclassOf(
substituteTypes = false,
supertypeSupplier
).any { superType ->
// Note: We check just classId here, so type substitution isn't needed
superType.lookupTag.classId.isSame(ownerLookupTag.classId)
// Note: We just check lookupTag here, so type substitution isn't needed
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 {
val visitedSymbols: MutableSet<FirClassifierSymbol<*>> = SmartSet.create()
val inProcess: MutableSet<FirClassifierSymbol<*>> = mutableSetOf()