NI: Prefer nullable lower bound to flexible one when substitution of type variable is performed
^KT-32435 Fixed
This commit is contained in:
committed by
victor.petukhov
parent
78dfcef160
commit
09c2b92b1d
+6
-2
@@ -136,7 +136,7 @@ abstract class AbstractTypeCheckerContextForConstraintSystem : AbstractTypeCheck
|
||||
*
|
||||
* => Foo <: T! -- (Foo!! .. Foo) <: T
|
||||
*
|
||||
* Foo? <: T! -- (Foo!! .. Foo?) <: T
|
||||
* Foo? <: T! -- Foo? <: T
|
||||
*
|
||||
*
|
||||
* (Foo..Bar) <: T! --
|
||||
@@ -163,7 +163,11 @@ abstract class AbstractTypeCheckerContextForConstraintSystem : AbstractTypeCheck
|
||||
when (subType) {
|
||||
is SimpleTypeMarker ->
|
||||
// Foo <: T! -- (Foo!! .. Foo) <: T
|
||||
createFlexibleType(subType.makeSimpleTypeDefinitelyNotNullOrNotNull(), subType)
|
||||
if (subType.isNullableType()) {
|
||||
subType // prefer nullable type to flexible one: `Foo? <: (T..T?)` => lowerConstraint = `Foo?`
|
||||
} else {
|
||||
createFlexibleType(subType.makeSimpleTypeDefinitelyNotNullOrNotNull(), subType)
|
||||
}
|
||||
|
||||
is FlexibleTypeMarker ->
|
||||
// (Foo..Bar) <: T! -- (Foo!! .. Bar) <: T
|
||||
|
||||
Reference in New Issue
Block a user