Reuse error type constructor for stub types
This commit is contained in:
@@ -13,9 +13,10 @@ import org.jetbrains.kotlin.types.refinement.TypeRefinement
|
|||||||
class StubTypeForBuilderInference(
|
class StubTypeForBuilderInference(
|
||||||
originalTypeVariable: TypeConstructor,
|
originalTypeVariable: TypeConstructor,
|
||||||
isMarkedNullable: Boolean,
|
isMarkedNullable: Boolean,
|
||||||
|
override val constructor: TypeConstructor = createConstructor(originalTypeVariable)
|
||||||
) : AbstractStubType(originalTypeVariable, isMarkedNullable), StubTypeMarker {
|
) : AbstractStubType(originalTypeVariable, isMarkedNullable), StubTypeMarker {
|
||||||
override fun materialize(newNullability: Boolean): AbstractStubType =
|
override fun materialize(newNullability: Boolean): AbstractStubType =
|
||||||
StubTypeForBuilderInference(originalTypeVariable, newNullability)
|
StubTypeForBuilderInference(originalTypeVariable, newNullability, constructor)
|
||||||
|
|
||||||
override val memberScope = originalTypeVariable.builtIns.anyType.memberScope
|
override val memberScope = originalTypeVariable.builtIns.anyType.memberScope
|
||||||
|
|
||||||
@@ -25,10 +26,13 @@ class StubTypeForBuilderInference(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class StubTypeForTypeVariablesInSubtyping(originalTypeVariable: TypeConstructor, isMarkedNullable: Boolean) :
|
class StubTypeForTypeVariablesInSubtyping(
|
||||||
AbstractStubType(originalTypeVariable, isMarkedNullable), StubTypeMarker {
|
originalTypeVariable: TypeConstructor,
|
||||||
|
isMarkedNullable: Boolean,
|
||||||
|
override val constructor: TypeConstructor = createConstructor(originalTypeVariable)
|
||||||
|
) : AbstractStubType(originalTypeVariable, isMarkedNullable), StubTypeMarker {
|
||||||
override fun materialize(newNullability: Boolean): AbstractStubType =
|
override fun materialize(newNullability: Boolean): AbstractStubType =
|
||||||
StubTypeForTypeVariablesInSubtyping(originalTypeVariable, newNullability)
|
StubTypeForTypeVariablesInSubtyping(originalTypeVariable, newNullability, constructor)
|
||||||
|
|
||||||
override fun toString(): String {
|
override fun toString(): String {
|
||||||
return "Stub (subtyping): $originalTypeVariable${if (isMarkedNullable) "?" else ""}"
|
return "Stub (subtyping): $originalTypeVariable${if (isMarkedNullable) "?" else ""}"
|
||||||
@@ -36,10 +40,13 @@ class StubTypeForTypeVariablesInSubtyping(originalTypeVariable: TypeConstructor,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This type is used as a replacement of type variables for provideDelegate resolve
|
// This type is used as a replacement of type variables for provideDelegate resolve
|
||||||
class StubTypeForProvideDelegateReceiver(originalTypeVariable: TypeConstructor, isMarkedNullable: Boolean) :
|
class StubTypeForProvideDelegateReceiver(
|
||||||
AbstractStubType(originalTypeVariable, isMarkedNullable) {
|
originalTypeVariable: TypeConstructor,
|
||||||
|
isMarkedNullable: Boolean,
|
||||||
|
override val constructor: TypeConstructor = createConstructor(originalTypeVariable)
|
||||||
|
) : AbstractStubType(originalTypeVariable, isMarkedNullable) {
|
||||||
override fun materialize(newNullability: Boolean): StubTypeForProvideDelegateReceiver =
|
override fun materialize(newNullability: Boolean): StubTypeForProvideDelegateReceiver =
|
||||||
StubTypeForProvideDelegateReceiver(originalTypeVariable, newNullability)
|
StubTypeForProvideDelegateReceiver(originalTypeVariable, newNullability, constructor)
|
||||||
|
|
||||||
override fun toString(): String {
|
override fun toString(): String {
|
||||||
return "Stub (delegation): $originalTypeVariable${if (isMarkedNullable) "?" else ""}"
|
return "Stub (delegation): $originalTypeVariable${if (isMarkedNullable) "?" else ""}"
|
||||||
@@ -48,7 +55,6 @@ class StubTypeForProvideDelegateReceiver(originalTypeVariable: TypeConstructor,
|
|||||||
|
|
||||||
abstract class AbstractStubType(val originalTypeVariable: TypeConstructor, override val isMarkedNullable: Boolean) : SimpleType() {
|
abstract class AbstractStubType(val originalTypeVariable: TypeConstructor, override val isMarkedNullable: Boolean) : SimpleType() {
|
||||||
override val memberScope = ErrorUtils.createErrorScope("Scope for stub type: $originalTypeVariable")
|
override val memberScope = ErrorUtils.createErrorScope("Scope for stub type: $originalTypeVariable")
|
||||||
override val constructor = ErrorUtils.createErrorTypeConstructor("Constructor for stub type: $originalTypeVariable")
|
|
||||||
|
|
||||||
override val arguments: List<TypeProjection>
|
override val arguments: List<TypeProjection>
|
||||||
get() = emptyList()
|
get() = emptyList()
|
||||||
@@ -66,4 +72,9 @@ abstract class AbstractStubType(val originalTypeVariable: TypeConstructor, overr
|
|||||||
override fun refine(kotlinTypeRefiner: KotlinTypeRefiner) = this
|
override fun refine(kotlinTypeRefiner: KotlinTypeRefiner) = this
|
||||||
|
|
||||||
abstract fun materialize(newNullability: Boolean): AbstractStubType
|
abstract fun materialize(newNullability: Boolean): AbstractStubType
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun createConstructor(originalTypeVariable: TypeConstructor) =
|
||||||
|
ErrorUtils.createErrorTypeConstructor("Constructor for stub type: $originalTypeVariable")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user