[FE 1.0] Eliminate resolution ambiguity on inherited SAM-interfaces

^KT-17765 Fixed
This commit is contained in:
Victor Petukhov
2021-11-16 10:59:45 +03:00
committed by teamcityserver
parent a5c6d370dd
commit a6fd14d4e6
27 changed files with 271 additions and 46 deletions
@@ -1,4 +1,4 @@
// !LANGUAGE: +NewInference
// !LANGUAGE: +EliminateAmbiguitiesOnInheritedSamInterfaces
// !CHECK_TYPE
// FILE: Fn.java
public interface Fn<T, R> {
@@ -26,6 +26,5 @@ fun test(j: J) {
j.<!OVERLOAD_RESOLUTION_AMBIGUITY!>bas<!>({ <!UNRESOLVED_REFERENCE!>it<!> checkType { _<Any>() }; "" }, "") <!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>checkType<!> { _<Int>() }
// NI: TODO
j.bar { it checkType { <!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>_<!><Any>() }; "" } checkType { _<Int>() }
j.bar { it checkType { _<String>() }; "" } checkType { _<Int>() }
}
@@ -1,4 +1,4 @@
// !LANGUAGE: +NewInference
// !LANGUAGE: +EliminateAmbiguitiesOnInheritedSamInterfaces
// !CHECK_TYPE
// FILE: Fn.java
public interface Fn<T, R> {
@@ -26,6 +26,5 @@ fun test(j: J) {
j.bas({ it checkType { _<Any>() }; "" }, "") checkType { _<Int>() }
// NI: TODO
j.<!OVERLOAD_RESOLUTION_AMBIGUITY!>bar<!> { <!UNRESOLVED_REFERENCE!>it<!> <!DEBUG_INFO_MISSING_UNRESOLVED!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><Any>() }; "" } <!DEBUG_INFO_MISSING_UNRESOLVED!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
j.bar { it checkType { _<String>() }; "" } checkType { _<Int>() }
}
@@ -1,4 +1,4 @@
// !LANGUAGE: +NewInference +SamConversionForKotlinFunctions +SamConversionPerArgument
// !LANGUAGE: +EliminateAmbiguitiesOnInheritedSamInterfaces +SamConversionForKotlinFunctions +SamConversionPerArgument
// !CHECK_TYPE
// FILE: Fn.java
public interface Fn<T, R> {
@@ -25,6 +25,5 @@ fun test(k: K) {
k.<!OVERLOAD_RESOLUTION_AMBIGUITY!>bas<!> { <!UNRESOLVED_REFERENCE!>it<!> checkType { _<Any?>() }; "" } <!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>checkType<!> { _<Int>() }
// NI: TODO
k.bar { it checkType { <!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>_<!><Any>() }; "" } checkType { _<Int>() }
k.bar { it checkType { _<String>() }; "" } checkType { _<Int>() }
}
@@ -1,4 +1,4 @@
// !LANGUAGE: +NewInference +SamConversionForKotlinFunctions +SamConversionPerArgument
// !LANGUAGE: +EliminateAmbiguitiesOnInheritedSamInterfaces +SamConversionForKotlinFunctions +SamConversionPerArgument
// !CHECK_TYPE
// FILE: Fn.java
public interface Fn<T, R> {
@@ -25,6 +25,5 @@ fun test(k: K) {
k.bas { it checkType { _<Any?>() }; "" } checkType { _<Int>() }
// NI: TODO
k.<!OVERLOAD_RESOLUTION_AMBIGUITY!>bar<!> { <!UNRESOLVED_REFERENCE!>it<!> <!DEBUG_INFO_MISSING_UNRESOLVED!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><Any>() }; "" } <!DEBUG_INFO_MISSING_UNRESOLVED!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
k.bar { it checkType { _<String>() }; "" } checkType { _<Int>() }
}
@@ -0,0 +1,12 @@
// FILE: Test.java
public class Test {
interface MyRunnable extends Runnable {}
public static void foo(MyRunnable r) {}
public static void foo(Runnable r) {}
}
// FILE: 1.kt
fun main(args: Array<String>) {
Test.foo { }
}
@@ -0,0 +1,12 @@
// FILE: Test.java
public class Test {
interface MyRunnable extends Runnable {}
public static void foo(MyRunnable r) {}
public static void foo(Runnable r) {}
}
// FILE: 1.kt
fun main(args: Array<String>) {
Test.<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!> { }
}
@@ -0,0 +1,21 @@
package
public fun main(/*0*/ args: kotlin.Array<kotlin.String>): kotlin.Unit
public open class Test {
public constructor Test()
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/*package*/ interface MyRunnable : java.lang.Runnable {
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 override /*1*/ /*fake_override*/ fun run(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
// Static members
public open fun foo(/*0*/ r: Test.MyRunnable!): kotlin.Unit
public open fun foo(/*0*/ r: java.lang.Runnable!): kotlin.Unit
}