[NI] Move ability to convert standalone SAM-argument under the feature
If new inference is enabled only for IDE analysis, then this feature will be disabled to reduce difference between new and old inference, but if new inference is enabled in the compiler, then this feature will be enabled too to preserve behavior of new inference for compilation #KT-32175 Fixed #KT-32143 Fixed #KT-32123 Fixed #KT-32230 Fixed
This commit is contained in:
+3
-3
@@ -1,4 +1,4 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// !LANGUAGE: +SamConversionPerArgument +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
// FILE: A.java
|
||||
@@ -16,14 +16,14 @@ fun <T> bar(s: T) {}
|
||||
fun <T> complex(t: T, f: (T) -> Unit) {}
|
||||
|
||||
fun test1() {
|
||||
foo(1, <!NI;TYPE_MISMATCH!>A::invokeLater<!>) // KT-24507 SAM conversion accidentally applied to callable reference and incorrectly handled via BE
|
||||
foo(1, <!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, <!NI;TYPE_MISMATCH!>A::invokeLater<!>) // KT-24507 SAM conversion accidentally applied to callable reference and incorrectly handled via BE
|
||||
foo(x, <!TYPE_MISMATCH!>A::invokeLater<!>) // KT-24507 SAM conversion accidentally applied to callable reference and incorrectly handled via BE
|
||||
foo(x, ::bar)
|
||||
|
||||
complex(x, ::bar)
|
||||
|
||||
+1
-1
@@ -13,5 +13,5 @@ public class J {
|
||||
package test
|
||||
|
||||
fun test() {
|
||||
J("", <!NAMED_ARGUMENTS_NOT_ALLOWED!>r<!> = { }, <!NAMED_ARGUMENTS_NOT_ALLOWED!>z<!> = false)
|
||||
J("", <!NAMED_ARGUMENTS_NOT_ALLOWED!>r<!> = <!NI;TYPE_MISMATCH!>{ }<!>, <!NAMED_ARGUMENTS_NOT_ALLOWED!>z<!> = false)
|
||||
}
|
||||
|
||||
+1
-1
@@ -13,5 +13,5 @@ public class J {
|
||||
package test
|
||||
|
||||
fun test() {
|
||||
J.foo("", <!NAMED_ARGUMENTS_NOT_ALLOWED!>r<!> = { }, <!NAMED_ARGUMENTS_NOT_ALLOWED!>z<!> = false)
|
||||
J.foo("", <!NAMED_ARGUMENTS_NOT_ALLOWED!>r<!> = <!NI;TYPE_MISMATCH!>{ }<!>, <!NAMED_ARGUMENTS_NOT_ALLOWED!>z<!> = false)
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ class B {
|
||||
fun main() {
|
||||
fun println() {}
|
||||
// All parameters in SAM adapter of `foo` have functional types
|
||||
B().foo(<!OI;TYPE_MISMATCH!>{ println() }<!>, B.bar())
|
||||
B().foo(<!TYPE_MISMATCH!>{ println() }<!>, B.bar())
|
||||
// So you should use SAM constructors when you want to use mix lambdas and Java objects
|
||||
B().foo(Runnable { println() }, B.bar())
|
||||
B().foo({ println() }, { it: Any? -> it == null } )
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !LANGUAGE: +NewInference +SamConversionPerArgument
|
||||
// !CHECK_TYPE
|
||||
// FILE: J.java
|
||||
public interface J<T> {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// !LANGUAGE: +NewInference +SamConversionForKotlinFunctions
|
||||
// !LANGUAGE: +NewInference +SamConversionForKotlinFunctions +SamConversionPerArgument
|
||||
// !CHECK_TYPE
|
||||
// FILE: F.java
|
||||
public interface F<S> {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// !LANGUAGE: +NewInference +SamConversionForKotlinFunctions
|
||||
// !LANGUAGE: +NewInference +SamConversionForKotlinFunctions +SamConversionPerArgument
|
||||
// !CHECK_TYPE
|
||||
// FILE: Fn.java
|
||||
public interface Fn<T, R> {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// !LANGUAGE: +NewInference +SamConversionForKotlinFunctions
|
||||
// !LANGUAGE: +NewInference +SamConversionPerArgument
|
||||
// FILE: J.java
|
||||
public interface J {
|
||||
public void foo1(Runnable r);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// !LANGUAGE: +NewInference +SamConversionForKotlinFunctions
|
||||
// !LANGUAGE: +NewInference +SamConversionForKotlinFunctions +SamConversionPerArgument
|
||||
// FILE: Runnable.java
|
||||
public interface Runnable {
|
||||
void run();
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ class B : A() {
|
||||
}
|
||||
|
||||
if (d.x is B) {
|
||||
<!OI;SMARTCAST_IMPOSSIBLE!>d.x<!>.<!NI;INVISIBLE_MEMBER!>foo<!> {}
|
||||
<!SMARTCAST_IMPOSSIBLE!>d.x<!>.<!NI;INVISIBLE_MEMBER!>foo<!> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
// FILE: KotlinFile.kt
|
||||
fun foo(javaClass: JavaClass<Int>): Int {
|
||||
val inner = javaClass.createInner<String>()
|
||||
return <!TYPE_MISMATCH!>inner.doSomething(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>1<!>, "") <!OI;TYPE_MISMATCH!>{ }<!><!>
|
||||
return <!TYPE_MISMATCH!>inner.<!NI;TYPE_MISMATCH!>doSomething(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>1<!>, "") <!TYPE_MISMATCH!>{ }<!><!><!>
|
||||
}
|
||||
|
||||
// FILE: JavaClass.java
|
||||
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// FILE: KotlinFile.kt
|
||||
fun foo(javaClass: JavaClass) {
|
||||
javaClass.doSomething(<!NAMED_ARGUMENTS_NOT_ALLOWED!>p<!> = 1) {
|
||||
javaClass.doSomething(<!NAMED_ARGUMENTS_NOT_ALLOWED!>p<!> = 1) <!NI;TYPE_MISMATCH!>{
|
||||
bar()
|
||||
}
|
||||
}<!>
|
||||
}
|
||||
|
||||
fun bar(){}
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// FILE: KotlinFile.kt
|
||||
fun foo(javaClass: JavaClass) {
|
||||
javaClass.<!INVISIBLE_MEMBER!>doSomething<!> <!OI;TYPE_MISMATCH!>{ }<!>
|
||||
javaClass.<!INVISIBLE_MEMBER!>doSomething<!> <!TYPE_MISMATCH!>{ }<!>
|
||||
}
|
||||
|
||||
// FILE: JavaClass.java
|
||||
|
||||
Reference in New Issue
Block a user