Use Variance instead of custom class in KtTypeArgumentWithVariance
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
package org.jetbrains.kotlin.idea.frontend.api
|
package org.jetbrains.kotlin.idea.frontend.api
|
||||||
|
|
||||||
import org.jetbrains.kotlin.idea.frontend.api.types.KtType
|
import org.jetbrains.kotlin.idea.frontend.api.types.KtType
|
||||||
|
import org.jetbrains.kotlin.types.Variance
|
||||||
|
|
||||||
sealed class KtTypeArgument
|
sealed class KtTypeArgument
|
||||||
|
|
||||||
@@ -13,10 +14,5 @@ object KtStarProjectionTypeArgument : KtTypeArgument()
|
|||||||
|
|
||||||
abstract class KtTypeArgumentWithVariance : KtTypeArgument() {
|
abstract class KtTypeArgumentWithVariance : KtTypeArgument() {
|
||||||
abstract val type: KtType
|
abstract val type: KtType
|
||||||
abstract val variance: KtTypeArgumentVariance
|
abstract val variance: Variance
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class KtTypeArgumentVariance {
|
|
||||||
COVARIANT, CONTRAVARIANT, INVARIANT
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
+4
-3
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.idea.frontend.api.components
|
|||||||
import org.jetbrains.kotlin.idea.frontend.api.*
|
import org.jetbrains.kotlin.idea.frontend.api.*
|
||||||
import org.jetbrains.kotlin.idea.frontend.api.types.*
|
import org.jetbrains.kotlin.idea.frontend.api.types.*
|
||||||
import org.jetbrains.kotlin.name.ClassId
|
import org.jetbrains.kotlin.name.ClassId
|
||||||
|
import org.jetbrains.kotlin.types.Variance
|
||||||
|
|
||||||
abstract class KtTypeRenderer : KtAnalysisSessionComponent() {
|
abstract class KtTypeRenderer : KtAnalysisSessionComponent() {
|
||||||
abstract fun render(type: KtType, options: KtTypeRendererOptions): String
|
abstract fun render(type: KtType, options: KtTypeRendererOptions): String
|
||||||
@@ -83,9 +84,9 @@ class KtDefaultTypeRenderer(override val analysisSession: KtAnalysisSession, ove
|
|||||||
}
|
}
|
||||||
is KtTypeArgumentWithVariance -> {
|
is KtTypeArgumentWithVariance -> {
|
||||||
val varianceWithSpace = when (typeArgument.variance) {
|
val varianceWithSpace = when (typeArgument.variance) {
|
||||||
KtTypeArgumentVariance.COVARIANT -> "out "
|
Variance.OUT_VARIANCE -> "out "
|
||||||
KtTypeArgumentVariance.CONTRAVARIANT -> "in "
|
Variance.IN_VARIANCE -> "in "
|
||||||
KtTypeArgumentVariance.INVARIANT -> ""
|
Variance.INVARIANT -> ""
|
||||||
}
|
}
|
||||||
append(varianceWithSpace)
|
append(varianceWithSpace)
|
||||||
render(typeArgument.type, options)
|
render(typeArgument.type, options)
|
||||||
|
|||||||
+4
-3
@@ -29,6 +29,7 @@ import org.jetbrains.kotlin.idea.frontend.api.types.KtType
|
|||||||
import org.jetbrains.kotlin.idea.stubindex.PackageIndexUtil
|
import org.jetbrains.kotlin.idea.stubindex.PackageIndexUtil
|
||||||
import org.jetbrains.kotlin.name.ClassId
|
import org.jetbrains.kotlin.name.ClassId
|
||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
|
import org.jetbrains.kotlin.types.Variance
|
||||||
import java.util.concurrent.ConcurrentMap
|
import java.util.concurrent.ConcurrentMap
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -189,9 +190,9 @@ internal class KtSymbolByFirBuilder private constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun ProjectionKind.toVariance() = when (this) {
|
private fun ProjectionKind.toVariance() = when (this) {
|
||||||
ProjectionKind.OUT -> KtTypeArgumentVariance.COVARIANT
|
ProjectionKind.OUT -> Variance.OUT_VARIANCE
|
||||||
ProjectionKind.IN -> KtTypeArgumentVariance.CONTRAVARIANT
|
ProjectionKind.IN -> Variance.IN_VARIANCE
|
||||||
ProjectionKind.INVARIANT -> KtTypeArgumentVariance.INVARIANT
|
ProjectionKind.INVARIANT -> Variance.INVARIANT
|
||||||
ProjectionKind.STAR -> error("KtStarProjectionTypeArgument be directly created")
|
ProjectionKind.STAR -> error("KtStarProjectionTypeArgument be directly created")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -18,6 +18,7 @@ import org.jetbrains.kotlin.idea.frontend.api.symbols.KtTypeParameterSymbol
|
|||||||
import org.jetbrains.kotlin.idea.frontend.api.types.*
|
import org.jetbrains.kotlin.idea.frontend.api.types.*
|
||||||
import org.jetbrains.kotlin.name.ClassId
|
import org.jetbrains.kotlin.name.ClassId
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
import org.jetbrains.kotlin.types.Variance
|
||||||
|
|
||||||
internal interface KtFirType : KtType, ValidityTokenOwner {
|
internal interface KtFirType : KtType, ValidityTokenOwner {
|
||||||
val coneType: ConeKotlinType
|
val coneType: ConeKotlinType
|
||||||
@@ -103,5 +104,5 @@ internal class KtFirIntersectionType(
|
|||||||
|
|
||||||
internal class KtFirTypeArgumentWithVariance(
|
internal class KtFirTypeArgumentWithVariance(
|
||||||
override val type: KtType,
|
override val type: KtType,
|
||||||
override val variance: KtTypeArgumentVariance
|
override val variance: Variance
|
||||||
) : KtTypeArgumentWithVariance()
|
) : KtTypeArgumentWithVariance()
|
||||||
Reference in New Issue
Block a user