Files
kotlin-fork/compiler/testData/diagnostics/tests/callableReference/generic/genericExtensionFunction.fir.kt
T
Dmitriy Novozhilov f283f2db43 [FIR] Improve diagnostic reporting & don't use error symbol for candidate if possible
Also introduce few new diagnostics:
- NONE_APPLICABLE more many inapplicable candidates
- HIDDEN for visible candidates
2020-07-28 20:46:56 +03:00

32 lines
1.3 KiB
Kotlin
Vendored

// !WITH_NEW_INFERENCE
// !CHECK_TYPE
// !DIAGNOSTICS: -UNUSED_PARAMETER, -UNUSED_VARIABLE
class Wrapper
fun <R, S> Wrapper.foo(x: R): S = TODO()
fun Wrapper.fooIntString(x: Int): String = ""
fun <T> Wrapper.fooReturnString(x: T): String = ""
fun <T> Wrapper.fooTakeInt(x: Int): T = TODO()
fun <T, R, S> bar(f: T.(R) -> S): Tripple<T, R, S> = TODO()
fun <T, R, S> baz(x: T, y: R, z: S, f: T.(R) -> S): Tripple<T, R, S> = TODO()
class Tripple<A, B, C>(val a: A, val b: B, val c: C)
fun test1() {
val x: Wrapper.(String) -> Boolean = Wrapper::foo
bar<Wrapper, Double, Float>(Wrapper::foo).checkType { _<Tripple<Wrapper, Double, Float>>() }
bar(Wrapper::fooIntString).checkType { _<Tripple<Wrapper, Int, String>>() }
}
fun <T> test2() {
bar<Wrapper, Int, String>(Wrapper::fooReturnString).checkType { _<Tripple<Wrapper, Int, String>>() }
bar<Wrapper, T, String>(Wrapper::fooReturnString).checkType { _<Tripple<Wrapper, T, String>>() }
<!INAPPLICABLE_CANDIDATE!>bar<!><Wrapper, T, T>(<!UNRESOLVED_REFERENCE!>Wrapper::fooReturnString<!>)
<!INAPPLICABLE_CANDIDATE!>bar<!><Wrapper, Int, Int>(<!UNRESOLVED_REFERENCE!>Wrapper::fooReturnString<!>)
bar<Wrapper, Int, T>(Wrapper::fooTakeInt).checkType { _<Tripple<Wrapper, Int, T>>() }
bar<Wrapper, Int, String>(Wrapper::fooTakeInt).checkType { _<Tripple<Wrapper, Int, String>>() }
}