[NI] Relax rules for call completion: require at least one constraint

It's enough to have at least one good constraint.

 Note that the whole algorithm can be a bit more general:
 we could check also Out<T>, In<T> and verify that T has good only
 lower constraint or upper constraint, but there are questions for
 types like Inv<Out<T>>, where T should have lower and upper constraints

 #KT-31514 Fixed
This commit is contained in:
Mikhail Zarechenskiy
2019-05-28 19:53:22 +03:00
parent 848640253a
commit f702417655
13 changed files with 94 additions and 8 deletions
@@ -11,7 +11,7 @@ fun <T> bind(r: Option<T>): Option<T> {
// Ideally we should infer Option<T> here (see KT-10896)
(<!OI;TYPE_INFERENCE_FAILED_ON_SPECIAL_CONSTRUCT!>if<!> (true) <!OI;TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH!>None()<!> else <!DEBUG_INFO_SMARTCAST!>r<!>) checkType { <!NI;DEBUG_INFO_UNRESOLVED_WITH_TARGET, NI;UNRESOLVED_REFERENCE_WRONG_RECEIVER, OI;TYPE_MISMATCH!>_<!><Option<T>>() }
// Works correctly
if (true) None() else r
if (true) None() else <!NI;DEBUG_INFO_SMARTCAST!>r<!>
}
else r
}
@@ -36,7 +36,7 @@ fun <T> bindWhen(r: Option<T>): Option<T> {
return when (r) {
is Some -> {
// Works correctly
if (true) None() else r
if (true) None() else <!NI;DEBUG_INFO_SMARTCAST!>r<!>
}
else -> r
}