Extract common code (TypeSystemContext)
This commit is contained in:
committed by
Mikhail Glukhikh
parent
2c7b05a67b
commit
85cd4f3cdf
+10
-25
@@ -121,13 +121,7 @@ interface ClassicTypeSystemContext : TypeSystemContext {
|
||||
return this.projectionKind.convertVariance()
|
||||
}
|
||||
|
||||
private fun Variance.convertVariance(): TypeVariance {
|
||||
return when (this) {
|
||||
Variance.INVARIANT -> TypeVariance.INV
|
||||
Variance.IN_VARIANCE -> TypeVariance.IN
|
||||
Variance.OUT_VARIANCE -> TypeVariance.OUT
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun TypeArgumentMarker.getType(): KotlinTypeMarker {
|
||||
require(this is TypeProjection, this::errorMessage)
|
||||
@@ -189,23 +183,6 @@ interface ClassicTypeSystemContext : TypeSystemContext {
|
||||
classDescriptor.kind != ClassKind.ANNOTATION_CLASS
|
||||
}
|
||||
|
||||
|
||||
override fun TypeArgumentListMarker.get(index: Int): TypeArgumentMarker {
|
||||
return when (this) {
|
||||
is SimpleTypeMarker -> getArgument(index)
|
||||
is ArgumentList -> get(index)
|
||||
else -> error("unknown type argument list type: $this, ${this::class}")
|
||||
}
|
||||
}
|
||||
|
||||
override fun TypeArgumentListMarker.size(): Int {
|
||||
return when (this) {
|
||||
is SimpleTypeMarker -> argumentsCount()
|
||||
is ArgumentList -> size
|
||||
else -> error("unknown type argument list type: $this, ${this::class}")
|
||||
}
|
||||
}
|
||||
|
||||
override fun SimpleTypeMarker.asArgumentList(): TypeArgumentListMarker {
|
||||
require(this is SimpleType, this::errorMessage)
|
||||
return this
|
||||
@@ -257,4 +234,12 @@ interface ClassicTypeSystemContext : TypeSystemContext {
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
private inline fun Any.errorMessage(): String {
|
||||
return "ClassicTypeSystemContext couldn't handle: $this, ${this::class}"
|
||||
}
|
||||
}
|
||||
|
||||
fun Variance.convertVariance(): TypeVariance {
|
||||
return when (this) {
|
||||
Variance.INVARIANT -> TypeVariance.INV
|
||||
Variance.IN_VARIANCE -> TypeVariance.IN
|
||||
Variance.OUT_VARIANCE -> TypeVariance.OUT
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,8 +114,21 @@ interface TypeSystemContext : TypeSystemOptimizationContext {
|
||||
|
||||
fun SimpleTypeMarker.asArgumentList(): TypeArgumentListMarker
|
||||
|
||||
fun TypeArgumentListMarker.size(): Int
|
||||
operator fun TypeArgumentListMarker.get(index: Int): TypeArgumentMarker
|
||||
operator fun TypeArgumentListMarker.get(index: Int): TypeArgumentMarker {
|
||||
return when (this) {
|
||||
is SimpleTypeMarker -> getArgument(index)
|
||||
is ArgumentList -> get(index)
|
||||
else -> error("unknown type argument list type: $this, ${this::class}")
|
||||
}
|
||||
}
|
||||
|
||||
fun TypeArgumentListMarker.size(): Int {
|
||||
return when (this) {
|
||||
is SimpleTypeMarker -> argumentsCount()
|
||||
is ArgumentList -> size
|
||||
else -> error("unknown type argument list type: $this, ${this::class}")
|
||||
}
|
||||
}
|
||||
|
||||
fun TypeConstructorMarker.isAnyConstructor(): Boolean
|
||||
fun TypeConstructorMarker.isNothingConstructor(): Boolean
|
||||
|
||||
Reference in New Issue
Block a user