Files
kotlin-fork/compiler/testData/diagnostics/tests/functionLiterals/destructuringInLambdas/complexInference.fir.kt
T
Denis.Zharkov 2ecba6ac39 Remove WITH_NEW_INFERENCE directive from all tests
This directive anyway does not make test run twice with OI, and with NI
It only once run the test with specific settings (// LANGUAGE)
and ignores irrelevant (OI or NI tags)
2021-05-25 13:28:26 +03:00

48 lines
1.4 KiB
Kotlin
Vendored

// !CHECK_TYPE
// !DIAGNOSTICS: -UNUSED_PARAMETER
data class A(val x: Int, val y: String)
data class B(val u: Double, val w: Short)
// first parameter of the functional type of 'x' can only be inferred from a lambda parameter explicit type specification
fun <X, Y> foo(y: Y, x: (X, Y) -> Unit) {}
fun bar(aInstance: A, bInstance: B) {
foo("") {
(a, b): A, c ->
a checkType { _<Int>() }
b checkType { _<String>() }
c checkType { _<String>() }
}
foo(aInstance) {
a: String, (b, c) ->
a checkType { _<String>() }
b checkType { _<Int>() }
c checkType { _<String>() }
}
foo(bInstance) {
(a, b): A, (c, d) ->
a checkType { _<Int>() }
b checkType { _<String>() }
c checkType { _<Double>() }
d checkType { _<Short>() }
}
foo(bInstance) {
<!COMPONENT_FUNCTION_MISSING, COMPONENT_FUNCTION_MISSING!>(a, b)<!>, (c, d) ->
a <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!INAPPLICABLE_CANDIDATE!>_<!><Int>() }
b <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!INAPPLICABLE_CANDIDATE!>_<!><String>() }
c checkType { _<Double>() }
d checkType { _<Short>() }
}
foo<A, B>(bInstance) {
(a, b), (c, d) ->
a checkType { _<Int>() }
b checkType { _<String>() }
c checkType { _<Double>() }
d checkType { _<Short>() }
}
}