Don't do new captured type specific checks for old ones in the type checker
^KT-47143 Fixed
This commit is contained in:
@@ -376,8 +376,9 @@ object AbstractTypeChecker {
|
||||
): Boolean {
|
||||
val simpleSubArgumentType = subArgumentType.asSimpleType()
|
||||
|
||||
if (simpleSubArgumentType !is CapturedTypeMarker || !simpleSubArgumentType.typeConstructor().projection().isStarProjection())
|
||||
return false
|
||||
if (simpleSubArgumentType !is CapturedTypeMarker || simpleSubArgumentType.isOldCapturedType()
|
||||
|| !simpleSubArgumentType.typeConstructor().projection().isStarProjection()
|
||||
) return false
|
||||
// Only 'for subtyping' captured types are approximated before adding constraints (see ConstraintInjector.addNewIncorporatedConstraint)
|
||||
// that can lead to adding problematic constraints like UPPER(Nothing) given by CapturedType(*) <: TypeVariable(A)
|
||||
if (simpleSubArgumentType.captureStatus() != CaptureStatus.FOR_SUBTYPING) return false
|
||||
|
||||
@@ -285,6 +285,7 @@ interface TypeSystemContext : TypeSystemOptimizationContext {
|
||||
fun SimpleTypeMarker.typeConstructor(): TypeConstructorMarker
|
||||
fun KotlinTypeMarker.withNullability(nullable: Boolean): KotlinTypeMarker
|
||||
|
||||
fun CapturedTypeMarker.isOldCapturedType(): Boolean
|
||||
fun CapturedTypeMarker.typeConstructor(): CapturedTypeConstructorMarker
|
||||
fun CapturedTypeMarker.captureStatus(): CaptureStatus
|
||||
fun CapturedTypeMarker.isProjectionNotNull(): Boolean
|
||||
|
||||
@@ -17,6 +17,7 @@ import org.jetbrains.kotlin.name.FqNameUnsafe
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.CapturedType
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.CapturedTypeConstructor
|
||||
import org.jetbrains.kotlin.resolve.constants.IntegerLiteralTypeConstructor
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.*
|
||||
import org.jetbrains.kotlin.resolve.isInlineClass
|
||||
@@ -462,6 +463,8 @@ interface ClassicTypeSystemContext : TypeSystemInferenceExtensionContext, TypeSy
|
||||
return this.captureStatus
|
||||
}
|
||||
|
||||
override fun CapturedTypeMarker.isOldCapturedType(): Boolean = this is CapturedType
|
||||
|
||||
override fun KotlinTypeMarker.isNullableType(): Boolean {
|
||||
require(this is KotlinType, this::errorMessage)
|
||||
return TypeUtils.isNullableType(this)
|
||||
|
||||
Reference in New Issue
Block a user