Introduce language feature for refined sam adapters priority
This commit is contained in:
+37
@@ -0,0 +1,37 @@
|
||||
// !LANGUAGE: -RefinedSamAdaptersPriority
|
||||
// !CHECK_TYPE
|
||||
// FILE: A.java
|
||||
public class A {
|
||||
public static int foo(Runnable r) { return 0; }
|
||||
public static String foo(Object r) { return null;}
|
||||
|
||||
public static int bar(Runnable r) { return 1; }
|
||||
public static String bar(CharSequence r) { return null; }
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
fun fn() {}
|
||||
fun x(r: Runnable) {
|
||||
A.foo(::fn) checkType { _<String>() }
|
||||
A.foo {} checkType { _<String>() }
|
||||
|
||||
A.foo(null) checkType { _<Int>() }
|
||||
A.foo(Runnable { }) checkType { _<Int>() }
|
||||
A.foo(r) checkType { _<Int>() }
|
||||
|
||||
A.foo(123) checkType { _<String>() }
|
||||
A.foo("") checkType { _<String>() }
|
||||
|
||||
A.bar(::fn) checkType { _<Int>() }
|
||||
A.bar {} checkType { _<Int>() }
|
||||
|
||||
A.bar(r) checkType { _<Int>() }
|
||||
|
||||
A.<!OVERLOAD_RESOLUTION_AMBIGUITY!>bar<!>(null)
|
||||
|
||||
A.bar(null as Runnable?) checkType { _<Int>() }
|
||||
A.bar(null as CharSequence?) checkType { _<String>() }
|
||||
|
||||
A.bar("") checkType { _<String>() }
|
||||
A.<!NONE_APPLICABLE!>bar<!>(123)
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package
|
||||
|
||||
public fun fn(): kotlin.Unit
|
||||
public fun x(/*0*/ r: java.lang.Runnable): kotlin.Unit
|
||||
|
||||
public open class A {
|
||||
public constructor A()
|
||||
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
|
||||
|
||||
// Static members
|
||||
public final /*synthesized*/ fun bar(/*0*/ r: (() -> kotlin.Unit)!): kotlin.Int
|
||||
public open fun bar(/*0*/ r: java.lang.Runnable!): kotlin.Int
|
||||
public open fun bar(/*0*/ r: kotlin.CharSequence!): kotlin.String!
|
||||
public final /*synthesized*/ fun foo(/*0*/ r: (() -> kotlin.Unit)!): kotlin.Int
|
||||
public open fun foo(/*0*/ r: java.lang.Runnable!): kotlin.Int
|
||||
public open fun foo(/*0*/ r: kotlin.Any!): kotlin.String!
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
// !LANGUAGE: -RefinedSamAdaptersPriority
|
||||
// !CHECK_TYPE
|
||||
// FILE: A.java
|
||||
public class A {
|
||||
public int foo(Runnable r) { return 0; }
|
||||
public String foo(Object r) { return null;}
|
||||
|
||||
public int bar(Runnable r) { return 1; }
|
||||
public String bar(CharSequence r) { return null; }
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
fun fn() {}
|
||||
fun x(a: A, r: Runnable) {
|
||||
a.foo(::fn) checkType { _<String>() }
|
||||
a.foo {} checkType { _<String>() }
|
||||
|
||||
a.foo(null) checkType { _<Int>() }
|
||||
a.foo(Runnable { }) checkType { _<Int>() }
|
||||
a.foo(r) checkType { _<Int>() }
|
||||
|
||||
a.foo(123) checkType { _<String>() }
|
||||
a.foo("") checkType { _<String>() }
|
||||
|
||||
a.bar(::fn) checkType { _<Int>() }
|
||||
a.bar {} checkType { _<Int>() }
|
||||
|
||||
a.bar(r) checkType { _<Int>() }
|
||||
|
||||
a.<!OVERLOAD_RESOLUTION_AMBIGUITY!>bar<!>(null)
|
||||
|
||||
a.bar(null as Runnable?) checkType { _<Int>() }
|
||||
a.bar(null as CharSequence?) checkType { _<String>() }
|
||||
|
||||
a.bar("") checkType { _<String>() }
|
||||
a.<!NONE_APPLICABLE!>bar<!>(123)
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package
|
||||
|
||||
public fun fn(): kotlin.Unit
|
||||
public fun x(/*0*/ a: A, /*1*/ r: java.lang.Runnable): kotlin.Unit
|
||||
|
||||
public open class A {
|
||||
public constructor A()
|
||||
public open fun bar(/*0*/ r: java.lang.Runnable!): kotlin.Int
|
||||
public open fun bar(/*0*/ r: kotlin.CharSequence!): kotlin.String!
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open fun foo(/*0*/ r: java.lang.Runnable!): kotlin.Int
|
||||
public open fun foo(/*0*/ r: kotlin.Any!): kotlin.String!
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// !CHECK_TYPE
|
||||
|
||||
// FILE: Foo.java
|
||||
import kotlin.Unit;
|
||||
import kotlin.jvm.functions.Function1;
|
||||
|
||||
class Foo {
|
||||
interface FObject<T> {
|
||||
void invoke(T i);
|
||||
}
|
||||
|
||||
public String foo(FObject<Integer> f) { return ""; }
|
||||
public int foo(Function1<Integer, Unit> f) { return 1; }
|
||||
|
||||
public String bar(FObject<Object> f) { return ""; }
|
||||
public int bar(Function1<Integer, Unit> f) { return 1; }
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
fun test() {
|
||||
Foo().foo {} checkType { _<Int>() }
|
||||
Foo().bar {} checkType { _<String>() }
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package
|
||||
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
public/*package*/ open class Foo {
|
||||
public/*package*/ constructor Foo()
|
||||
public open fun bar(/*0*/ f: ((kotlin.Int!) -> kotlin.Unit!)!): kotlin.Int
|
||||
public open fun bar(/*0*/ f: Foo.FObject<kotlin.Any!>!): kotlin.String!
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open fun foo(/*0*/ f: ((kotlin.Int!) -> kotlin.Unit!)!): kotlin.Int
|
||||
public open fun foo(/*0*/ f: Foo.FObject<kotlin.Int!>!): kotlin.String!
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
public/*package*/ interface FObject</*0*/ T : kotlin.Any!> {
|
||||
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 operator fun invoke(/*0*/ i: T!): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
// Static members
|
||||
public/*package*/ final /*synthesized*/ fun </*0*/ T : kotlin.Any!> FObject(/*0*/ function: (i: T!) -> kotlin.Unit): Foo.FObject<T>
|
||||
}
|
||||
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
// !LANGUAGE: -RefinedSamAdaptersPriority
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// !CHECK_TYPE
|
||||
|
||||
// FILE: Foo.java
|
||||
import kotlin.Unit;
|
||||
import kotlin.jvm.functions.Function1;
|
||||
|
||||
class Foo {
|
||||
interface FObject<T> {
|
||||
void invoke(T i);
|
||||
}
|
||||
|
||||
public String foo(FObject<Integer> f) { return ""; }
|
||||
public int foo(Function1<Integer, Unit> f) { return 1; }
|
||||
|
||||
public String bar(FObject<Object> f) { return ""; }
|
||||
public int bar(Function1<Integer, Unit> f) { return 1; }
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
fun test() {
|
||||
Foo().foo {} checkType { _<Int>() }
|
||||
Foo().bar {} checkType { _<Int>() }
|
||||
}
|
||||
compiler/testData/diagnostics/testsWithStdLib/resolve/samOverloadsWithGenericsWithoutRefinedSams.txt
Vendored
+24
@@ -0,0 +1,24 @@
|
||||
package
|
||||
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
public/*package*/ open class Foo {
|
||||
public/*package*/ constructor Foo()
|
||||
public open fun bar(/*0*/ f: ((kotlin.Int!) -> kotlin.Unit!)!): kotlin.Int
|
||||
public open fun bar(/*0*/ f: Foo.FObject<kotlin.Any!>!): kotlin.String!
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open fun foo(/*0*/ f: ((kotlin.Int!) -> kotlin.Unit!)!): kotlin.Int
|
||||
public open fun foo(/*0*/ f: Foo.FObject<kotlin.Int!>!): kotlin.String!
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
public/*package*/ interface FObject</*0*/ T : kotlin.Any!> {
|
||||
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 operator fun invoke(/*0*/ i: T!): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
// Static members
|
||||
public/*package*/ final /*synthesized*/ fun </*0*/ T : kotlin.Any!> FObject(/*0*/ function: (i: T!) -> kotlin.Unit): Foo.FObject<T>
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// !CHECK_TYPE
|
||||
|
||||
// FILE: Foo.java
|
||||
import kotlin.Unit;
|
||||
import kotlin.jvm.functions.Function1;
|
||||
|
||||
public class Foo {
|
||||
interface FObject {
|
||||
void invoke(Object i);
|
||||
}
|
||||
|
||||
public String test(FObject f) { return ""; }
|
||||
public int test(Function1<Integer, Unit> f) { return 1; }
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
fun bar() {
|
||||
Foo().test {} checkType { _<String>() }
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package
|
||||
|
||||
public fun bar(): kotlin.Unit
|
||||
|
||||
public open class Foo {
|
||||
public constructor Foo()
|
||||
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 fun test(/*0*/ f: ((kotlin.Int!) -> kotlin.Unit!)!): kotlin.Int
|
||||
public open fun test(/*0*/ f: Foo.FObject!): kotlin.String!
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
public/*package*/ interface FObject {
|
||||
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 operator fun invoke(/*0*/ i: kotlin.Any!): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
// Static members
|
||||
public/*package*/ final /*synthesized*/ fun FObject(/*0*/ function: (i: kotlin.Any!) -> kotlin.Unit): Foo.FObject
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
// !LANGUAGE: -RefinedSamAdaptersPriority
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// !CHECK_TYPE
|
||||
|
||||
// FILE: Foo.java
|
||||
import kotlin.Unit;
|
||||
import kotlin.jvm.functions.Function1;
|
||||
|
||||
public class Foo {
|
||||
interface FObject {
|
||||
void invoke(Object i);
|
||||
}
|
||||
|
||||
public String test(FObject f) { return ""; }
|
||||
public int test(Function1<Integer, Unit> f) { return 1; }
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
fun bar() {
|
||||
Foo().test {} checkType { _<Int>() }
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package
|
||||
|
||||
public fun bar(): kotlin.Unit
|
||||
|
||||
public open class Foo {
|
||||
public constructor Foo()
|
||||
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 fun test(/*0*/ f: ((kotlin.Int!) -> kotlin.Unit!)!): kotlin.Int
|
||||
public open fun test(/*0*/ f: Foo.FObject!): kotlin.String!
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
public/*package*/ interface FObject {
|
||||
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 operator fun invoke(/*0*/ i: kotlin.Any!): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
// Static members
|
||||
public/*package*/ final /*synthesized*/ fun FObject(/*0*/ function: (i: kotlin.Any!) -> kotlin.Unit): Foo.FObject
|
||||
}
|
||||
Reference in New Issue
Block a user