[FIR] Replace usages of FirExpression.typeRef with coneTypeOrNull
#KT-59855 Fixed
This commit is contained in:
committed by
Space Team
parent
f60d81097c
commit
8d7c5b375e
@@ -37,25 +37,25 @@ fun FirLookupTrackerComponent.recordTypeLookup(typeRef: FirTypeRef, inScopes: Li
|
||||
|
||||
fun FirLookupTrackerComponent.recordTypeResolveAsLookup(typeRef: FirTypeRef, source: KtSourceElement?, fileSource: KtSourceElement?) {
|
||||
if (typeRef !is FirResolvedTypeRef) return // TODO: check if this is the correct behavior
|
||||
if (source == null && fileSource == null) return // TODO: investigate all cases
|
||||
recordTypeResolveAsLookup(typeRef.type, source, fileSource)
|
||||
}
|
||||
|
||||
fun recordIfValid(type: ConeKotlinType) {
|
||||
if (type is ConeErrorType) return // TODO: investigate whether some cases should be recorded, e.g. unresolved
|
||||
type.classId?.let {
|
||||
if (!it.isLocal) {
|
||||
if (it.shortClassName.asString() != "Companion") {
|
||||
recordLookup(it.shortClassName, it.packageFqName.asString(), source, fileSource)
|
||||
} else {
|
||||
recordLookup(it.outerClassId!!.shortClassName, it.outerClassId!!.packageFqName.asString(), source, fileSource)
|
||||
}
|
||||
fun FirLookupTrackerComponent.recordTypeResolveAsLookup(type: ConeKotlinType?, source: KtSourceElement?, fileSource: KtSourceElement?) {
|
||||
if (type == null) return
|
||||
if (source == null && fileSource == null) return // TODO: investigate all cases
|
||||
if (type is ConeErrorType) return // TODO: investigate whether some cases should be recorded, e.g. unresolved
|
||||
type.classId?.let {
|
||||
if (!it.isLocal) {
|
||||
if (it.shortClassName.asString() != "Companion") {
|
||||
recordLookup(it.shortClassName, it.packageFqName.asString(), source, fileSource)
|
||||
} else {
|
||||
recordLookup(it.outerClassId!!.shortClassName, it.outerClassId!!.packageFqName.asString(), source, fileSource)
|
||||
}
|
||||
}
|
||||
type.typeArguments.forEach {
|
||||
if (it is ConeKotlinType) recordIfValid(it)
|
||||
}
|
||||
}
|
||||
|
||||
recordIfValid(typeRef.type)
|
||||
type.typeArguments.forEach {
|
||||
if (it is ConeKotlinType) recordTypeResolveAsLookup(it, source, fileSource)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -16,13 +16,13 @@ import org.jetbrains.kotlin.fir.resolve.dfa.FlowPath
|
||||
import org.jetbrains.kotlin.fir.resolve.dfa.PersistentFlow
|
||||
import org.jetbrains.kotlin.fir.resolve.dfa.controlFlowGraph
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol
|
||||
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
||||
import org.jetbrains.kotlin.fir.types.UnexpandedTypeCheck
|
||||
import org.jetbrains.kotlin.fir.types.ConeKotlinType
|
||||
import org.jetbrains.kotlin.fir.types.coneType
|
||||
import org.jetbrains.kotlin.fir.types.impl.FirImplicitNothingTypeRef
|
||||
import org.jetbrains.kotlin.fir.types.constructClassLikeType
|
||||
import org.jetbrains.kotlin.fir.types.isNothing
|
||||
import org.jetbrains.kotlin.fir.visitors.FirTransformer
|
||||
import org.jetbrains.kotlin.fir.visitors.FirVisitor
|
||||
import org.jetbrains.kotlin.name.StandardClassIds
|
||||
import org.jetbrains.kotlin.utils.SmartList
|
||||
|
||||
@RequiresOptIn
|
||||
@@ -869,16 +869,14 @@ class WhenSubjectExpressionExitNode(owner: ControlFlowGraph, override val fir: F
|
||||
|
||||
object FirStub : FirExpression() {
|
||||
override val source: KtSourceElement? get() = null
|
||||
override val typeRef: FirTypeRef = FirImplicitNothingTypeRef(null)
|
||||
override val coneTypeOrNull: ConeKotlinType = StandardClassIds.Nothing.constructClassLikeType()
|
||||
override val annotations: List<FirAnnotation> get() = listOf()
|
||||
|
||||
override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {}
|
||||
override fun <D> transformAnnotations(transformer: FirTransformer<D>, data: D): FirExpression = this
|
||||
override fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirElement = this
|
||||
override fun replaceAnnotations(newAnnotations: List<FirAnnotation>) { assert(newAnnotations.isEmpty()) }
|
||||
|
||||
@OptIn(UnexpandedTypeCheck::class)
|
||||
override fun replaceTypeRef(newTypeRef: FirTypeRef) { assert(newTypeRef.isNothing) }
|
||||
override fun replaceConeTypeOrNull(newConeTypeOrNull: ConeKotlinType?) { assert(newConeTypeOrNull?.isNothing == true) }
|
||||
}
|
||||
|
||||
class FakeExpressionEnterNode(owner: ControlFlowGraph, level: Int) : CFGNode<FirStub>(owner, level), GraphEnterNodeMarker, GraphExitNodeMarker {
|
||||
|
||||
Reference in New Issue
Block a user