[NI] Don't apply SAM-conversion for type that is subtype of function
Plus, don't get synthetic candidates as all candidates are creating by conversion #KT-31503 Fixed
This commit is contained in:
+2
-2
@@ -16,14 +16,14 @@ fun <T> bar(s: T) {}
|
||||
fun <T> complex(t: T, f: (T) -> Unit) {}
|
||||
|
||||
fun test1() {
|
||||
foo(1, A::invokeLater) // KT-24507 SAM conversion accidentally applied to callable reference and incorrectly handled via BE
|
||||
foo(1, <!NI;TYPE_MISMATCH!>A::invokeLater<!>) // KT-24507 SAM conversion accidentally applied to callable reference and incorrectly handled via BE
|
||||
foo(1, ::bar)
|
||||
|
||||
complex(1, ::bar)
|
||||
}
|
||||
|
||||
fun <R> test2(x: R) {
|
||||
foo(x, A::invokeLater) // KT-24507 SAM conversion accidentally applied to callable reference and incorrectly handled via BE
|
||||
foo(x, <!NI;TYPE_MISMATCH!>A::invokeLater<!>) // KT-24507 SAM conversion accidentally applied to callable reference and incorrectly handled via BE
|
||||
foo(x, ::bar)
|
||||
|
||||
complex(x, ::bar)
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
// FILE: MyFuture.java
|
||||
|
||||
public interface MyFuture<V> {
|
||||
MyFuture<V> addListener(MyListener<? extends MyFuture<? super V>> listener);
|
||||
}
|
||||
|
||||
// FILE: MyListener.java
|
||||
|
||||
public interface MyListener<F extends MyFuture<?>> {
|
||||
void operationComplete(F future) throws Exception;
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
|
||||
typealias Handler = (cause: Throwable?) -> Unit
|
||||
|
||||
fun <T> MyFuture<T>.setup() {
|
||||
addListener(ListenerImpl<T, MyFuture<T>>())
|
||||
addListener { }
|
||||
}
|
||||
|
||||
class ListenerImpl<T, F : MyFuture<T>> : MyListener<F>, Handler {
|
||||
override fun operationComplete(future: F) {
|
||||
}
|
||||
|
||||
override fun invoke(cause: Throwable?) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ T> MyFuture<T>.setup(): kotlin.Unit
|
||||
|
||||
public final class ListenerImpl</*0*/ T, /*1*/ F : MyFuture<T>> : MyListener<F>, Handler /* = (cause: kotlin.Throwable?) -> kotlin.Unit */ {
|
||||
public constructor ListenerImpl</*0*/ T, /*1*/ F : MyFuture<T>>()
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ fun invoke(/*0*/ cause: kotlin.Throwable?): kotlin.Unit
|
||||
public open override /*1*/ fun operationComplete(/*0*/ future: F): kotlin.Unit
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface MyFuture</*0*/ V : kotlin.Any!> {
|
||||
public abstract fun addListener(/*0*/ listener: MyListener<out MyFuture<in V!>!>!): MyFuture<V!>!
|
||||
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 interface MyListener</*0*/ F : MyFuture<*>!> {
|
||||
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 abstract fun operationComplete(/*0*/ future: F!): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
public typealias Handler = (cause: kotlin.Throwable?) -> kotlin.Unit
|
||||
+1
-1
@@ -21,7 +21,7 @@ class B : A() {
|
||||
}
|
||||
|
||||
if (d.x is B) {
|
||||
<!SMARTCAST_IMPOSSIBLE!>d.x<!>.<!NI;INVISIBLE_MEMBER!>foo<!> {}
|
||||
<!OI;SMARTCAST_IMPOSSIBLE!>d.x<!>.<!NI;INVISIBLE_MEMBER!>foo<!> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user