ResultTypeResolver: don't allow Nothing as ILT subtype
#KT-58379 Fixed
This commit is contained in:
committed by
Space Team
parent
6ae648f6f6
commit
1c7ffb3276
+3
-2
@@ -94,12 +94,13 @@ class ResultTypeResolver(
|
||||
// and the second one from UPPER/LOWER constraints (subType/superType based)
|
||||
// The logic of choice here is:
|
||||
// - if one type is null, we return another one
|
||||
// - we return type from UPPER/LOWER constraints if it's more precise
|
||||
// - we return type from UPPER/LOWER constraints if it's more precise (in fact, only Int/Short/Byte/Long is allowed here)
|
||||
// - otherwise we return ILT-based type
|
||||
return when {
|
||||
resultTypeFromEqualConstraint == null -> resultTypeFromDirection
|
||||
resultTypeFromDirection == null -> resultTypeFromEqualConstraint
|
||||
AbstractTypeChecker.isSubtypeOf(c, resultTypeFromDirection, resultTypeFromEqualConstraint) -> resultTypeFromDirection
|
||||
with(c) { !resultTypeFromDirection.typeConstructor().isNothingConstructor() } &&
|
||||
AbstractTypeChecker.isSubtypeOf(c, resultTypeFromDirection, resultTypeFromEqualConstraint) -> resultTypeFromDirection
|
||||
else -> resultTypeFromEqualConstraint
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user