[NI] Improve completing calls with multiple postponed arguments

#KT-27999 Fixed
#KT-30244 Fixed
#KT-31102 Fixed
This commit is contained in:
Dmitriy Novozhilov
2019-12-25 15:25:57 +03:00
parent 0aa527347d
commit 0c01499d98
14 changed files with 206 additions and 46 deletions
@@ -0,0 +1,32 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_ANONYMOUS_PARAMETER
fun <K> select(x: K, y: K): K = x
fun <K> select3(x: K, y: K, z: K): K = x
interface A
interface B
fun test() {
select3(
{ a: A, b: A -> Unit },
{ b, a -> Unit },
{ <!UNRESOLVED_REFERENCE!>it<!>; Unit }
)
}
// ISSUE: KT-27999
// ISSUE: KT-30244
fun test_1() {
select(
{ 1 },
{ "" }
)
}
// ISSUE: KT-31102
fun bar(): Int = 1
fun test_2(x: Int) {
val f1: () -> Int = select({ bar() }, ::bar) // TYPE_MISMATCH on lambda
val f2 = select({ bar() }, ::bar) // Same
}
@@ -0,0 +1,32 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_ANONYMOUS_PARAMETER
fun <K> select(x: K, y: K): K = x
fun <K> select3(x: K, y: K, z: K): K = x
interface A
interface B
fun test() {
<!DEBUG_INFO_EXPRESSION_TYPE("(A, A) -> kotlin.Unit")!>select3(
{ a: A, b: A -> Unit },
{ b, a -> Unit },
<!EXPECTED_PARAMETERS_NUMBER_MISMATCH!>{<!> <!UNRESOLVED_REFERENCE!>it<!>; Unit }
)<!>
}
// ISSUE: KT-27999
// ISSUE: KT-30244
fun test_1() {
<!DEBUG_INFO_EXPRESSION_TYPE("() -> {Comparable<{Int & String}> & java.io.Serializable}")!>select(
{ 1 },
{ "" }
)<!>
}
// ISSUE: KT-31102
fun bar(): Int = 1
fun test_2(x: Int) {
val f1: () -> Int = select({ bar() }, ::bar) // TYPE_MISMATCH on lambda
val f2 = select({ bar() }, ::bar) // Same
}
@@ -0,0 +1,20 @@
package
public fun bar(): kotlin.Int
public fun </*0*/ K> select(/*0*/ x: K, /*1*/ y: K): K
public fun </*0*/ K> select3(/*0*/ x: K, /*1*/ y: K, /*2*/ z: K): K
public fun test(): kotlin.Unit
public fun test_1(): kotlin.Unit
public fun test_2(/*0*/ x: kotlin.Int): kotlin.Unit
public interface A {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public interface B {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -5,8 +5,8 @@ fun <K> select2(x: K, y: K): K = TODO()
fun <K> select3(x: K, y: K, z: K): K = TODO()
fun test2(f: ((String) -> Int)?) {
val a0: ((Int) -> Int)? = select2(<!TYPE_MISMATCH!>{ <!OI;CANNOT_INFER_PARAMETER_TYPE!>it<!> -> <!OI;DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>it<!> }<!>, null)
val b0: ((Nothing) -> Unit)? = select2(<!TYPE_MISMATCH!>{ <!OI;CANNOT_INFER_PARAMETER_TYPE!>it<!> -> <!OI;DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>it<!> }<!>, null)
val a0: ((Int) -> Int)? = select2(<!OI;TYPE_MISMATCH!>{ <!OI;CANNOT_INFER_PARAMETER_TYPE!>it<!> -> <!OI;DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>it<!> }<!>, null)
val b0: ((Nothing) -> Unit)? = select2(<!OI;TYPE_MISMATCH!>{ <!OI;CANNOT_INFER_PARAMETER_TYPE!>it<!> -> <!NI;UNUSED_EXPRESSION, OI;DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>it<!> }<!>, null)
select3({ it.length }, f, null)
}