[NI] Complete call if return type has proper lower or equal constraints
There was a silly bug: equal constraint is actually a lower and an upper constraint, but we checked only presence of lower constraints. Test is important as here we have one equal constraint and should complete inner call `foo<Int>()` without propagating it to `bar` to avoid using `NoInfer` annotation multiple times
This commit is contained in:
+2
-1
@@ -210,7 +210,8 @@ class KotlinCallCompleter(
|
|||||||
val constraints = variableWithConstraints.constraints
|
val constraints = variableWithConstraints.constraints
|
||||||
return constraints.isNotEmpty() && constraints.all {
|
return constraints.isNotEmpty() && constraints.all {
|
||||||
!it.type.typeConstructor(context).isIntegerLiteralTypeConstructor(context) &&
|
!it.type.typeConstructor(context).isIntegerLiteralTypeConstructor(context) &&
|
||||||
it.kind.isLower() && csBuilder.isProperType(it.type)
|
(it.kind.isLower() || it.kind.isEqual()) &&
|
||||||
|
csBuilder.isProperType(it.type)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -19,8 +19,8 @@ fun test(i: Int?) {
|
|||||||
|
|
||||||
foo(<!REDUNDANT_LABEL_WARNING!>l4@<!> <!TYPE_MISMATCH!>""<!>)
|
foo(<!REDUNDANT_LABEL_WARNING!>l4@<!> <!TYPE_MISMATCH!>""<!>)
|
||||||
foo((<!TYPE_MISMATCH!>""<!>))
|
foo((<!TYPE_MISMATCH!>""<!>))
|
||||||
foo(checkSubtype<Int>(<!NI;TYPE_MISMATCH, NI;TYPE_MISMATCH, TYPE_MISMATCH!>""<!>))
|
foo(checkSubtype<Int>(<!TYPE_MISMATCH!>""<!>))
|
||||||
foo(<!NI;TYPE_MISMATCH, TYPE_MISMATCH!>checkSubtype<Long>(<!NI;TYPE_MISMATCH, NI;TYPE_MISMATCH, TYPE_MISMATCH!>""<!>)<!>)
|
foo(<!TYPE_MISMATCH!>checkSubtype<Long>(<!TYPE_MISMATCH!>""<!>)<!>)
|
||||||
|
|
||||||
use(a, b, c, d)
|
use(a, b, c, d)
|
||||||
}
|
}
|
||||||
|
|||||||
+10
@@ -0,0 +1,10 @@
|
|||||||
|
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||||
|
|
||||||
|
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||||
|
fun <T> foo(): @kotlin.internal.NoInfer T = TODO()
|
||||||
|
|
||||||
|
fun <K> bar(k: K) {}
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
bar(foo<Int>())
|
||||||
|
}
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public fun </*0*/ K> bar(/*0*/ k: K): kotlin.Unit
|
||||||
|
@kotlin.Suppress(names = {"INVISIBLE_MEMBER", "INVISIBLE_REFERENCE"}) public fun </*0*/ T> foo(): T
|
||||||
|
public fun test(): kotlin.Unit
|
||||||
Reference in New Issue
Block a user