[FIR] Properly pass type attributes for inference of lambda with type variable as expected type
#KT-41989 Fixed #KT-37317 Fixed
This commit is contained in:
Vendored
+2
-2
@@ -142,8 +142,8 @@ fun main() {
|
||||
val x18: (C) -> Unit = select(id { <!DEBUG_INFO_EXPRESSION_TYPE("C")!>it<!> }, { <!DEBUG_INFO_EXPRESSION_TYPE("C")!>it<!> }, id<(B) -> Unit> { x -> x })
|
||||
|
||||
// Resolution of extension/non-extension functions combination
|
||||
val x19: String.() -> Unit = select(<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Function1<kotlin.String, kotlin.Unit>")!>id { <!DEBUG_INFO_EXPRESSION_TYPE("ERROR CLASS: 'this' is not defined in this context"), DEBUG_INFO_EXPRESSION_TYPE("ERROR CLASS: 'this' is not defined in this context"), NO_THIS!>this<!> }<!>, <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Function1<kotlin.String, kotlin.Unit>")!>id(fun(x: String) {})<!>)
|
||||
val x20: String.() -> Unit = select(<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Function1<kotlin.String, kotlin.Unit>")!>{ <!DEBUG_INFO_EXPRESSION_TYPE("ERROR CLASS: 'this' is not defined in this context"), DEBUG_INFO_EXPRESSION_TYPE("ERROR CLASS: 'this' is not defined in this context"), NO_THIS!>this<!> }<!>, (fun(x: String) {}))
|
||||
val x19: String.() -> Unit = select(<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Function1<kotlin.String, kotlin.String>")!>id { <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String"), DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>this<!> }<!>, <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Function1<kotlin.String, kotlin.Unit>")!>id(fun(x: String) {})<!>)
|
||||
val x20: String.() -> Unit = select(<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Function1<kotlin.String, kotlin.Unit>")!>{ <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String"), DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>this<!> }<!>, (fun(x: String) {}))
|
||||
val x21: String.() -> Unit = select(<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Function1<kotlin.String, kotlin.Unit>")!>id(fun(x: String) {})<!>, <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Function1<kotlin.String, kotlin.Unit>")!>id(fun(x: String) {})<!>)
|
||||
select(id<String.() -> Unit>(fun(x: String) {}), <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Function1<kotlin.String, kotlin.Unit>")!>id(fun(x: String) {})<!>)
|
||||
select(<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Function2<kotlin.String, kotlin.String, kotlin.Unit>")!>id(fun String.(x: String) {})<!>, <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Function2<kotlin.String, kotlin.String, kotlin.Unit>")!>id(fun(x: String, y: String) {})<!>)
|
||||
|
||||
+4
-4
@@ -3,14 +3,14 @@
|
||||
fun <T> select(vararg x: T) = x[0]
|
||||
|
||||
fun main() {
|
||||
val x1: String.() -> String = if (true) {{ <!NO_THIS!>this<!> }} else {{ <!NO_THIS!>this<!> }}
|
||||
val x2: String.() -> String = if (true) {{ -> <!NO_THIS!>this<!> }} else {{ -> <!NO_THIS!>this<!> }}
|
||||
val x1: String.() -> String = if (true) {{ this }} else {{ this }}
|
||||
val x2: String.() -> String = if (true) {{ -> this }} else {{ -> this }}
|
||||
val x3: () -> String = if (true) {{ -> "this" }} else {{ -> "this" }}
|
||||
val x4: String.() -> String = if (true) {{ str: String -> "this" }} else {{ str: String -> "this" }}
|
||||
val x41: String.(String) -> String = if (true) {{ str: String, str2: String -> "this" }} else {{ str: String, str2: String -> "this" }}
|
||||
val x42: String.(String) -> String = if (true) {{ str, str2 -> "this" }} else {{ str, str2 -> "this" }}
|
||||
val x5: String.() -> String = if (true) {{ str -> "this" }} else {{ str -> "this" }}
|
||||
val x6: String.() -> String = if (true) {{ str -> "this" }} else {{ "this" }}
|
||||
val x7: String.() -> String = select({ -> <!NO_THIS!>this<!> }, { -> <!NO_THIS!>this<!> })
|
||||
val x8: String.() -> String = select({ <!NO_THIS!>this<!> }, { <!NO_THIS!>this<!> })
|
||||
val x7: String.() -> String = select({ -> this }, { -> this })
|
||||
val x8: String.() -> String = select({ this }, { this })
|
||||
}
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_ANONYMOUS_PARAMETER -CAST_NEVER_SUCCEEDS
|
||||
// ISSUE: KT-36819
|
||||
|
||||
// Case 1
|
||||
|
||||
fun <K> select(vararg x: K) = x[0]
|
||||
interface A
|
||||
class B: A
|
||||
class C: A
|
||||
fun <T> id1(x: T): T = x
|
||||
fun <R> id2(x: R): R = x
|
||||
|
||||
class Out<out R>(x: R)
|
||||
|
||||
fun main() {
|
||||
val x1 = select(id1 { B() }, id2 { C() })
|
||||
val x2 = select({ B() }, { C() })
|
||||
val x3 = select(id1(Out(B())), id2(Out(C())))
|
||||
}
|
||||
|
||||
// Case 2
|
||||
|
||||
fun <R> fold(initial: R, operation: (R) -> Unit) {}
|
||||
|
||||
fun foo() {
|
||||
fold({ x: Int -> x }) { acc -> }
|
||||
}
|
||||
|
||||
// Case 3
|
||||
|
||||
class Foo
|
||||
|
||||
typealias X = Foo.(Foo.() -> Unit) -> Unit
|
||||
|
||||
fun bar() {
|
||||
val y = when {
|
||||
false -> { _ ->
|
||||
Unit
|
||||
}
|
||||
true -> null as X
|
||||
else -> { x ->
|
||||
<!UNRESOLVED_REFERENCE!>x<!>()
|
||||
Unit
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_ANONYMOUS_PARAMETER -CAST_NEVER_SUCCEEDS
|
||||
// ISSUE: KT-36819
|
||||
|
||||
Reference in New Issue
Block a user