[FIR] Support completion of lambdas with type variable as expected type
#KT-37310 Fixed #KT-37304 Fixed
This commit is contained in:
+1
-1
@@ -6,7 +6,7 @@ fun testLambda() {
|
||||
if (x is String) return@myRun { it -> x.length <!AMBIGUITY!>+<!> it }
|
||||
if (x !is Int) return@myRun { it -> it }
|
||||
|
||||
{ it -> x <!AMBIGUITY!>+<!> it }
|
||||
{ it -> x + it }
|
||||
}
|
||||
|
||||
val twoLambda: (Int) -> Int = myRun {
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
//KT-3184 Type inference seems partially broken
|
||||
package a
|
||||
|
||||
import java.util.HashMap
|
||||
|
||||
private fun <T> test(value: T, extf: String.(value: T)->Unit) {
|
||||
"".extf(value)
|
||||
}
|
||||
|
||||
fun main() {
|
||||
test(1, {value -> println(value)})
|
||||
}
|
||||
|
||||
fun tests() {
|
||||
val dict = HashMap<String, (String) -> Unit>()
|
||||
<!INAPPLICABLE_CANDIDATE!>dict["0"] = { str -> println(str) }<!>
|
||||
<!INAPPLICABLE_CANDIDATE!>dict["1"] = { println(<!UNRESOLVED_REFERENCE!>it<!>) }<!>
|
||||
|
||||
dict.<!INAPPLICABLE_CANDIDATE!>set<!>("1", { println(<!UNRESOLVED_REFERENCE!>it<!>) })
|
||||
<!INAPPLICABLE_CANDIDATE!>dict["1"] = { r -> println(r) }<!>
|
||||
}
|
||||
|
||||
// from standard library
|
||||
operator fun <K, V> MutableMap<K, V>.set(key : K, value : V) : V? = this.put(key, value)
|
||||
|
||||
fun println(message : Any?) = System.out.println(message)
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
//KT-3184 Type inference seems partially broken
|
||||
package a
|
||||
|
||||
|
||||
-37
@@ -1,37 +0,0 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER
|
||||
|
||||
class B {
|
||||
class Builder
|
||||
}
|
||||
|
||||
typealias ApplyRestrictions = B.Builder.() -> B.Builder
|
||||
|
||||
fun applyRestrictions1(): ApplyRestrictions = TODO()
|
||||
fun applyRestrictions2() = applyRestrictions1()
|
||||
fun <K> applyRestrictions3(e: K) = applyRestrictions1()
|
||||
|
||||
fun buildB() {
|
||||
val a1 = applyRestrictions1()
|
||||
val a2 = applyRestrictions2()
|
||||
val a3 = applyRestrictions3("foo")
|
||||
|
||||
B.Builder().a1()
|
||||
B.Builder().a2()
|
||||
B.Builder().a3()
|
||||
}
|
||||
|
||||
// additional example from #KT-34820
|
||||
|
||||
class R
|
||||
class P
|
||||
|
||||
typealias F = R.(P) -> Unit
|
||||
|
||||
fun guess(): F? = TODO()
|
||||
fun consume(f: F) {}
|
||||
|
||||
fun problem() {
|
||||
val p = guess()
|
||||
<!INAPPLICABLE_CANDIDATE!>consume<!>(p ?: {})
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER
|
||||
|
||||
|
||||
Reference in New Issue
Block a user