Ignore constraint from implicit 'in Nothing'
From Array<T> <: Array<out Int> we may generate T >: Nothing (implicit) and T <: Int (explicit). Without ignoring we'll infer 'Nothing' for T too often
This commit is contained in:
@@ -160,10 +160,6 @@ public class TypeBoundsImpl(
|
||||
// a captured type might be an answer
|
||||
if (!possibleAnswer.getConstructor().isDenotable() && !possibleAnswer.isCaptured()) return false
|
||||
|
||||
// e.g. if T has a lower bound 'Nothing' and an upper bound 'String',
|
||||
// by default 'Nothing' is inferred which can lead to an error for reified type variable
|
||||
if (typeVariable.isReified() && possibleAnswer.cannotBeReified()) return false
|
||||
|
||||
for (bound in bounds) {
|
||||
when (bound.kind) {
|
||||
LOWER_BOUND -> if (!JetTypeChecker.DEFAULT.isSubtypeOf(bound.constrainingType, possibleAnswer)) {
|
||||
|
||||
+6
-1
@@ -244,7 +244,12 @@ public class TypeCheckingProcedure {
|
||||
}
|
||||
else {
|
||||
if (!constraints.assertSubtype(subOut, superOut, this)) return false;
|
||||
if (!constraints.assertSubtype(superIn, subIn, this)) return false;
|
||||
if (superArgument.getProjectionKind() != Variance.OUT_VARIANCE) {
|
||||
if (!constraints.assertSubtype(superIn, subIn, this)) return false;
|
||||
}
|
||||
else {
|
||||
assert KotlinBuiltIns.isNothing(superIn) : "In component must be Nothing for out-projection";
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user