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)
|
// and the second one from UPPER/LOWER constraints (subType/superType based)
|
||||||
// The logic of choice here is:
|
// The logic of choice here is:
|
||||||
// - if one type is null, we return another one
|
// - 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
|
// - otherwise we return ILT-based type
|
||||||
return when {
|
return when {
|
||||||
resultTypeFromEqualConstraint == null -> resultTypeFromDirection
|
resultTypeFromEqualConstraint == null -> resultTypeFromDirection
|
||||||
resultTypeFromDirection == null -> resultTypeFromEqualConstraint
|
resultTypeFromDirection == null -> resultTypeFromEqualConstraint
|
||||||
AbstractTypeChecker.isSubtypeOf(c, resultTypeFromDirection, resultTypeFromEqualConstraint) -> resultTypeFromDirection
|
with(c) { !resultTypeFromDirection.typeConstructor().isNothingConstructor() } &&
|
||||||
|
AbstractTypeChecker.isSubtypeOf(c, resultTypeFromDirection, resultTypeFromEqualConstraint) -> resultTypeFromDirection
|
||||||
else -> resultTypeFromEqualConstraint
|
else -> resultTypeFromEqualConstraint
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
// WITH_STDLIB
|
|
||||||
|
|
||||||
import Cause.*
|
|
||||||
|
|
||||||
typealias ChallengeFunction = suspend (String) -> Unit
|
|
||||||
|
|
||||||
enum class Cause {
|
|
||||||
FIRST,
|
|
||||||
SECOND,
|
|
||||||
ERROR,
|
|
||||||
LAST
|
|
||||||
}
|
|
||||||
|
|
||||||
class Some {
|
|
||||||
internal val register = mutableListOf<Pair<Cause, ChallengeFunction>>()
|
|
||||||
|
|
||||||
internal val challenges: List<ChallengeFunction>
|
|
||||||
get() = <!NEW_INFERENCE_ERROR!>register.filter { it.first != ERROR }.sortedBy {
|
|
||||||
when (it.first) {
|
|
||||||
FIRST -> 1
|
|
||||||
SECOND -> 2
|
|
||||||
else -> throw AssertionError()
|
|
||||||
}
|
|
||||||
}<!>.map { it.second }
|
|
||||||
}
|
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// FIR_IDENTICAL
|
||||||
// WITH_STDLIB
|
// WITH_STDLIB
|
||||||
|
|
||||||
import Cause.*
|
import Cause.*
|
||||||
|
|||||||
Reference in New Issue
Block a user