[FIR] Introduce ConeStubType to have subtyping for non-fixed variables

Currently, it's needed after changes in d7b47108f70a107818a04c8b8db33bfbf7c7e590

 Later it'll be also used for builder-inference
This commit is contained in:
Mikhail Zarechenskiy
2019-09-03 20:02:14 +03:00
parent 01ad9c47c8
commit 77577dfa6f
11 changed files with 32 additions and 17 deletions
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.fir.types
import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag
import org.jetbrains.kotlin.fir.symbols.ConeClassifierLookupTag
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.types.model.*
sealed class ConeKotlinTypeProjection : TypeArgumentMarker {
@@ -193,3 +194,17 @@ class ConeIntersectionType(
fun ConeIntersectionType.mapTypes(func: (ConeKotlinType) -> ConeKotlinType): ConeIntersectionType {
return ConeIntersectionType(intersectedTypes.map(func))
}
class ConeStubType(val variable: ConeTypeVariable, override val nullability: ConeNullability) : StubTypeMarker, ConeKotlinType() {
override val typeArguments: Array<out ConeKotlinTypeProjection>
get() = emptyArray()
}
open class ConeTypeVariable(name: String) : TypeVariableMarker {
val typeConstructor = ConeTypeVariableTypeConstructor(name)
val defaultType = ConeTypeVariableType(ConeNullability.NOT_NULL, typeConstructor)
}
class ConeTypeVariableTypeConstructor(val debugName: String) : ConeClassifierLookupTag(), TypeVariableTypeConstructorMarker {
override val name: Name get() = Name.identifier(debugName)
}
@@ -46,5 +46,6 @@ fun ConeKotlinType.render(): String {
postfix = ")"
)
}
is ConeStubType -> "stub type: $variable"
} + nullabilitySuffix
}