KT-9371 Callable reference resolve should not prefer one of the overloads by some magic reasons
#KT-9371 Fixed
This commit is contained in:
+1
-1
@@ -7,4 +7,4 @@ fun foo(s: String) {}
|
||||
|
||||
val x1 = ofType<() -> Unit>(::foo)
|
||||
val x2 = ofType<(String) -> Unit>(::foo)
|
||||
val x3 = ofType<(Int) -> Unit>(<!TYPE_MISMATCH!>::foo<!>)
|
||||
val x3 = ofType<(Int) -> Unit>(::<!NONE_APPLICABLE!>foo<!>)
|
||||
@@ -3,7 +3,7 @@
|
||||
fun foo() {}
|
||||
fun foo(s: String) {}
|
||||
|
||||
val x1 = ::foo
|
||||
val x1 = ::<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!>
|
||||
val x2: () -> Unit = ::foo
|
||||
val x3: (String) -> Unit = ::foo
|
||||
val x4: (Int) -> Unit = <!TYPE_MISMATCH!>::foo<!>
|
||||
val x4: (Int) -> Unit = ::<!NONE_APPLICABLE!>foo<!>
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package
|
||||
|
||||
public val x1: kotlin.reflect.KFunction0<kotlin.Unit>
|
||||
public val x1: [ERROR : Type for ::foo]
|
||||
public val x2: () -> kotlin.Unit
|
||||
public val x3: (kotlin.String) -> kotlin.Unit
|
||||
public val x4: (kotlin.Int) -> kotlin.Unit
|
||||
|
||||
@@ -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() {
|
||||
B::<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!> // todo KT-9601 Chose maximally specific function in callable reference
|
||||
|
||||
B::bar checkType { _<KFunction1<B, Unit>>() }
|
||||
|
||||
B::<!OVERLOAD_RESOLUTION_AMBIGUITY!>bas<!>
|
||||
|
||||
::<!OVERLOAD_RESOLUTION_AMBIGUITY!>fas<!>
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package
|
||||
|
||||
public fun fas(): kotlin.Unit
|
||||
public fun fas(/*0*/ i: kotlin.Int = ...): kotlin.Unit
|
||||
public fun test(): kotlin.Unit
|
||||
public fun A.foo(): kotlin.Unit
|
||||
public fun B.foo(): kotlin.Unit
|
||||
|
||||
public open class A {
|
||||
public constructor A()
|
||||
public open fun bar(): kotlin.Unit
|
||||
public final fun bas(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class B : A {
|
||||
public constructor B()
|
||||
public open override /*1*/ fun bar(): kotlin.Unit
|
||||
public final override /*1*/ /*fake_override*/ fun bas(): kotlin.Unit
|
||||
public final fun bas(/*0*/ i: kotlin.Int): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+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::<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!>
|
||||
B::<!OVERLOAD_RESOLUTION_AMBIGUITY!>fas<!>
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package
|
||||
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
public open class A {
|
||||
public constructor A()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun fas(/*0*/ a: kotlin.Int): kotlin.Unit
|
||||
public final fun foo(/*0*/ a: kotlin.Any): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class B : A {
|
||||
public constructor B()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun fas(/*0*/ a: kotlin.Any): kotlin.Unit
|
||||
public final override /*1*/ /*fake_override*/ fun fas(/*0*/ a: kotlin.Int): kotlin.Unit
|
||||
public final override /*1*/ /*fake_override*/ fun foo(/*0*/ a: kotlin.Any): kotlin.Unit
|
||||
public final fun foo(/*0*/ a: kotlin.Int): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
@@ -6,5 +6,5 @@ fun foo(s: String) {}
|
||||
fun bar(f: () -> Unit) = 1
|
||||
fun bar(f: (String) -> Unit) = 2
|
||||
|
||||
val x1 = ::foo <!USELESS_CAST!>as () -> Unit<!>
|
||||
val x2 = bar(<!UNCHECKED_CAST!>::foo as (String) -> Unit<!>)
|
||||
val x1 = ::<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!> as () -> Unit
|
||||
val x2 = bar(::<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!> as (String) -> Unit)
|
||||
+1
-1
@@ -6,5 +6,5 @@ fun foo(i: Int) {}
|
||||
|
||||
val fn1: (Int) -> Unit = ::foo
|
||||
val fn2: (IntArray) -> Unit = ::foo
|
||||
val fn3: (Int, Int) -> Unit = <!TYPE_MISMATCH!>::foo<!>
|
||||
val fn3: (Int, Int) -> Unit = ::<!NONE_APPLICABLE!>foo<!>
|
||||
val fn4: (Array<String>) -> Unit = ::foo
|
||||
Reference in New Issue
Block a user