[FIR-TEST] Add new testdata generated after changes in previous commit
This commit is contained in:
+11
@@ -0,0 +1,11 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun foo(x: Int) {}
|
||||
fun foo(y: String) {}
|
||||
|
||||
fun <T> bar(f: (T) -> Unit) {}
|
||||
|
||||
fun test() {
|
||||
bar(<!UNRESOLVED_REFERENCE!>::foo<!>)
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun fun1() {}
|
||||
fun fun1(x: Int) {}
|
||||
|
||||
val ref1 = <!UNRESOLVED_REFERENCE!>::fun1<!>
|
||||
|
||||
fun fun2(vararg x: Int) {}
|
||||
fun fun2(x: Int) {}
|
||||
|
||||
val ref2 = <!UNRESOLVED_REFERENCE!>::fun2<!>
|
||||
|
||||
fun fun3(x0: Int, vararg xs: Int) {}
|
||||
fun fun3(x0: String, vararg xs: String) {}
|
||||
|
||||
val ref3 = <!UNRESOLVED_REFERENCE!>::fun3<!>
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
|
||||
|
||||
fun foo(s: String) {}
|
||||
|
||||
object Scope {
|
||||
fun foo(a: Int) {}
|
||||
fun foo(b: Boolean) {}
|
||||
|
||||
fun <T> bar(f: (T) -> Unit): T = TODO()
|
||||
|
||||
fun test() {
|
||||
val s: String = bar(::foo)
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun foo() {}
|
||||
fun foo(s: String) {}
|
||||
|
||||
fun fn(f: () -> Unit) {}
|
||||
|
||||
fun test() {
|
||||
fn(::foo)
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun <T> ofType(x: T): T = x
|
||||
|
||||
fun foo() {}
|
||||
fun foo(s: String) {}
|
||||
|
||||
val x1 = ofType<() -> Unit>(::foo)
|
||||
val x2 = ofType<(String) -> Unit>(::foo)
|
||||
val x3 = <!INAPPLICABLE_CANDIDATE!>ofType<!><(Int) -> Unit>(<!UNRESOLVED_REFERENCE!>::foo<!>)
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun foo() {}
|
||||
fun foo(s: String) {}
|
||||
|
||||
val x1 = <!UNRESOLVED_REFERENCE!>::foo<!>
|
||||
val x2: () -> Unit = ::foo
|
||||
val x3: (String) -> Unit = ::foo
|
||||
val x4: (Int) -> Unit = <!UNRESOLVED_REFERENCE!>::foo<!>
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_EXPRESSION
|
||||
|
||||
class A {
|
||||
fun foo(i: A) {}
|
||||
|
||||
fun baz(i: A) {}
|
||||
}
|
||||
|
||||
class B {
|
||||
fun foo(s: B) {}
|
||||
fun foo(c: Char) {}
|
||||
|
||||
fun baz(s: B) {}
|
||||
}
|
||||
|
||||
fun <T> bar(f: (T) -> Unit): T = TODO()
|
||||
|
||||
fun test() {
|
||||
myWith(A()) {
|
||||
val t1 = bar(::foo)
|
||||
t1
|
||||
|
||||
val t2 = bar(::baz)
|
||||
t2
|
||||
|
||||
myWith(B()) {
|
||||
val a: A = bar(::foo)
|
||||
val b: B = bar(::foo)
|
||||
|
||||
val t3 = bar(::baz)
|
||||
t3
|
||||
|
||||
bar(<!UNRESOLVED_REFERENCE!>::foo<!>)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline fun <T, R> myWith(receiver: T, block: T.() -> R): R = TODO()
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun test() {
|
||||
foo(String::extensionReceiver)
|
||||
foo(::valueParameter)
|
||||
}
|
||||
|
||||
fun CharSequence.extensionReceiver(): CharSequence = TODO()
|
||||
fun String.extensionReceiver(): String = TODO()
|
||||
|
||||
fun valueParameter(c: CharSequence): CharSequence = TODO()
|
||||
fun valueParameter(s: String): CharSequence = TODO()
|
||||
|
||||
fun <R> foo(f: (String) -> R) {}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
import kotlin.reflect.KProperty1
|
||||
|
||||
class Inv<T>
|
||||
|
||||
fun <T, R : Number> foo(prop: KProperty1<T, R>, p: String = "") {}
|
||||
|
||||
fun <T, R> foo(prop: KProperty1<T, Inv<R>>, p: Int = 42) {}
|
||||
|
||||
class A {
|
||||
val prop = 42
|
||||
}
|
||||
|
||||
fun test() {
|
||||
foo(A::prop)
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION
|
||||
|
||||
interface Parent
|
||||
interface Child1 : Parent
|
||||
interface Child2 : Parent
|
||||
|
||||
fun foo(): Child1 = TODO()
|
||||
fun bar(): Child2 = TODO()
|
||||
|
||||
fun <K> select(x: K, y: K): K = TODO()
|
||||
|
||||
fun test() {
|
||||
val a = select(::foo, ::bar)
|
||||
a
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
class Klass {
|
||||
constructor(a: Int) {}
|
||||
constructor(a: String) {}
|
||||
}
|
||||
|
||||
fun user(f: (Int) -> Klass) {}
|
||||
|
||||
fun fn() {
|
||||
user(::Klass)
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_EXPRESSION
|
||||
|
||||
interface A
|
||||
interface B
|
||||
|
||||
fun multiple(a: A) {}
|
||||
fun multiple(b: B) {}
|
||||
|
||||
fun singleA(a: A) {}
|
||||
fun singleB(a: B) {}
|
||||
|
||||
fun <T> foo(f: (T) -> Unit, g: (T) -> Unit): T = TODO()
|
||||
|
||||
fun test() {
|
||||
val a1 = foo(::singleA, ::multiple)
|
||||
a1
|
||||
|
||||
val a2 = foo(::singleB, ::multiple)
|
||||
a2
|
||||
|
||||
val a3 = foo(::multiple, ::singleA)
|
||||
a3
|
||||
|
||||
val a4 = foo(::multiple, ::singleB)
|
||||
a4
|
||||
|
||||
val a5 = foo(::singleA, ::singleA)
|
||||
a5
|
||||
|
||||
val a6 = foo(::singleA, ::singleB)
|
||||
a6
|
||||
|
||||
foo(<!UNRESOLVED_REFERENCE!>::multiple<!>, <!UNRESOLVED_REFERENCE!>::multiple<!>)
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// !LANGUAGE: -NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
open class A
|
||||
class B : A()
|
||||
|
||||
class Or(left: A, right: A) : A()
|
||||
|
||||
class Out<out T>
|
||||
|
||||
fun test(ls: Out<B>) {
|
||||
ls.reduce(::Or)
|
||||
}
|
||||
|
||||
fun <S, T : S> Out<T>.reduce(operation: (S, T) -> S): S = TODO()
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER, -UNUSED_VARIABLE
|
||||
|
||||
abstract class A {
|
||||
inner class InnerInA
|
||||
}
|
||||
|
||||
abstract class B : A()
|
||||
|
||||
fun foo(a: A) {
|
||||
if (a is B) {
|
||||
val v = a::InnerInA
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
import kotlin.reflect.KCallable
|
||||
|
||||
class Foo {
|
||||
fun <T> installRoute(handler: T) where T : (String) -> Any?, T : KCallable<*> {
|
||||
}
|
||||
|
||||
fun <T> installRoute(handler: T) where T : () -> Any?, T : KCallable<*> {
|
||||
}
|
||||
|
||||
fun foo() {
|
||||
<!INAPPLICABLE_CANDIDATE!>installRoute<!><Any>(::route)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun route(s: String): Any? = null
|
||||
@@ -0,0 +1,19 @@
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER
|
||||
// KT-10036 Ambiguous overload cannot be resolved when using a member function reference in Beta 2, that worked in Beta 1
|
||||
|
||||
class OverloadTest {
|
||||
fun foo(bar: Boolean) {}
|
||||
fun foo(bar: Any?) {}
|
||||
}
|
||||
|
||||
object Literal
|
||||
|
||||
inline fun <T : Any> OverloadTest.overload(value: T?, function: OverloadTest.(T) -> Unit) {
|
||||
if (value == null) foo(Literal) else <!INAPPLICABLE_CANDIDATE!>function<!>(value)
|
||||
}
|
||||
|
||||
// Overload resolution ambiguity
|
||||
fun OverloadTest.overloadBoolean(value: Boolean?) = overload(value, OverloadTest::foo)
|
||||
|
||||
// Works fine
|
||||
fun OverloadTest.overloadBoolean2(value: Boolean?) = overload(value) { foo(it) }
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER
|
||||
|
||||
class OverloadTest {
|
||||
fun foo(bar: Boolean) {}
|
||||
fun foo(bar: Any?) {}
|
||||
}
|
||||
|
||||
inline fun <T : Any> OverloadTest.overload(value: T?, function: (T) -> Unit) {
|
||||
}
|
||||
|
||||
fun OverloadTest.overloadBoolean(value: Boolean?) = overload(value, OverloadTest()::foo)
|
||||
@@ -0,0 +1,9 @@
|
||||
// KT-12338 Compiler error ERROR: Rewrite at slice LEXICAL_SCOPE key: REFERENCE_EXPRESSION with when and function references
|
||||
|
||||
fun a() { }
|
||||
|
||||
fun test() {
|
||||
when {
|
||||
true -> ::a
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// KT-12751 Type inference failed with forEach and bound reference
|
||||
|
||||
class L<out T>
|
||||
|
||||
fun <T> L<T>.foo(action: (T) -> Unit): Unit {}
|
||||
|
||||
class B {
|
||||
fun remove(charSequence: CharSequence) {}
|
||||
}
|
||||
|
||||
fun foo(list: L<CharSequence>, b: B) {
|
||||
list.foo(b::remove)
|
||||
list.foo<CharSequence>(b::remove)
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
|
||||
|
||||
// KT-8596 Rewrite at slice LEXICAL_SCOPE for nested class constructor reference in an argument position
|
||||
|
||||
class K {
|
||||
class Nested
|
||||
}
|
||||
|
||||
fun foo(f: Any) {}
|
||||
|
||||
fun test1() {
|
||||
foo(K::Nested)
|
||||
}
|
||||
|
||||
// KT-10567 Error: Rewrite at slice LEXICAL_SCOPE key: REFERENCE_EXPRESSION
|
||||
|
||||
class Foo(val a: String, val b: String)
|
||||
|
||||
fun test2() {
|
||||
val prop : Foo.() -> String = if (true) {
|
||||
<!UNRESOLVED_REFERENCE!>Foo::a<!>
|
||||
} else {
|
||||
<!UNRESOLVED_REFERENCE!>Foo::b<!>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION
|
||||
|
||||
open class A
|
||||
class B: A()
|
||||
|
||||
fun A.foo() {}
|
||||
fun B.foo() {} // more specific
|
||||
|
||||
fun bar(a: Any) {}
|
||||
fun bar(a: Int) {} // more specific
|
||||
|
||||
fun test() {
|
||||
<!UNRESOLVED_REFERENCE!>B::foo<!>
|
||||
::bar
|
||||
}
|
||||
compiler/testData/diagnostics/tests/callableReference/resolve/moreSpecificAmbiguousExtensions.fir.kt
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
|
||||
|
||||
interface IA
|
||||
interface IB : IA
|
||||
|
||||
fun IA.extFun(x: IB) {}
|
||||
fun IB.extFun(x: IA) {}
|
||||
|
||||
fun test() {
|
||||
val extFun1 = IA::extFun
|
||||
val extFun2 = IB::extFun
|
||||
}
|
||||
|
||||
fun testWithExpectedType() {
|
||||
val extFun_AB_A: IA.(IB) -> Unit = IA::extFun
|
||||
val extFun_AA_B: IA.(IA) -> Unit = IB::extFun
|
||||
val extFun_BB_A: IB.(IB) -> Unit = IA::extFun
|
||||
val extFun_BA_B: IB.(IA) -> Unit = IB::extFun
|
||||
val extFun_BB_B: IB.(IB) -> Unit = IB::extFun
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
interface IA
|
||||
interface IB : IA
|
||||
|
||||
fun IA.extFun() {}
|
||||
fun IB.extFun() {}
|
||||
|
||||
fun test() {
|
||||
val extFun = <!UNRESOLVED_REFERENCE!>IB::extFun<!>
|
||||
<!INAPPLICABLE_CANDIDATE!>checkSubtype<!><IB.() -> Unit>(extFun)
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
interface Base
|
||||
class Inv<K> : Base
|
||||
|
||||
fun foo(x: Int): Inv<Int> = TODO()
|
||||
fun foo(y: String): Inv<String> = TODO()
|
||||
|
||||
fun <T, R : Number> bar(f: (T) -> Inv<R>, p: String = "") {}
|
||||
|
||||
fun <T, R : Base> bar(f: (T) -> Inv<R>, p: Int = 4) {}
|
||||
|
||||
fun test() {
|
||||
bar(::foo)
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
import kotlin.reflect.KProperty0
|
||||
import kotlin.reflect.KProperty1
|
||||
|
||||
fun <R> property(property: KProperty0<R>): Int = 1
|
||||
fun <T, R> property(property: KProperty1<T, R>): String = ""
|
||||
|
||||
val subject = ""
|
||||
|
||||
class O {
|
||||
val subject = ""
|
||||
}
|
||||
|
||||
val someProperty0 = property(::subject)
|
||||
val someProperty1 = property(O::subject)
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
// !CHECK_TYPE
|
||||
// KT-12322 Overload resolution ambiguity with constructor references when class has a companion object
|
||||
|
||||
class Foo {
|
||||
companion object
|
||||
}
|
||||
|
||||
fun test() {
|
||||
val a = ::Foo
|
||||
checkSubtype<() -> Foo>(a)
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION
|
||||
import kotlin.reflect.KFunction1
|
||||
|
||||
open class A {
|
||||
open fun bar() {}
|
||||
|
||||
fun bas() {}
|
||||
}
|
||||
class B: A() {
|
||||
override fun bar() {}
|
||||
|
||||
fun bas(i: Int) {}
|
||||
}
|
||||
|
||||
fun A.foo() {}
|
||||
fun B.foo() {}
|
||||
|
||||
fun fas() {}
|
||||
fun fas(i: Int = 1) {}
|
||||
|
||||
fun test() {
|
||||
<!UNRESOLVED_REFERENCE!>B::foo<!> // todo KT-9601 Chose maximally specific function in callable reference
|
||||
|
||||
B::bar checkType { <!UNRESOLVED_REFERENCE!>_<!><KFunction1<B, Unit>>() }
|
||||
|
||||
<!UNRESOLVED_REFERENCE!>B::bas<!>
|
||||
|
||||
<!UNRESOLVED_REFERENCE!>::fas<!>
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// KT-12799 Bound callable references not resolved for overload
|
||||
|
||||
class C {
|
||||
fun xf1(){}
|
||||
fun xf1(s: String){}
|
||||
}
|
||||
|
||||
fun foo(p: (String) -> Unit){}
|
||||
|
||||
fun bar(c: C) {
|
||||
foo(c::xf1)
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION
|
||||
// KT-9601 Chose maximally specific function in callable reference
|
||||
|
||||
open class A {
|
||||
fun foo(a: Any) {}
|
||||
fun fas(a: Int) {}
|
||||
}
|
||||
class B: A() {
|
||||
fun foo(a: Int) {}
|
||||
fun fas(a: Any) {}
|
||||
}
|
||||
|
||||
fun test() {
|
||||
B::foo
|
||||
B::fas
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
|
||||
|
||||
interface A
|
||||
interface B
|
||||
|
||||
fun foo(i: A) {}
|
||||
fun foo(b: B) {}
|
||||
|
||||
fun <T> bar1(f: (T) -> Unit): T = TODO()
|
||||
fun <T> bar2(f: (T) -> Unit, e: T) {}
|
||||
|
||||
fun test(a: A, b: B) {
|
||||
val expectedType1: A = bar1(::foo)
|
||||
val expectedType2: B = bar1(::foo)
|
||||
|
||||
bar2(::foo, a)
|
||||
bar2(::foo, b)
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
interface A
|
||||
interface B
|
||||
|
||||
fun fooB(b: B) {}
|
||||
|
||||
fun <T> bar(f: (T) -> Unit, e: T) {}
|
||||
fun <T> baz(e: T, f: (T) -> Unit) {}
|
||||
|
||||
fun test(a: A, b: B) {
|
||||
// Note that diagnostic is always on callable references as they are resolved after simple arguments
|
||||
<!INAPPLICABLE_CANDIDATE!>baz<!>(a, ::fooB)
|
||||
<!INAPPLICABLE_CANDIDATE!>bar<!>(::fooB, a)
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
|
||||
interface Base
|
||||
|
||||
fun <K> materialize(): K = TODO()
|
||||
|
||||
fun <T : Base> Base.transform(): T = materialize()
|
||||
|
||||
fun test(child: Base) {
|
||||
child == child.transform()
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
import kotlin.reflect.*
|
||||
|
||||
class A {
|
||||
val x = 1
|
||||
fun x() {}
|
||||
}
|
||||
|
||||
fun f1(): KProperty<Int> = A::x // ok, property
|
||||
fun f2(): (A) -> Unit = A::x // ok, function
|
||||
@@ -0,0 +1,10 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun foo() {}
|
||||
fun foo(s: String) {}
|
||||
|
||||
fun bar(f: () -> Unit) = 1
|
||||
fun bar(f: (String) -> Unit) = 2
|
||||
|
||||
val x1 = <!UNRESOLVED_REFERENCE!>::foo<!> as () -> Unit
|
||||
val x2 = bar(::foo as (String) -> Unit)
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER, -EXTENSION_SHADOWED_BY_MEMBER
|
||||
|
||||
import kotlin.reflect.*
|
||||
|
||||
fun <T> ofType(x: T): T = x
|
||||
|
||||
class A {
|
||||
val foo: Int = 0
|
||||
fun foo() {}
|
||||
|
||||
fun bar() {}
|
||||
val bar: Int = 0
|
||||
}
|
||||
|
||||
fun A.foo(): String = "A"
|
||||
|
||||
val x0 = A::foo
|
||||
|
||||
val x1 = ofType<(A) -> Unit>(A::foo)
|
||||
val x2 = ofType<KProperty1<A, Int>>(A::foo)
|
||||
val x3: KProperty1<A, Int> = A::foo
|
||||
val x4: (A) -> String = A::foo
|
||||
|
||||
val y0 = A::bar
|
||||
val y1 = ofType<(A) -> Unit>(A::bar)
|
||||
val y2 = ofType<KProperty1<A, Int>>(A::bar)
|
||||
val y3: KProperty1<A, Int> = A::bar
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// NI_EXPECTED_FILE
|
||||
|
||||
fun <T, R> apply(x: T, f: (T) -> R): R = f(x)
|
||||
|
||||
fun foo(i: Int) {}
|
||||
fun foo(s: String) {}
|
||||
|
||||
val x1 = apply(1, ::foo)
|
||||
val x2 = apply("hello", ::foo)
|
||||
val x3 = <!INAPPLICABLE_CANDIDATE!>apply<!>(true, <!UNRESOLVED_REFERENCE!>::foo<!>)
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER,-CONFLICTING_JVM_DECLARATIONS
|
||||
// NI_EXPECTED_FILE
|
||||
|
||||
fun foo(i: Int) = "$i"
|
||||
fun foo(s: String) = s
|
||||
|
||||
fun bar(s: String) = s
|
||||
|
||||
fun qux(i: Int, j: Int, k: Int): Int = i + j + k
|
||||
fun qux(a: String, b: String, c: String, d: String) {}
|
||||
|
||||
fun fn1(x: Int, f1: (Int) -> String, f2: (String) -> String) = f2(f1(x))
|
||||
|
||||
fun fn2(f1: (Int) -> String, f2: (String) -> String ) = f2(f1(0))
|
||||
fun fn2(f1: (Int) -> Int, f2: (Int) -> String ) = f2(f1(0))
|
||||
fun fn2(f1: (String) -> String, f2: (String) -> String ) = f2(f1(""))
|
||||
|
||||
fun fn3(i: Int, f: (Int, Int, Int) -> Int): Int = f(i, i, i)
|
||||
|
||||
val x1 = fn1(1, ::foo, ::foo)
|
||||
val x2 = fn1(1, ::foo, ::bar)
|
||||
|
||||
val x3 = fn2(::bar, ::foo)
|
||||
val x4 = <!AMBIGUITY!>fn2<!>(<!UNRESOLVED_REFERENCE!>::foo<!>, ::bar)
|
||||
val x5 = <!AMBIGUITY!>fn2<!>(<!UNRESOLVED_REFERENCE!>::foo<!>, <!UNRESOLVED_REFERENCE!>::foo<!>)
|
||||
|
||||
val x6 = fn3(1, ::qux)
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun foo(vararg ii: Int) {}
|
||||
fun foo(vararg ss: String) {}
|
||||
fun foo(i: Int) {}
|
||||
|
||||
val fn1: (Int) -> Unit = ::foo
|
||||
val fn2: (IntArray) -> Unit = ::foo
|
||||
val fn3: (Int, Int) -> Unit = <!UNRESOLVED_REFERENCE!>::foo<!>
|
||||
val fn4: (Array<String>) -> Unit = ::foo
|
||||
Reference in New Issue
Block a user