Files
kotlin-fork/compiler/testData/diagnostics/tests/functionLiterals/destructuringInLambdas/complexInference.fir.kt
T
Tianyu Geng fb14b03824 FIR checker: skip error named reference if receiver is unresolved
Currently, FIR reports errors caused by previous resolution failure. For
example with unresolved `a` and `b` in code `a.b`, both `a` and `b` are
highlighted. FE1.0 only highlights `a` since it's the root cause. This
change applies this heuristics when reporting FirDiagnostics.
2021-03-29 12:45:27 +03:00

49 lines
1.6 KiB
Kotlin
Vendored

// !WITH_NEW_INFERENCE
// !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) ->
<!UNRESOLVED_REFERENCE!>a<!> checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Int>() }
<!UNRESOLVED_REFERENCE!>b<!> checkType { <!INAPPLICABLE_CANDIDATE!>_<!><String>() }
c checkType { _<Double>() }
d checkType { _<Short>() }
}
foo(bInstance) {
(a, b), (c, d) ->
<!UNRESOLVED_REFERENCE!>a<!> checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Int>() }
<!UNRESOLVED_REFERENCE!>b<!> checkType { <!INAPPLICABLE_CANDIDATE!>_<!><String>() }
c checkType { _<Double>() }
d checkType { _<Short>() }
}
foo<A, B>(bInstance) {
(a, b), (c, d) ->
<!UNRESOLVED_REFERENCE!>a<!> checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Int>() }
<!UNRESOLVED_REFERENCE!>b<!> checkType { <!INAPPLICABLE_CANDIDATE!>_<!><String>() }
c checkType { _<Double>() }
d checkType { _<Short>() }
}
}