FIR: Optimize ConeTypeContext::asSimpleType
This commit is contained in:
@@ -71,6 +71,8 @@ sealed class ConeKotlinType : ConeKotlinTypeProjection(),
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sealed class ConeSimpleKotlinType : ConeKotlinType(), SimpleTypeMarker
|
||||||
|
|
||||||
interface ConeTypedProjection {
|
interface ConeTypedProjection {
|
||||||
val type: ConeKotlinType
|
val type: ConeKotlinType
|
||||||
}
|
}
|
||||||
@@ -94,7 +96,7 @@ class ConeClassErrorType(val reason: String) : ConeClassLikeType() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class ConeLookupTagBasedType : ConeKotlinType(), SimpleTypeMarker {
|
abstract class ConeLookupTagBasedType : ConeSimpleKotlinType() {
|
||||||
abstract val lookupTag: ConeClassifierLookupTag
|
abstract val lookupTag: ConeClassifierLookupTag
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,7 +152,7 @@ class ConeCapturedType(
|
|||||||
val lowerType: ConeKotlinType?,
|
val lowerType: ConeKotlinType?,
|
||||||
override val nullability: ConeNullability = ConeNullability.NOT_NULL,
|
override val nullability: ConeNullability = ConeNullability.NOT_NULL,
|
||||||
val constructor: ConeCapturedTypeConstructor
|
val constructor: ConeCapturedTypeConstructor
|
||||||
) : ConeKotlinType(), SimpleTypeMarker, CapturedTypeMarker {
|
) : ConeSimpleKotlinType(), CapturedTypeMarker {
|
||||||
constructor(captureStatus: CaptureStatus, lowerType: ConeKotlinType?, projection: ConeKotlinTypeProjection) : this(
|
constructor(captureStatus: CaptureStatus, lowerType: ConeKotlinType?, projection: ConeKotlinTypeProjection) : this(
|
||||||
captureStatus,
|
captureStatus,
|
||||||
lowerType,
|
lowerType,
|
||||||
@@ -170,7 +172,7 @@ class ConeTypeVariableType(
|
|||||||
override val typeArguments: Array<out ConeKotlinTypeProjection> get() = emptyArray()
|
override val typeArguments: Array<out ConeKotlinTypeProjection> get() = emptyArray()
|
||||||
}
|
}
|
||||||
|
|
||||||
class ConeDefinitelyNotNullType private constructor(val original: ConeKotlinType) : ConeKotlinType(), DefinitelyNotNullTypeMarker {
|
class ConeDefinitelyNotNullType private constructor(val original: ConeKotlinType) : ConeSimpleKotlinType(), DefinitelyNotNullTypeMarker {
|
||||||
override val typeArguments: Array<out ConeKotlinTypeProjection>
|
override val typeArguments: Array<out ConeKotlinTypeProjection>
|
||||||
get() = original.typeArguments
|
get() = original.typeArguments
|
||||||
override val nullability: ConeNullability
|
override val nullability: ConeNullability
|
||||||
@@ -194,7 +196,7 @@ class ConeRawType(lowerBound: ConeKotlinType, upperBound: ConeKotlinType) : Cone
|
|||||||
*/
|
*/
|
||||||
class ConeIntersectionType(
|
class ConeIntersectionType(
|
||||||
val intersectedTypes: Collection<ConeKotlinType>
|
val intersectedTypes: Collection<ConeKotlinType>
|
||||||
) : ConeKotlinType(), SimpleTypeMarker, TypeConstructorMarker {
|
) : ConeSimpleKotlinType(), TypeConstructorMarker {
|
||||||
override val typeArguments: Array<out ConeKotlinTypeProjection>
|
override val typeArguments: Array<out ConeKotlinTypeProjection>
|
||||||
get() = emptyArray()
|
get() = emptyArray()
|
||||||
|
|
||||||
@@ -206,7 +208,7 @@ fun ConeIntersectionType.mapTypes(func: (ConeKotlinType) -> ConeKotlinType): Con
|
|||||||
return ConeIntersectionType(intersectedTypes.map(func))
|
return ConeIntersectionType(intersectedTypes.map(func))
|
||||||
}
|
}
|
||||||
|
|
||||||
class ConeStubType(val variable: ConeTypeVariable, override val nullability: ConeNullability) : StubTypeMarker, ConeKotlinType() {
|
class ConeStubType(val variable: ConeTypeVariable, override val nullability: ConeNullability) : StubTypeMarker, ConeSimpleKotlinType() {
|
||||||
override val typeArguments: Array<out ConeKotlinTypeProjection>
|
override val typeArguments: Array<out ConeKotlinTypeProjection>
|
||||||
get() = emptyArray()
|
get() = emptyArray()
|
||||||
}
|
}
|
||||||
@@ -220,7 +222,7 @@ class ConeTypeVariableTypeConstructor(val debugName: String) : ConeClassifierLoo
|
|||||||
override val name: Name get() = Name.identifier(debugName)
|
override val name: Name get() = Name.identifier(debugName)
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class ConeIntegerLiteralType(val value: Long) : ConeKotlinType(), SimpleTypeMarker, TypeConstructorMarker {
|
abstract class ConeIntegerLiteralType(val value: Long) : ConeSimpleKotlinType(), TypeConstructorMarker {
|
||||||
abstract val possibleTypes: Collection<ConeClassLikeType>
|
abstract val possibleTypes: Collection<ConeClassLikeType>
|
||||||
abstract val supertypes: List<ConeClassLikeType>
|
abstract val supertypes: List<ConeClassLikeType>
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor
|
|||||||
import org.jetbrains.kotlin.fir.resolve.substitution.substitutorByMap
|
import org.jetbrains.kotlin.fir.resolve.substitution.substitutorByMap
|
||||||
import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.firUnsafe
|
import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.firUnsafe
|
||||||
import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol
|
import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.ConeTypeParameterLookupTag
|
||||||
import org.jetbrains.kotlin.fir.symbols.StandardClassIds
|
import org.jetbrains.kotlin.fir.symbols.StandardClassIds
|
||||||
import org.jetbrains.kotlin.fir.symbols.impl.*
|
import org.jetbrains.kotlin.fir.symbols.impl.*
|
||||||
import org.jetbrains.kotlin.fir.symbols.invoke
|
import org.jetbrains.kotlin.fir.symbols.invoke
|
||||||
@@ -62,13 +63,8 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty
|
|||||||
assert(this is ConeKotlinType)
|
assert(this is ConeKotlinType)
|
||||||
return when (this) {
|
return when (this) {
|
||||||
is ConeClassLikeType -> fullyExpandedType(session)
|
is ConeClassLikeType -> fullyExpandedType(session)
|
||||||
is ConeCapturedType -> this
|
is ConeSimpleKotlinType -> this
|
||||||
is ConeLookupTagBasedType -> this
|
|
||||||
is ConeDefinitelyNotNullType -> this
|
|
||||||
is ConeIntersectionType -> this
|
|
||||||
is ConeFlexibleType -> null
|
is ConeFlexibleType -> null
|
||||||
is ConeStubType -> this
|
|
||||||
is ConeIntegerLiteralType -> this
|
|
||||||
else -> error("Unknown simpleType: $this")
|
else -> error("Unknown simpleType: $this")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user