[NI] Add feature for choosing candidate by lambda return type

This commit is contained in:
Dmitriy Novozhilov
2020-04-22 13:15:49 +03:00
parent f243b8946f
commit 865ddac07a
19 changed files with 429 additions and 23 deletions
@@ -0,0 +1,36 @@
// !LANGUAGE: +NewInference -FactoryPatternResolution
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_EXPRESSION
// ISSUE: KT-11265
fun create(f: (Int) -> Int): Int = 1
fun create(f: (Int) -> String): String = ""
fun takeString(s: String) {}
fun takeInt(s: Int) {}
fun test_1() {
val x = <!AMBIGUITY!>create<!> { "" }
takeString(x)
}
fun test_2() {
val x = <!AMBIGUITY!>create<!> { 1 }
takeInt(x)
}
fun test_3() {
val x = <!AMBIGUITY!>create<!> { 1.0 }
}
fun <K> create(x: K, f: (K) -> Int): Int = 1
fun <T> create(x: T, f: (T) -> String): String = ""
fun test_4() {
val x = <!AMBIGUITY!>create<!>("") { "" }
takeString(x)
}
fun test_5() {
val x = <!AMBIGUITY!>create<!>("") { 1 }
takeInt(x)
}
@@ -0,0 +1,36 @@
// !LANGUAGE: +NewInference -FactoryPatternResolution
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_EXPRESSION
// ISSUE: KT-11265
fun create(f: (Int) -> Int): Int = 1
fun create(f: (Int) -> String): String = ""
fun takeString(s: String) {}
fun takeInt(s: Int) {}
fun test_1() {
val x = <!OVERLOAD_RESOLUTION_AMBIGUITY!>create<!> { "" }
takeString(<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>x<!>)
}
fun test_2() {
val x = <!OVERLOAD_RESOLUTION_AMBIGUITY!>create<!> { 1 }
takeInt(<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>x<!>)
}
fun test_3() {
val x = <!OVERLOAD_RESOLUTION_AMBIGUITY!>create<!> { 1.0 }
}
fun <K> create(x: K, f: (K) -> Int): Int = 1
fun <T> create(x: T, f: (T) -> String): String = ""
fun test_4() {
val x = <!OVERLOAD_RESOLUTION_AMBIGUITY!>create<!>("") { "" }
takeString(<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>x<!>)
}
fun test_5() {
val x = <!OVERLOAD_RESOLUTION_AMBIGUITY!>create<!>("") { 1 }
takeInt(<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>x<!>)
}
@@ -0,0 +1,13 @@
package
public fun create(/*0*/ f: (kotlin.Int) -> kotlin.Int): kotlin.Int
public fun create(/*0*/ f: (kotlin.Int) -> kotlin.String): kotlin.String
public fun </*0*/ K> create(/*0*/ x: K, /*1*/ f: (K) -> kotlin.Int): kotlin.Int
public fun </*0*/ T> create(/*0*/ x: T, /*1*/ f: (T) -> kotlin.String): kotlin.String
public fun takeInt(/*0*/ s: kotlin.Int): kotlin.Unit
public fun takeString(/*0*/ s: kotlin.String): kotlin.Unit
public fun test_1(): kotlin.Unit
public fun test_2(): kotlin.Unit
public fun test_3(): kotlin.Unit
public fun test_4(): kotlin.Unit
public fun test_5(): kotlin.Unit
@@ -0,0 +1,36 @@
// !LANGUAGE: +NewInference +FactoryPatternResolution
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_EXPRESSION
// ISSUE: KT-11265
fun create(f: (Int) -> Int): Int = 1
fun create(f: (Int) -> String): String = ""
fun takeString(s: String) {}
fun takeInt(s: Int) {}
fun test_1() {
val x = <!AMBIGUITY!>create<!> { "" }
takeString(x)
}
fun test_2() {
val x = <!AMBIGUITY!>create<!> { 1 }
takeInt(x)
}
fun test_3() {
val x = <!AMBIGUITY!>create<!> { 1.0 }
}
fun <K> create(x: K, f: (K) -> Int): Int = 1
fun <T> create(x: T, f: (T) -> String): String = ""
fun test_4() {
val x = <!AMBIGUITY!>create<!>("") { "" }
takeString(x)
}
fun test_5() {
val x = <!AMBIGUITY!>create<!>("") { 1 }
takeInt(x)
}
@@ -0,0 +1,36 @@
// !LANGUAGE: +NewInference +FactoryPatternResolution
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_EXPRESSION
// ISSUE: KT-11265
fun create(f: (Int) -> Int): Int = 1
fun create(f: (Int) -> String): String = ""
fun takeString(s: String) {}
fun takeInt(s: Int) {}
fun test_1() {
val x = create { "" }
takeString(x)
}
fun test_2() {
val x = create { 1 }
takeInt(x)
}
fun test_3() {
val x = <!NONE_APPLICABLE!>create<!> { 1.0 }
}
fun <K> create(x: K, f: (K) -> Int): Int = 1
fun <T> create(x: T, f: (T) -> String): String = ""
fun test_4() {
val x = create("") { "" }
takeString(x)
}
fun test_5() {
val x = create("") { 1 }
takeInt(x)
}
@@ -0,0 +1,13 @@
package
public fun create(/*0*/ f: (kotlin.Int) -> kotlin.Int): kotlin.Int
public fun create(/*0*/ f: (kotlin.Int) -> kotlin.String): kotlin.String
public fun </*0*/ K> create(/*0*/ x: K, /*1*/ f: (K) -> kotlin.Int): kotlin.Int
public fun </*0*/ T> create(/*0*/ x: T, /*1*/ f: (T) -> kotlin.String): kotlin.String
public fun takeInt(/*0*/ s: kotlin.Int): kotlin.Unit
public fun takeString(/*0*/ s: kotlin.String): kotlin.Unit
public fun test_1(): kotlin.Unit
public fun test_2(): kotlin.Unit
public fun test_3(): kotlin.Unit
public fun test_4(): kotlin.Unit
public fun test_5(): kotlin.Unit