[FIR] Reorganize ConeKotlinTypeProjection hierarchy
This commit is contained in:
@@ -25,27 +25,25 @@ enum class ProjectionKind {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sealed class ConeKotlinTypeProjection : TypeArgumentMarker {
|
sealed class ConeTypeProjection : TypeArgumentMarker {
|
||||||
abstract val kind: ProjectionKind
|
abstract val kind: ProjectionKind
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val EMPTY_ARRAY = arrayOf<ConeKotlinTypeProjection>()
|
val EMPTY_ARRAY = arrayOf<ConeTypeProjection>()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
object ConeStarProjection : ConeKotlinTypeProjection() {
|
object ConeStarProjection : ConeTypeProjection() {
|
||||||
override val kind: ProjectionKind
|
override val kind: ProjectionKind
|
||||||
get() = ProjectionKind.STAR
|
get() = ProjectionKind.STAR
|
||||||
}
|
}
|
||||||
|
|
||||||
data class ConeKotlinTypeProjectionIn(override val type: ConeKotlinType) : ConeKotlinTypeProjection(),
|
data class ConeKotlinTypeProjectionIn(override val type: ConeKotlinType) : ConeKotlinTypeProjection() {
|
||||||
ConeTypedProjection {
|
|
||||||
override val kind: ProjectionKind
|
override val kind: ProjectionKind
|
||||||
get() = ProjectionKind.IN
|
get() = ProjectionKind.IN
|
||||||
}
|
}
|
||||||
|
|
||||||
data class ConeKotlinTypeProjectionOut(override val type: ConeKotlinType) : ConeKotlinTypeProjection(),
|
data class ConeKotlinTypeProjectionOut(override val type: ConeKotlinType) : ConeKotlinTypeProjection() {
|
||||||
ConeTypedProjection {
|
|
||||||
override val kind: ProjectionKind
|
override val kind: ProjectionKind
|
||||||
get() = ProjectionKind.OUT
|
get() = ProjectionKind.OUT
|
||||||
}
|
}
|
||||||
@@ -53,13 +51,12 @@ data class ConeKotlinTypeProjectionOut(override val type: ConeKotlinType) : Cone
|
|||||||
// We assume type IS an invariant type projection to prevent additional wrapper here
|
// We assume type IS an invariant type projection to prevent additional wrapper here
|
||||||
// (more exactly, invariant type projection contains type)
|
// (more exactly, invariant type projection contains type)
|
||||||
sealed class ConeKotlinType : ConeKotlinTypeProjection(),
|
sealed class ConeKotlinType : ConeKotlinTypeProjection(),
|
||||||
ConeTypedProjection,
|
|
||||||
KotlinTypeMarker,
|
KotlinTypeMarker,
|
||||||
TypeArgumentListMarker {
|
TypeArgumentListMarker {
|
||||||
override val kind: ProjectionKind
|
override val kind: ProjectionKind
|
||||||
get() = ProjectionKind.INVARIANT
|
get() = ProjectionKind.INVARIANT
|
||||||
|
|
||||||
abstract val typeArguments: Array<out ConeKotlinTypeProjection>
|
abstract val typeArguments: Array<out ConeTypeProjection>
|
||||||
|
|
||||||
override val type: ConeKotlinType
|
override val type: ConeKotlinType
|
||||||
get() = this
|
get() = this
|
||||||
@@ -73,8 +70,8 @@ sealed class ConeKotlinType : ConeKotlinTypeProjection(),
|
|||||||
|
|
||||||
sealed class ConeSimpleKotlinType : ConeKotlinType(), SimpleTypeMarker
|
sealed class ConeSimpleKotlinType : ConeKotlinType(), SimpleTypeMarker
|
||||||
|
|
||||||
interface ConeTypedProjection {
|
sealed class ConeKotlinTypeProjection : ConeTypeProjection() {
|
||||||
val type: ConeKotlinType
|
abstract val type: ConeKotlinType
|
||||||
}
|
}
|
||||||
|
|
||||||
typealias ConeKotlinErrorType = ConeClassErrorType
|
typealias ConeKotlinErrorType = ConeClassErrorType
|
||||||
@@ -85,7 +82,7 @@ class ConeClassErrorType(val reason: String) : ConeClassLikeType() {
|
|||||||
override val lookupTag: ConeClassLikeLookupTag
|
override val lookupTag: ConeClassLikeLookupTag
|
||||||
get() = ConeClassLikeErrorLookupTag(ClassId.fromString("<error>"))
|
get() = ConeClassLikeErrorLookupTag(ClassId.fromString("<error>"))
|
||||||
|
|
||||||
override val typeArguments: Array<out ConeKotlinTypeProjection>
|
override val typeArguments: Array<out ConeTypeProjection>
|
||||||
get() = EMPTY_ARRAY
|
get() = EMPTY_ARRAY
|
||||||
|
|
||||||
override val nullability: ConeNullability
|
override val nullability: ConeNullability
|
||||||
@@ -109,7 +106,7 @@ open class ConeFlexibleType(val lowerBound: ConeKotlinType, val upperBound: Cone
|
|||||||
require(upperBound is SimpleTypeMarker, message)
|
require(upperBound is SimpleTypeMarker, message)
|
||||||
}
|
}
|
||||||
|
|
||||||
override val typeArguments: Array<out ConeKotlinTypeProjection>
|
override val typeArguments: Array<out ConeTypeProjection>
|
||||||
get() = emptyArray()
|
get() = emptyArray()
|
||||||
|
|
||||||
override val nullability: ConeNullability
|
override val nullability: ConeNullability
|
||||||
@@ -139,7 +136,7 @@ fun ConeKotlinType.upperBoundIfFlexible() = (this as? ConeFlexibleType)?.upperBo
|
|||||||
fun ConeKotlinType.lowerBoundIfFlexible() = (this as? ConeFlexibleType)?.lowerBound ?: this
|
fun ConeKotlinType.lowerBoundIfFlexible() = (this as? ConeFlexibleType)?.lowerBound ?: this
|
||||||
|
|
||||||
class ConeCapturedTypeConstructor(
|
class ConeCapturedTypeConstructor(
|
||||||
val projection: ConeKotlinTypeProjection,
|
val projection: ConeTypeProjection,
|
||||||
var supertypes: List<ConeKotlinType>? = null,
|
var supertypes: List<ConeKotlinType>? = null,
|
||||||
val typeParameterMarker: TypeParameterMarker? = null
|
val typeParameterMarker: TypeParameterMarker? = null
|
||||||
) : CapturedTypeConstructorMarker
|
) : CapturedTypeConstructorMarker
|
||||||
@@ -151,7 +148,7 @@ class ConeCapturedType(
|
|||||||
val constructor: ConeCapturedTypeConstructor
|
val constructor: ConeCapturedTypeConstructor
|
||||||
) : ConeSimpleKotlinType(), CapturedTypeMarker {
|
) : ConeSimpleKotlinType(), CapturedTypeMarker {
|
||||||
constructor(
|
constructor(
|
||||||
captureStatus: CaptureStatus, lowerType: ConeKotlinType?, projection: ConeKotlinTypeProjection,
|
captureStatus: CaptureStatus, lowerType: ConeKotlinType?, projection: ConeTypeProjection,
|
||||||
typeParameterMarker: TypeParameterMarker
|
typeParameterMarker: TypeParameterMarker
|
||||||
) : this(
|
) : this(
|
||||||
captureStatus,
|
captureStatus,
|
||||||
@@ -162,7 +159,7 @@ class ConeCapturedType(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
override val typeArguments: Array<out ConeKotlinTypeProjection>
|
override val typeArguments: Array<out ConeTypeProjection>
|
||||||
get() = emptyArray()
|
get() = emptyArray()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,11 +167,11 @@ data class ConeTypeVariableType(
|
|||||||
override val nullability: ConeNullability,
|
override val nullability: ConeNullability,
|
||||||
override val lookupTag: ConeClassifierLookupTag
|
override val lookupTag: ConeClassifierLookupTag
|
||||||
) : ConeLookupTagBasedType() {
|
) : ConeLookupTagBasedType() {
|
||||||
override val typeArguments: Array<out ConeKotlinTypeProjection> get() = emptyArray()
|
override val typeArguments: Array<out ConeTypeProjection> get() = emptyArray()
|
||||||
}
|
}
|
||||||
|
|
||||||
data class ConeDefinitelyNotNullType(val original: ConeKotlinType) : ConeSimpleKotlinType(), DefinitelyNotNullTypeMarker {
|
data class ConeDefinitelyNotNullType(val original: ConeKotlinType) : ConeSimpleKotlinType(), DefinitelyNotNullTypeMarker {
|
||||||
override val typeArguments: Array<out ConeKotlinTypeProjection>
|
override val typeArguments: Array<out ConeTypeProjection>
|
||||||
get() = original.typeArguments
|
get() = original.typeArguments
|
||||||
override val nullability: ConeNullability
|
override val nullability: ConeNullability
|
||||||
get() = ConeNullability.NOT_NULL
|
get() = ConeNullability.NOT_NULL
|
||||||
@@ -193,7 +190,7 @@ class ConeRawType(lowerBound: ConeKotlinType, upperBound: ConeKotlinType) : Cone
|
|||||||
class ConeIntersectionType(
|
class ConeIntersectionType(
|
||||||
val intersectedTypes: Collection<ConeKotlinType>
|
val intersectedTypes: Collection<ConeKotlinType>
|
||||||
) : ConeSimpleKotlinType(), TypeConstructorMarker {
|
) : ConeSimpleKotlinType(), TypeConstructorMarker {
|
||||||
override val typeArguments: Array<out ConeKotlinTypeProjection>
|
override val typeArguments: Array<out ConeTypeProjection>
|
||||||
get() = emptyArray()
|
get() = emptyArray()
|
||||||
|
|
||||||
override val nullability: ConeNullability
|
override val nullability: ConeNullability
|
||||||
@@ -205,7 +202,7 @@ fun ConeIntersectionType.mapTypes(func: (ConeKotlinType) -> ConeKotlinType): Con
|
|||||||
}
|
}
|
||||||
|
|
||||||
class ConeStubType(val variable: ConeTypeVariable, override val nullability: ConeNullability) : StubTypeMarker, ConeSimpleKotlinType() {
|
class ConeStubType(val variable: ConeTypeVariable, override val nullability: ConeNullability) : StubTypeMarker, ConeSimpleKotlinType() {
|
||||||
override val typeArguments: Array<out ConeKotlinTypeProjection>
|
override val typeArguments: Array<out ConeTypeProjection>
|
||||||
get() = emptyArray()
|
get() = emptyArray()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -226,7 +223,7 @@ abstract class ConeIntegerLiteralType(val value: Long) : ConeSimpleKotlinType(),
|
|||||||
abstract val possibleTypes: Collection<ConeClassLikeType>
|
abstract val possibleTypes: Collection<ConeClassLikeType>
|
||||||
abstract val supertypes: List<ConeClassLikeType>
|
abstract val supertypes: List<ConeClassLikeType>
|
||||||
|
|
||||||
override val typeArguments: Array<out ConeKotlinTypeProjection> = emptyArray()
|
override val typeArguments: Array<out ConeTypeProjection> = emptyArray()
|
||||||
override val nullability: ConeNullability = ConeNullability.NOT_NULL
|
override val nullability: ConeNullability = ConeNullability.NOT_NULL
|
||||||
|
|
||||||
abstract fun getApproximatedType(expectedType: ConeKotlinType? = null): ConeClassLikeType
|
abstract fun getApproximatedType(expectedType: ConeKotlinType? = null): ConeClassLikeType
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ fun ConeKotlinType.render(): String {
|
|||||||
} + nullabilitySuffix
|
} + nullabilitySuffix
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun ConeKotlinTypeProjection.render(): String {
|
private fun ConeTypeProjection.render(): String {
|
||||||
return when (this) {
|
return when (this) {
|
||||||
ConeStarProjection -> "*"
|
ConeStarProjection -> "*"
|
||||||
is ConeKotlinTypeProjectionIn -> "in ${type.render()}"
|
is ConeKotlinTypeProjectionIn -> "in ${type.render()}"
|
||||||
|
|||||||
@@ -7,12 +7,12 @@ package org.jetbrains.kotlin.fir.types.impl
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag
|
import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag
|
||||||
import org.jetbrains.kotlin.fir.types.ConeClassLikeType
|
import org.jetbrains.kotlin.fir.types.ConeClassLikeType
|
||||||
import org.jetbrains.kotlin.fir.types.ConeKotlinTypeProjection
|
import org.jetbrains.kotlin.fir.types.ConeTypeProjection
|
||||||
import org.jetbrains.kotlin.fir.types.ConeNullability
|
import org.jetbrains.kotlin.fir.types.ConeNullability
|
||||||
|
|
||||||
class ConeClassLikeTypeImpl(
|
class ConeClassLikeTypeImpl(
|
||||||
override val lookupTag: ConeClassLikeLookupTag,
|
override val lookupTag: ConeClassLikeLookupTag,
|
||||||
override val typeArguments: Array<out ConeKotlinTypeProjection>,
|
override val typeArguments: Array<out ConeTypeProjection>,
|
||||||
isNullable: Boolean
|
isNullable: Boolean
|
||||||
) : ConeClassLikeType() {
|
) : ConeClassLikeType() {
|
||||||
override val nullability: ConeNullability = ConeNullability.create(isNullable)
|
override val nullability: ConeNullability = ConeNullability.create(isNullable)
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import org.jetbrains.kotlin.fir.expressions.impl.FirUnitExpression
|
|||||||
import org.jetbrains.kotlin.fir.references.*
|
import org.jetbrains.kotlin.fir.references.*
|
||||||
import org.jetbrains.kotlin.fir.references.impl.FirSimpleNamedReference
|
import org.jetbrains.kotlin.fir.references.impl.FirSimpleNamedReference
|
||||||
import org.jetbrains.kotlin.fir.resolve.directExpansionType
|
import org.jetbrains.kotlin.fir.resolve.directExpansionType
|
||||||
import org.jetbrains.kotlin.fir.resolve.firSymbolProvider
|
|
||||||
import org.jetbrains.kotlin.fir.resolve.toSymbol
|
import org.jetbrains.kotlin.fir.resolve.toSymbol
|
||||||
import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol
|
import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol
|
||||||
import org.jetbrains.kotlin.fir.resolve.diagnostics.FirAmbiguityError
|
import org.jetbrains.kotlin.fir.resolve.diagnostics.FirAmbiguityError
|
||||||
@@ -697,10 +696,10 @@ class HtmlFirDump internal constructor(private var linkResolver: FirLinkResolver
|
|||||||
generate(variableAssignment.rValue)
|
generate(variableAssignment.rValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun FlowContent.generate(projection: ConeKotlinTypeProjection) {
|
private fun FlowContent.generate(projection: ConeTypeProjection) {
|
||||||
when (projection) {
|
when (projection) {
|
||||||
is ConeStarProjection -> +"*"
|
is ConeStarProjection -> +"*"
|
||||||
is ConeTypedProjection -> {
|
is ConeKotlinTypeProjection -> {
|
||||||
when (projection.kind) {
|
when (projection.kind) {
|
||||||
ProjectionKind.IN -> keyword("in ")
|
ProjectionKind.IN -> keyword("in ")
|
||||||
ProjectionKind.OUT -> keyword("out ")
|
ProjectionKind.OUT -> keyword("out ")
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ private fun getArrayType(classId: ClassId?, irBuiltIns: IrBuiltIns): IrClassifie
|
|||||||
return irType?.let { irBuiltIns.primitiveArrayForType.getValue(it) }
|
return irType?.let { irBuiltIns.primitiveArrayForType.getValue(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun ConeKotlinTypeProjection.toIrTypeArgument(
|
fun ConeTypeProjection.toIrTypeArgument(
|
||||||
session: FirSession,
|
session: FirSession,
|
||||||
declarationStorage: Fir2IrDeclarationStorage,
|
declarationStorage: Fir2IrDeclarationStorage,
|
||||||
irBuiltIns: IrBuiltIns
|
irBuiltIns: IrBuiltIns
|
||||||
|
|||||||
@@ -418,7 +418,7 @@ class Fir2IrVisitor(
|
|||||||
).apply {
|
).apply {
|
||||||
val typeArguments = (constructedTypeRef as? FirResolvedTypeRef)?.type?.typeArguments
|
val typeArguments = (constructedTypeRef as? FirResolvedTypeRef)?.type?.typeArguments
|
||||||
if (typeArguments?.isNotEmpty() == true) {
|
if (typeArguments?.isNotEmpty() == true) {
|
||||||
val irType = (typeArguments.first() as ConeTypedProjection).type.toIrType(session, declarationStorage, irBuiltIns)
|
val irType = (typeArguments.first() as ConeKotlinTypeProjection).type.toIrType(session, declarationStorage, irBuiltIns)
|
||||||
putTypeArgument(0, irType)
|
putTypeArgument(0, irType)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -232,7 +232,7 @@ private fun ConeClassLikeType.mapToCanonicalNoExpansionString(session: FirSessio
|
|||||||
if (lookupTag.classId == StandardClassIds.Array) {
|
if (lookupTag.classId == StandardClassIds.Array) {
|
||||||
return when (val typeProjection = typeArguments[0]) {
|
return when (val typeProjection = typeArguments[0]) {
|
||||||
is ConeStarProjection -> CommonClassNames.JAVA_LANG_OBJECT
|
is ConeStarProjection -> CommonClassNames.JAVA_LANG_OBJECT
|
||||||
is ConeTypedProjection -> {
|
is ConeKotlinTypeProjection -> {
|
||||||
if (typeProjection.kind == ProjectionKind.IN)
|
if (typeProjection.kind == ProjectionKind.IN)
|
||||||
CommonClassNames.JAVA_LANG_VOID
|
CommonClassNames.JAVA_LANG_VOID
|
||||||
else
|
else
|
||||||
@@ -259,10 +259,10 @@ private fun ConeClassLikeType.mapToCanonicalNoExpansionString(session: FirSessio
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun ConeKotlinTypeProjection.mapToCanonicalString(session: FirSession): String {
|
private fun ConeTypeProjection.mapToCanonicalString(session: FirSession): String {
|
||||||
return when (this) {
|
return when (this) {
|
||||||
is ConeStarProjection -> "?"
|
is ConeStarProjection -> "?"
|
||||||
is ConeTypedProjection -> {
|
is ConeKotlinTypeProjection -> {
|
||||||
val wildcard = when (kind) {
|
val wildcard = when (kind) {
|
||||||
ProjectionKind.STAR -> error("Should be handled in the case above")
|
ProjectionKind.STAR -> error("Should be handled in the case above")
|
||||||
ProjectionKind.IN -> "? super "
|
ProjectionKind.IN -> "? super "
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ internal val JavaClass.classKind: ClassKind
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal fun ClassId.toConeKotlinType(
|
internal fun ClassId.toConeKotlinType(
|
||||||
typeArguments: Array<ConeKotlinTypeProjection>,
|
typeArguments: Array<ConeTypeProjection>,
|
||||||
isNullable: Boolean
|
isNullable: Boolean
|
||||||
): ConeLookupTagBasedType {
|
): ConeLookupTagBasedType {
|
||||||
val lookupTag = ConeClassLikeLookupTagImpl(this)
|
val lookupTag = ConeClassLikeLookupTagImpl(this)
|
||||||
@@ -152,8 +152,8 @@ internal fun JavaType?.toConeKotlinTypeWithoutEnhancement(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun ClassId.toConeFlexibleType(
|
private fun ClassId.toConeFlexibleType(
|
||||||
typeArguments: Array<ConeKotlinTypeProjection>,
|
typeArguments: Array<ConeTypeProjection>,
|
||||||
typeArgumentsForUpper: Array<ConeKotlinTypeProjection> = typeArguments
|
typeArgumentsForUpper: Array<ConeTypeProjection> = typeArguments
|
||||||
) = ConeFlexibleType(
|
) = ConeFlexibleType(
|
||||||
toConeKotlinType(typeArguments, isNullable = false),
|
toConeKotlinType(typeArguments, isNullable = false),
|
||||||
toConeKotlinType(typeArgumentsForUpper, isNullable = true)
|
toConeKotlinType(typeArgumentsForUpper, isNullable = true)
|
||||||
@@ -367,7 +367,7 @@ private fun JavaType?.toConeProjectionWithoutEnhancement(
|
|||||||
session: FirSession,
|
session: FirSession,
|
||||||
javaTypeParameterStack: JavaTypeParameterStack,
|
javaTypeParameterStack: JavaTypeParameterStack,
|
||||||
boundTypeParameter: FirTypeParameter?
|
boundTypeParameter: FirTypeParameter?
|
||||||
): ConeKotlinTypeProjection {
|
): ConeTypeProjection {
|
||||||
return when (this) {
|
return when (this) {
|
||||||
null -> ConeStarProjection
|
null -> ConeStarProjection
|
||||||
is JavaWildcardType -> {
|
is JavaWildcardType -> {
|
||||||
|
|||||||
+1
-1
@@ -155,7 +155,7 @@ class FirTypeDeserializer(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun typeArgument(typeArgumentProto: ProtoBuf.Type.Argument): ConeKotlinTypeProjection {
|
private fun typeArgument(typeArgumentProto: ProtoBuf.Type.Argument): ConeTypeProjection {
|
||||||
if (typeArgumentProto.projection == ProtoBuf.Type.Argument.Projection.STAR) {
|
if (typeArgumentProto.projection == ProtoBuf.Type.Argument.Projection.STAR) {
|
||||||
return ConeStarProjection
|
return ConeStarProjection
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,8 +9,6 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
|||||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||||
import org.jetbrains.kotlin.fir.*
|
import org.jetbrains.kotlin.fir.*
|
||||||
import org.jetbrains.kotlin.fir.declarations.*
|
import org.jetbrains.kotlin.fir.declarations.*
|
||||||
import org.jetbrains.kotlin.fir.diagnostics.DiagnosticKind
|
|
||||||
import org.jetbrains.kotlin.fir.diagnostics.FirSimpleDiagnostic
|
|
||||||
import org.jetbrains.kotlin.fir.diagnostics.FirStubDiagnostic
|
import org.jetbrains.kotlin.fir.diagnostics.FirStubDiagnostic
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccess
|
import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccess
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccessExpression
|
import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccessExpression
|
||||||
@@ -121,11 +119,11 @@ private fun mapTypeAliasArguments(
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun substituteArgument(projection: ConeKotlinTypeProjection): ConeKotlinTypeProjection? {
|
override fun substituteArgument(projection: ConeTypeProjection): ConeTypeProjection? {
|
||||||
val type = (projection as? ConeTypedProjection)?.type ?: return null
|
val type = (projection as? ConeKotlinTypeProjection)?.type ?: return null
|
||||||
val symbol = (type as? ConeTypeParameterType)?.lookupTag?.toSymbol() ?: return super.substituteArgument(projection)
|
val symbol = (type as? ConeTypeParameterType)?.lookupTag?.toSymbol() ?: return super.substituteArgument(projection)
|
||||||
val mappedProjection = typeAliasMap[symbol] ?: return super.substituteArgument(projection)
|
val mappedProjection = typeAliasMap[symbol] ?: return super.substituteArgument(projection)
|
||||||
val mappedType = (mappedProjection as? ConeTypedProjection)?.type ?: return mappedProjection
|
val mappedType = (mappedProjection as? ConeKotlinTypeProjection)?.type ?: return mappedProjection
|
||||||
val resultingKind = mappedProjection.kind + projection.kind
|
val resultingKind = mappedProjection.kind + projection.kind
|
||||||
return when (resultingKind) {
|
return when (resultingKind) {
|
||||||
ProjectionKind.STAR -> ConeStarProjection
|
ProjectionKind.STAR -> ConeStarProjection
|
||||||
@@ -148,7 +146,7 @@ fun ConeClassifierLookupTag.toSymbol(useSiteSession: FirSession): FirClassifierS
|
|||||||
|
|
||||||
fun ConeTypeParameterLookupTag.toSymbol(): FirTypeParameterSymbol = this.symbol as FirTypeParameterSymbol
|
fun ConeTypeParameterLookupTag.toSymbol(): FirTypeParameterSymbol = this.symbol as FirTypeParameterSymbol
|
||||||
|
|
||||||
fun FirClassifierSymbol<*>.constructType(typeArguments: Array<ConeKotlinTypeProjection>, isNullable: Boolean): ConeLookupTagBasedType {
|
fun FirClassifierSymbol<*>.constructType(typeArguments: Array<ConeTypeProjection>, isNullable: Boolean): ConeLookupTagBasedType {
|
||||||
return when (this) {
|
return when (this) {
|
||||||
is FirTypeParameterSymbol -> {
|
is FirTypeParameterSymbol -> {
|
||||||
ConeTypeParameterTypeImpl(this.toLookupTag(), isNullable)
|
ConeTypeParameterTypeImpl(this.toLookupTag(), isNullable)
|
||||||
@@ -184,7 +182,7 @@ fun FirClassifierSymbol<*>.constructType(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun List<FirQualifierPart>.toTypeProjections(): Array<ConeKotlinTypeProjection> = flatMap {
|
private fun List<FirQualifierPart>.toTypeProjections(): Array<ConeTypeProjection> = flatMap {
|
||||||
it.typeArguments.map { typeArgument ->
|
it.typeArguments.map { typeArgument ->
|
||||||
when (typeArgument) {
|
when (typeArgument) {
|
||||||
is FirStarProjection -> ConeStarProjection
|
is FirStarProjection -> ConeStarProjection
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ class FirSamResolverImpl(
|
|||||||
.map { it.symbol }
|
.map { it.symbol }
|
||||||
.zip(
|
.zip(
|
||||||
type.typeArguments.map {
|
type.typeArguments.map {
|
||||||
(it as? ConeTypedProjection)?.type
|
(it as? ConeKotlinTypeProjection)?.type
|
||||||
?: firSession.builtinTypes.nullableAnyType.type
|
?: firSession.builtinTypes.nullableAnyType.type
|
||||||
//ConeClassLikeTypeImpl(ConeClassLikeLookupTagImpl(StandardClassIds.Any), emptyArray(), isNullable = true)
|
//ConeClassLikeTypeImpl(ConeClassLikeLookupTagImpl(StandardClassIds.Any), emptyArray(), isNullable = true)
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -57,13 +57,13 @@ fun FirClass<*>.buildUseSiteMemberScope(useSiteSession: FirSession, builder: Sco
|
|||||||
/* TODO REMOVE */
|
/* TODO REMOVE */
|
||||||
fun createSubstitution(
|
fun createSubstitution(
|
||||||
typeParameters: List<FirTypeParameter>,
|
typeParameters: List<FirTypeParameter>,
|
||||||
typeArguments: Array<out ConeKotlinTypeProjection>,
|
typeArguments: Array<out ConeTypeProjection>,
|
||||||
session: FirSession
|
session: FirSession
|
||||||
): Map<FirTypeParameterSymbol, ConeKotlinType> {
|
): Map<FirTypeParameterSymbol, ConeKotlinType> {
|
||||||
return typeParameters.zip(typeArguments) { typeParameter, typeArgument ->
|
return typeParameters.zip(typeArguments) { typeParameter, typeArgument ->
|
||||||
val typeParameterSymbol = typeParameter.symbol
|
val typeParameterSymbol = typeParameter.symbol
|
||||||
typeParameterSymbol to when (typeArgument) {
|
typeParameterSymbol to when (typeArgument) {
|
||||||
is ConeTypedProjection -> {
|
is ConeKotlinTypeProjection -> {
|
||||||
typeArgument.type
|
typeArgument.type
|
||||||
}
|
}
|
||||||
else /* StarProjection */ -> {
|
else /* StarProjection */ -> {
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ internal sealed class CheckReceivers : ResolutionStage() {
|
|||||||
if (receiverType != null) return receiverType
|
if (receiverType != null) return receiverType
|
||||||
val returnTypeRef = callable.returnTypeRef as? FirResolvedTypeRef ?: return null
|
val returnTypeRef = callable.returnTypeRef as? FirResolvedTypeRef ?: return null
|
||||||
if (!returnTypeRef.isExtensionFunctionType(bodyResolveComponents.session)) return null
|
if (!returnTypeRef.isExtensionFunctionType(bodyResolveComponents.session)) return null
|
||||||
return (returnTypeRef.type.typeArguments.firstOrNull() as? ConeTypedProjection)?.type
|
return (returnTypeRef.type.typeArguments.firstOrNull() as? ConeKotlinTypeProjection)?.type
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -80,7 +80,7 @@ fun ConeKotlinType.isSuspendFunctionType(session: FirSession): Boolean {
|
|||||||
|
|
||||||
fun ConeKotlinType.receiverType(expectedTypeRef: FirTypeRef, session: FirSession): ConeKotlinType? {
|
fun ConeKotlinType.receiverType(expectedTypeRef: FirTypeRef, session: FirSession): ConeKotlinType? {
|
||||||
if (isBuiltinFunctionalType(session) && expectedTypeRef.isExtensionFunctionType(session)) {
|
if (isBuiltinFunctionalType(session) && expectedTypeRef.isExtensionFunctionType(session)) {
|
||||||
return ((this as ConeClassLikeType).fullyExpandedType(session).typeArguments.first() as ConeTypedProjection).type
|
return ((this as ConeClassLikeType).fullyExpandedType(session).typeArguments.first() as ConeKotlinTypeProjection).type
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
@@ -88,13 +88,13 @@ fun ConeKotlinType.receiverType(expectedTypeRef: FirTypeRef, session: FirSession
|
|||||||
fun ConeKotlinType.returnType(session: FirSession): ConeKotlinType? {
|
fun ConeKotlinType.returnType(session: FirSession): ConeKotlinType? {
|
||||||
require(this is ConeClassLikeType)
|
require(this is ConeClassLikeType)
|
||||||
val projection = fullyExpandedType(session).typeArguments.last()
|
val projection = fullyExpandedType(session).typeArguments.last()
|
||||||
return (projection as? ConeTypedProjection)?.type
|
return (projection as? ConeKotlinTypeProjection)?.type
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun ConeKotlinType.valueParameterTypesIncludingReceiver(session: FirSession): List<ConeKotlinType?> {
|
private fun ConeKotlinType.valueParameterTypesIncludingReceiver(session: FirSession): List<ConeKotlinType?> {
|
||||||
require(this is ConeClassLikeType)
|
require(this is ConeClassLikeType)
|
||||||
return fullyExpandedType(session).typeArguments.dropLast(1).map {
|
return fullyExpandedType(session).typeArguments.dropLast(1).map {
|
||||||
(it as? ConeTypedProjection)?.type
|
(it as? ConeKotlinTypeProjection)?.type
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,7 +119,7 @@ private fun extraLambdaInfo(
|
|||||||
val receiverType = argument.receiverType
|
val receiverType = argument.receiverType
|
||||||
val returnType =
|
val returnType =
|
||||||
argument.returnType
|
argument.returnType
|
||||||
?: expectedType?.typeArguments?.singleOrNull()?.safeAs<ConeTypedProjection>()?.type?.takeIf { isFunctionSupertype }
|
?: expectedType?.typeArguments?.singleOrNull()?.safeAs<ConeKotlinTypeProjection>()?.type?.takeIf { isFunctionSupertype }
|
||||||
?: typeVariable.defaultType
|
?: typeVariable.defaultType
|
||||||
|
|
||||||
val nothingType = argument.session.builtinTypes.nothingType.type
|
val nothingType = argument.session.builtinTypes.nothingType.type
|
||||||
|
|||||||
+5
-5
@@ -10,7 +10,7 @@ import org.jetbrains.kotlin.fir.types.*
|
|||||||
import org.jetbrains.kotlin.fir.types.impl.ConeClassLikeTypeImpl
|
import org.jetbrains.kotlin.fir.types.impl.ConeClassLikeTypeImpl
|
||||||
|
|
||||||
abstract class AbstractConeSubstitutor : ConeSubstitutor() {
|
abstract class AbstractConeSubstitutor : ConeSubstitutor() {
|
||||||
protected fun wrapProjection(old: ConeKotlinTypeProjection, newType: ConeKotlinType): ConeKotlinTypeProjection {
|
protected fun wrapProjection(old: ConeTypeProjection, newType: ConeKotlinType): ConeTypeProjection {
|
||||||
return when (old) {
|
return when (old) {
|
||||||
is ConeStarProjection -> old
|
is ConeStarProjection -> old
|
||||||
is ConeKotlinTypeProjectionIn -> ConeKotlinTypeProjectionIn(newType)
|
is ConeKotlinTypeProjectionIn -> ConeKotlinTypeProjectionIn(newType)
|
||||||
@@ -21,8 +21,8 @@ abstract class AbstractConeSubstitutor : ConeSubstitutor() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
abstract fun substituteType(type: ConeKotlinType): ConeKotlinType?
|
abstract fun substituteType(type: ConeKotlinType): ConeKotlinType?
|
||||||
open fun substituteArgument(projection: ConeKotlinTypeProjection): ConeKotlinTypeProjection? {
|
open fun substituteArgument(projection: ConeTypeProjection): ConeTypeProjection? {
|
||||||
val type = (projection as? ConeTypedProjection)?.type ?: return null
|
val type = (projection as? ConeKotlinTypeProjection)?.type ?: return null
|
||||||
val newType = substituteOrNull(type) ?: return null
|
val newType = substituteOrNull(type) ?: return null
|
||||||
return wrapProjection(projection, newType)
|
return wrapProjection(projection, newType)
|
||||||
}
|
}
|
||||||
@@ -88,7 +88,7 @@ abstract class AbstractConeSubstitutor : ConeSubstitutor() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun ConeKotlinType.substituteArguments(): ConeKotlinType? {
|
private fun ConeKotlinType.substituteArguments(): ConeKotlinType? {
|
||||||
val newArguments by lazy { arrayOfNulls<ConeKotlinTypeProjection>(typeArguments.size) }
|
val newArguments by lazy { arrayOfNulls<ConeTypeProjection>(typeArguments.size) }
|
||||||
var initialized = false
|
var initialized = false
|
||||||
for ((index, typeArgument) in this.typeArguments.withIndex()) {
|
for ((index, typeArgument) in this.typeArguments.withIndex()) {
|
||||||
newArguments[index] = substituteArgument(typeArgument)?.also {
|
newArguments[index] = substituteArgument(typeArgument)?.also {
|
||||||
@@ -106,7 +106,7 @@ abstract class AbstractConeSubstitutor : ConeSubstitutor() {
|
|||||||
return when (this) {
|
return when (this) {
|
||||||
is ConeClassLikeTypeImpl -> ConeClassLikeTypeImpl(
|
is ConeClassLikeTypeImpl -> ConeClassLikeTypeImpl(
|
||||||
lookupTag,
|
lookupTag,
|
||||||
newArguments as Array<ConeKotlinTypeProjection>,
|
newArguments as Array<ConeTypeProjection>,
|
||||||
nullability.isNullable
|
nullability.isNullable
|
||||||
)
|
)
|
||||||
is ConeClassLikeType -> error("Unknown class-like type to substitute: $this, ${this::class}")
|
is ConeClassLikeType -> error("Unknown class-like type to substitute: $this, ${this::class}")
|
||||||
|
|||||||
+1
-1
@@ -550,7 +550,7 @@ class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransformer) :
|
|||||||
}.compose()
|
}.compose()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun ConeKotlinTypeProjection.toFirTypeProjection(): FirTypeProjection = when (this) {
|
private fun ConeTypeProjection.toFirTypeProjection(): FirTypeProjection = when (this) {
|
||||||
is ConeStarProjection -> buildStarProjection()
|
is ConeStarProjection -> buildStarProjection()
|
||||||
else -> {
|
else -> {
|
||||||
val type = when (this) {
|
val type = when (this) {
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ fun ConeKotlinType.arrayElementType(session: FirSession): ConeKotlinType? {
|
|||||||
if (type !is ConeClassLikeType) return null
|
if (type !is ConeClassLikeType) return null
|
||||||
val classId = type.lookupTag.classId
|
val classId = type.lookupTag.classId
|
||||||
if (classId == StandardClassIds.Array)
|
if (classId == StandardClassIds.Array)
|
||||||
return (type.typeArguments.first() as ConeTypedProjection).type
|
return (type.typeArguments.first() as ConeKotlinTypeProjection).type
|
||||||
val elementType = StandardClassIds.elementTypeByPrimitiveArrayType[classId]
|
val elementType = StandardClassIds.elementTypeByPrimitiveArrayType[classId]
|
||||||
if (elementType != null) {
|
if (elementType != null) {
|
||||||
return elementType.invoke(session.firSymbolProvider).constructType(emptyArray(), isNullable = false)
|
return elementType.invoke(session.firSymbolProvider).constructType(emptyArray(), isNullable = false)
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext, ConeTypeCo
|
|||||||
return when (constructor) {
|
return when (constructor) {
|
||||||
is FirClassLikeSymbol<*> -> ConeClassLikeTypeImpl(
|
is FirClassLikeSymbol<*> -> ConeClassLikeTypeImpl(
|
||||||
constructor.toLookupTag(),
|
constructor.toLookupTag(),
|
||||||
(arguments as List<ConeKotlinTypeProjection>).toTypedArray(),
|
(arguments as List<ConeTypeProjection>).toTypedArray(),
|
||||||
nullable
|
nullable
|
||||||
)
|
)
|
||||||
is FirTypeParameterSymbol -> ConeTypeParameterTypeImpl(
|
is FirTypeParameterSymbol -> ConeTypeParameterTypeImpl(
|
||||||
@@ -107,7 +107,7 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext, ConeTypeCo
|
|||||||
|
|
||||||
var maxArgumentDepth = 0
|
var maxArgumentDepth = 0
|
||||||
for (arg in typeArguments) {
|
for (arg in typeArguments) {
|
||||||
val current = if (arg is ConeStarProjection) 1 else (arg as ConeTypedProjection).type.typeDepth()
|
val current = if (arg is ConeStarProjection) 1 else (arg as ConeKotlinTypeProjection).type.typeDepth()
|
||||||
if (current > maxArgumentDepth) {
|
if (current > maxArgumentDepth) {
|
||||||
maxArgumentDepth = current
|
maxArgumentDepth = current
|
||||||
}
|
}
|
||||||
@@ -217,7 +217,7 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext, ConeTypeCo
|
|||||||
captureStatus: CaptureStatus
|
captureStatus: CaptureStatus
|
||||||
): CapturedTypeMarker {
|
): CapturedTypeMarker {
|
||||||
require(lowerType is ConeKotlinType?)
|
require(lowerType is ConeKotlinType?)
|
||||||
require(constructorProjection is ConeKotlinTypeProjection)
|
require(constructorProjection is ConeTypeProjection)
|
||||||
return ConeCapturedType(
|
return ConeCapturedType(
|
||||||
captureStatus,
|
captureStatus,
|
||||||
lowerType,
|
lowerType,
|
||||||
@@ -236,7 +236,7 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext, ConeTypeCo
|
|||||||
|
|
||||||
override fun SimpleTypeMarker.replaceArguments(newArguments: List<TypeArgumentMarker>): SimpleTypeMarker {
|
override fun SimpleTypeMarker.replaceArguments(newArguments: List<TypeArgumentMarker>): SimpleTypeMarker {
|
||||||
require(this is ConeKotlinType)
|
require(this is ConeKotlinType)
|
||||||
return this.withArguments(newArguments.cast<List<ConeKotlinTypeProjection>>().toTypedArray())
|
return this.withArguments(newArguments.cast<List<ConeTypeProjection>>().toTypedArray())
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun KotlinTypeMarker.hasExactAnnotation(): Boolean {
|
override fun KotlinTypeMarker.hasExactAnnotation(): Boolean {
|
||||||
|
|||||||
@@ -175,12 +175,12 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun TypeArgumentMarker.isStarProjection(): Boolean {
|
override fun TypeArgumentMarker.isStarProjection(): Boolean {
|
||||||
require(this is ConeKotlinTypeProjection)
|
require(this is ConeTypeProjection)
|
||||||
return this is ConeStarProjection
|
return this is ConeStarProjection
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun TypeArgumentMarker.getVariance(): TypeVariance {
|
override fun TypeArgumentMarker.getVariance(): TypeVariance {
|
||||||
require(this is ConeKotlinTypeProjection)
|
require(this is ConeTypeProjection)
|
||||||
|
|
||||||
return when (this.kind) {
|
return when (this.kind) {
|
||||||
ProjectionKind.STAR -> error("Nekorrektno (c) Stas")
|
ProjectionKind.STAR -> error("Nekorrektno (c) Stas")
|
||||||
@@ -191,8 +191,8 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun TypeArgumentMarker.getType(): KotlinTypeMarker {
|
override fun TypeArgumentMarker.getType(): KotlinTypeMarker {
|
||||||
require(this is ConeKotlinTypeProjection)
|
require(this is ConeTypeProjection)
|
||||||
require(this is ConeTypedProjection) { "No type for StarProjection" }
|
require(this is ConeKotlinTypeProjection) { "No type for StarProjection" }
|
||||||
return this.type
|
return this.type
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -310,7 +310,7 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty
|
|||||||
if (argument !is ConeStarProjection && argument.kind == ProjectionKind.INVARIANT) return@Array argument
|
if (argument !is ConeStarProjection && argument.kind == ProjectionKind.INVARIANT) return@Array argument
|
||||||
|
|
||||||
val lowerType = if (argument !is ConeStarProjection && argument.getVariance() == TypeVariance.IN) {
|
val lowerType = if (argument !is ConeStarProjection && argument.getVariance() == TypeVariance.IN) {
|
||||||
(argument as ConeTypedProjection).type
|
(argument as ConeKotlinTypeProjection).type
|
||||||
} else {
|
} else {
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
@@ -516,7 +516,7 @@ class ConeTypeCheckerContext(
|
|||||||
val substitutor = if (declaration is FirTypeParametersOwner) {
|
val substitutor = if (declaration is FirTypeParametersOwner) {
|
||||||
val substitution =
|
val substitution =
|
||||||
declaration.typeParameters.zip(type.typeArguments).associate { (parameter, argument) ->
|
declaration.typeParameters.zip(type.typeArguments).associate { (parameter, argument) ->
|
||||||
parameter.symbol to ((argument as? ConeTypedProjection)?.type
|
parameter.symbol to ((argument as? ConeKotlinTypeProjection)?.type
|
||||||
?: session.builtinTypes.nullableAnyType.type)//StandardClassIds.Any(session.firSymbolProvider).constructType(emptyArray(), isNullable = true))
|
?: session.builtinTypes.nullableAnyType.type)//StandardClassIds.Any(session.firSymbolProvider).constructType(emptyArray(), isNullable = true))
|
||||||
}
|
}
|
||||||
substitutorByMap(substitution)
|
substitutorByMap(substitution)
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ fun ConeKotlinType.makeConeTypeDefinitelyNotNullOrNotNull(): ConeKotlinType {
|
|||||||
return ConeDefinitelyNotNullType.create(this) ?: this.withNullability(ConeNullability.NOT_NULL)
|
return ConeDefinitelyNotNullType.create(this) ?: this.withNullability(ConeNullability.NOT_NULL)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <T : ConeKotlinType> T.withArguments(arguments: Array<out ConeKotlinTypeProjection>): T {
|
fun <T : ConeKotlinType> T.withArguments(arguments: Array<out ConeTypeProjection>): T {
|
||||||
if (this.typeArguments === arguments) {
|
if (this.typeArguments === arguments) {
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
@@ -175,7 +175,7 @@ fun coneFlexibleOrSimpleType(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun ConeKotlinType.toTypeProjection(variance: Variance): ConeKotlinTypeProjection =
|
fun ConeKotlinType.toTypeProjection(variance: Variance): ConeTypeProjection =
|
||||||
when (variance) {
|
when (variance) {
|
||||||
Variance.INVARIANT -> this
|
Variance.INVARIANT -> this
|
||||||
Variance.IN_VARIANCE -> ConeKotlinTypeProjectionIn(this)
|
Variance.IN_VARIANCE -> ConeKotlinTypeProjectionIn(this)
|
||||||
@@ -183,13 +183,13 @@ fun ConeKotlinType.toTypeProjection(variance: Variance): ConeKotlinTypeProjectio
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun ConeClassLikeLookupTag.constructClassType(
|
fun ConeClassLikeLookupTag.constructClassType(
|
||||||
typeArguments: Array<out ConeKotlinTypeProjection>,
|
typeArguments: Array<out ConeTypeProjection>,
|
||||||
isNullable: Boolean,
|
isNullable: Boolean,
|
||||||
): ConeClassLikeType {
|
): ConeClassLikeType {
|
||||||
return ConeClassLikeTypeImpl(this, typeArguments, isNullable)
|
return ConeClassLikeTypeImpl(this, typeArguments, isNullable)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun ConeClassifierLookupTag.constructType(typeArguments: Array<out ConeKotlinTypeProjection>, isNullable: Boolean): ConeLookupTagBasedType {
|
fun ConeClassifierLookupTag.constructType(typeArguments: Array<out ConeTypeProjection>, isNullable: Boolean): ConeLookupTagBasedType {
|
||||||
return when (this) {
|
return when (this) {
|
||||||
is ConeTypeParameterLookupTag -> ConeTypeParameterTypeImpl(this, isNullable)
|
is ConeTypeParameterLookupTag -> ConeTypeParameterTypeImpl(this, isNullable)
|
||||||
is ConeClassLikeLookupTag -> this.constructClassType(typeArguments, isNullable)
|
is ConeClassLikeLookupTag -> this.constructClassType(typeArguments, isNullable)
|
||||||
|
|||||||
+2
-2
@@ -6,7 +6,7 @@
|
|||||||
package org.jetbrains.kotlin.fir.types.impl
|
package org.jetbrains.kotlin.fir.types.impl
|
||||||
|
|
||||||
import org.jetbrains.kotlin.fir.symbols.ConeTypeParameterLookupTag
|
import org.jetbrains.kotlin.fir.symbols.ConeTypeParameterLookupTag
|
||||||
import org.jetbrains.kotlin.fir.types.ConeKotlinTypeProjection
|
import org.jetbrains.kotlin.fir.types.ConeTypeProjection
|
||||||
import org.jetbrains.kotlin.fir.types.ConeNullability
|
import org.jetbrains.kotlin.fir.types.ConeNullability
|
||||||
import org.jetbrains.kotlin.fir.types.ConeTypeParameterType
|
import org.jetbrains.kotlin.fir.types.ConeTypeParameterType
|
||||||
|
|
||||||
@@ -14,7 +14,7 @@ class ConeTypeParameterTypeImpl(
|
|||||||
override val lookupTag: ConeTypeParameterLookupTag,
|
override val lookupTag: ConeTypeParameterLookupTag,
|
||||||
isNullable: Boolean
|
isNullable: Boolean
|
||||||
) : ConeTypeParameterType() {
|
) : ConeTypeParameterType() {
|
||||||
override val typeArguments: Array<out ConeKotlinTypeProjection>
|
override val typeArguments: Array<out ConeTypeProjection>
|
||||||
get() = EMPTY_ARRAY
|
get() = EMPTY_ARRAY
|
||||||
|
|
||||||
override val nullability: ConeNullability = ConeNullability.create(isNullable)
|
override val nullability: ConeNullability = ConeNullability.create(isNullable)
|
||||||
|
|||||||
+3
-3
@@ -11,7 +11,7 @@ import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
|
|||||||
import org.jetbrains.kotlin.fir.symbols.StandardClassIds
|
import org.jetbrains.kotlin.fir.symbols.StandardClassIds
|
||||||
import org.jetbrains.kotlin.fir.symbols.impl.ConeClassLikeLookupTagImpl
|
import org.jetbrains.kotlin.fir.symbols.impl.ConeClassLikeLookupTagImpl
|
||||||
import org.jetbrains.kotlin.fir.types.ConeClassLikeType
|
import org.jetbrains.kotlin.fir.types.ConeClassLikeType
|
||||||
import org.jetbrains.kotlin.fir.types.ConeKotlinTypeProjection
|
import org.jetbrains.kotlin.fir.types.ConeTypeProjection
|
||||||
import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef
|
import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef
|
||||||
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
||||||
import org.jetbrains.kotlin.fir.visitors.FirTransformer
|
import org.jetbrains.kotlin.fir.visitors.FirTransformer
|
||||||
@@ -21,7 +21,7 @@ import org.jetbrains.kotlin.name.ClassId
|
|||||||
sealed class FirImplicitBuiltinTypeRef(
|
sealed class FirImplicitBuiltinTypeRef(
|
||||||
override val source: FirSourceElement?,
|
override val source: FirSourceElement?,
|
||||||
val id: ClassId,
|
val id: ClassId,
|
||||||
typeArguments: Array<out ConeKotlinTypeProjection> = emptyArray(),
|
typeArguments: Array<out ConeTypeProjection> = emptyArray(),
|
||||||
isNullable: Boolean = false
|
isNullable: Boolean = false
|
||||||
) : FirResolvedTypeRef() {
|
) : FirResolvedTypeRef() {
|
||||||
override val annotations: List<FirAnnotationCall>
|
override val annotations: List<FirAnnotationCall>
|
||||||
@@ -77,5 +77,5 @@ class FirImplicitStringTypeRef(
|
|||||||
|
|
||||||
class FirImplicitKPropertyTypeRef(
|
class FirImplicitKPropertyTypeRef(
|
||||||
source: FirSourceElement?,
|
source: FirSourceElement?,
|
||||||
typeArgument: ConeKotlinTypeProjection
|
typeArgument: ConeTypeProjection
|
||||||
) : FirImplicitBuiltinTypeRef(source, StandardClassIds.KProperty, arrayOf(typeArgument))
|
) : FirImplicitBuiltinTypeRef(source, StandardClassIds.KProperty, arrayOf(typeArgument))
|
||||||
|
|||||||
Reference in New Issue
Block a user