[NI] Make it possible to use nullable non-fixed type
This commit is contained in:
+1
-1
@@ -275,7 +275,7 @@ class NewConstraintSystemImpl(
|
|||||||
|
|
||||||
override fun bindingStubsForPostponedVariables(): Map<NewTypeVariable, NonFixedType> {
|
override fun bindingStubsForPostponedVariables(): Map<NewTypeVariable, NonFixedType> {
|
||||||
checkState(State.BUILDING, State.COMPLETION)
|
checkState(State.BUILDING, State.COMPLETION)
|
||||||
return storage.postponedTypeVariables.associate { it to NonFixedType(it.freshTypeConstructor) }
|
return storage.postponedTypeVariables.associate { it to NonFixedType(it.freshTypeConstructor, it.defaultType.isMarkedNullable) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun copyCurrentStorage(): ConstraintStorage {
|
override fun copyCurrentStorage(): ConstraintStorage {
|
||||||
|
|||||||
@@ -8,25 +8,32 @@ package org.jetbrains.kotlin.types
|
|||||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||||
|
|
||||||
class NonFixedType(val originalTypeVariable: TypeConstructor) : SimpleType() {
|
// This type is used as a stub for postponed type variables, which are important for coroutine inference
|
||||||
|
class NonFixedType(
|
||||||
|
private val originalTypeVariable: TypeConstructor,
|
||||||
|
override val isMarkedNullable: Boolean,
|
||||||
override val constructor: TypeConstructor =
|
override val constructor: TypeConstructor =
|
||||||
ErrorUtils.createErrorTypeConstructor("Constructor for non fixed type: $originalTypeVariable")
|
ErrorUtils.createErrorTypeConstructor("Constructor for non fixed type: $originalTypeVariable"),
|
||||||
|
override val memberScope: MemberScope =
|
||||||
|
ErrorUtils.createErrorScope("Scope for non fixed type: $originalTypeVariable")
|
||||||
|
) : SimpleType() {
|
||||||
|
|
||||||
override val arguments: List<TypeProjection>
|
override val arguments: List<TypeProjection>
|
||||||
get() = emptyList()
|
get() = emptyList()
|
||||||
|
|
||||||
override val isMarkedNullable: Boolean
|
|
||||||
get() = false
|
|
||||||
|
|
||||||
override val memberScope: MemberScope =
|
|
||||||
ErrorUtils.createErrorScope("Scope for non fixed type: $originalTypeVariable")
|
|
||||||
|
|
||||||
override val annotations: Annotations
|
override val annotations: Annotations
|
||||||
get() = Annotations.EMPTY
|
get() = Annotations.EMPTY
|
||||||
|
|
||||||
override fun replaceAnnotations(newAnnotations: Annotations): SimpleType = this
|
override fun replaceAnnotations(newAnnotations: Annotations): SimpleType {
|
||||||
|
error("Shouldn't be called on non-fixed type")
|
||||||
|
}
|
||||||
|
|
||||||
override fun makeNullableAsSpecified(newNullability: Boolean): SimpleType = this
|
override fun makeNullableAsSpecified(newNullability: Boolean): SimpleType {
|
||||||
|
return if (newNullability == isMarkedNullable)
|
||||||
|
this
|
||||||
|
else
|
||||||
|
NonFixedType(originalTypeVariable, newNullability, constructor, memberScope)
|
||||||
|
}
|
||||||
|
|
||||||
override fun toString(): String {
|
override fun toString(): String {
|
||||||
return "NonFixed: $originalTypeVariable"
|
return "NonFixed: $originalTypeVariable"
|
||||||
|
|||||||
Reference in New Issue
Block a user