// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_ANONYMOUS_PARAMETER import kotlin.reflect.* fun id(x: T) = x fun select(vararg x: T) = x[0] fun foo(x: Int) {} fun foo2(x: Number) {} fun foo3(x: Int) {} fun foo3(x: Number) {} interface A interface B fun foo4(x: A) {} fun foo4(x: B) {} interface C: A, B fun foo5(x: A) {} fun foo5(x: B) {} fun foo5(x: C) {} fun Unit> selectNumber(vararg x: T) = x[0] fun foo6(x: Int) {} fun foo6(x: Float) {} fun foo6(x: Number) {} fun main() { select(::foo, { it }) select(id(::foo), { x: Number -> }, { it }) val x1 = select(")!>id(::foo), kotlin.Number")!>id { x: Number -> x }) kotlin.Any")!>x1 val x11 = select(id(::foo), id { x: Number -> }, id { it }) kotlin.Any")!>x11 select(id(::foo2), id { x: Int -> }, id { it }) select(id(")!>::foo3), id { x: Int -> }, id { it }) select(id(")!>::foo3), id { x: Number -> }, id { it }) select(id(")!>::foo3), id { x: Number -> }, id { x: Int -> }, id { it }) select(id(")!>::foo4), id { x: A -> }, id { it }) select(id(")!>::foo4), id { x: B -> }, id { it }) // Expected ambiguity select(id(::foo4), id { x: A -> }, id { x: B -> }, id { it }) select(id(::foo5), id { x: A -> }, id { x: B -> }, id { it }) val x2: (Int) -> Unit = selectNumber(id(::foo6), id { x -> & Number}")!>x }, id { & Number}")!>it }) }