K2: disable compatibility mode for new inference
#KT-64306 Fixed #KT-64307 Fixed #KT-64308 Fixed
This commit is contained in:
+4
@@ -1,6 +1,10 @@
|
||||
// !LANGUAGE: +SuspendConversion
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// IGNORE_BACKEND: JVM
|
||||
// IGNORE_LIGHT_ANALYSIS
|
||||
// java.lang.IllegalStateException: OVERLOAD_RESOLUTION_AMBIGUITY: Overload resolution ambiguity:
|
||||
// public fun foo(x: () -> Int): Unit defined in root package in file overloadResolutionBySuspendModifier.kt
|
||||
// public fun foo(x: suspend () -> Int): Unit defined in root package in file overloadResolutionBySuspendModifier.kt (15,5) in /overloadResolutionBySuspendModifier.kt
|
||||
|
||||
var foo1 = false
|
||||
var foo2 = false
|
||||
|
||||
+2
@@ -1,6 +1,8 @@
|
||||
// !LANGUAGE: +SuspendConversion
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION
|
||||
// WITH_STDLIB
|
||||
// IGNORE_BACKEND_K2: JVM_IR, JS_IR, JS_IR_ES6, NATIVE, WASM
|
||||
// K2 status: java.lang.Integer cannot be cast to java.lang.String (inference changed due to KT-63558)
|
||||
|
||||
object Test1 {
|
||||
fun foo(f: () -> Unit) {}
|
||||
|
||||
+2
-2
@@ -15,7 +15,7 @@ object Scope {
|
||||
fun test() {
|
||||
// Despite the fact ::bar is resolved with compatibility warning, it's important not to propagate it to the outer call
|
||||
val result = <!DEBUG_INFO_CALL("fqName: Scope.foo; typeCall: function")!>foo(::bar)<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Unit")!>result<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>result<!>
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+3
-3
@@ -9,7 +9,7 @@ object Test1 {
|
||||
|
||||
fun test() {
|
||||
val result = foo(::bar)
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int")!>result<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>result<!>
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,7 +36,7 @@ object Test3 {
|
||||
|
||||
fun test() {
|
||||
val result = foo(::bar)
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int")!>result<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>result<!>
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -54,4 +54,4 @@ object Test4 {
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>result<!>
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
compiler/testData/diagnostics/tests/callableReference/unitAdaptationForReferenceCompatibility.fir.kt
Vendored
+1
-1
@@ -20,6 +20,6 @@ public interface Executor {
|
||||
fun f(): String = "test"
|
||||
|
||||
class A {
|
||||
fun schedule1(e: Executor): Future<String> = e.submit(::f)
|
||||
fun schedule1(e: Executor): Future<String> = <!RETURN_TYPE_MISMATCH!>e.submit(::f)<!>
|
||||
fun schedule2(e: Executor): Future<String> = <!RETURN_TYPE_MISMATCH!>e.submit { f() }<!>
|
||||
}
|
||||
|
||||
+5
-5
@@ -18,7 +18,7 @@ object Test1 {
|
||||
fun foo(r: Runnable) {}
|
||||
|
||||
fun test(f: () -> Unit) {
|
||||
<!DEBUG_INFO_CALL("fqName: Test1.foo; typeCall: function")!>foo(f)<!>
|
||||
<!DEBUG_INFO_CALL("fqName: Test1.Scope.foo; typeCall: function")!>foo(f)<!>
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,7 +41,7 @@ object Test3 {
|
||||
|
||||
fun test(f: () -> Unit) {
|
||||
val result = foo(1, f)
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>result<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int")!>result<!>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ object Test4 {
|
||||
|
||||
fun test() {
|
||||
val result = foo(1, ::bar)
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>result<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int")!>result<!>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ object Test5 {
|
||||
fun foo(r: Runnable) {}
|
||||
|
||||
fun test() {
|
||||
<!DEBUG_INFO_CALL("fqName: Test5.foo; typeCall: function")!>foo { }<!>
|
||||
<!DEBUG_INFO_CALL("fqName: Test5.Scope.foo; typeCall: function")!>foo { }<!>
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// SKIP_TXT
|
||||
// FULL_JDK
|
||||
|
||||
fun <T> bar(action: () -> T): T = action()
|
||||
fun bar(action: java.lang.Runnable) { }
|
||||
|
||||
fun foo(): String = ""
|
||||
|
||||
fun main() {
|
||||
val x = bar() { foo() } // OK with default current 1.5/1.6, Error with DisableCompatibilityModeForNewInference enabled
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
// SKIP_TXT
|
||||
// FIR_IDENTICAL
|
||||
// FULL_JDK
|
||||
|
||||
fun <T> bar(action: () -> T): T = action()
|
||||
|
||||
Vendored
+2
-2
@@ -22,7 +22,7 @@ object Test2 {
|
||||
|
||||
fun test() {
|
||||
val result = foo(::bar)
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int")!>result<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>result<!>
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -37,7 +37,7 @@ object Test3 {
|
||||
|
||||
fun test() {
|
||||
val result = foo(::bar)
|
||||
result
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>result<!>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -29,8 +29,8 @@ object Test2 {
|
||||
|
||||
fun test() {
|
||||
val result = foo(::bar)
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int")!>result<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>result<!>
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,7 +159,6 @@ enum class LanguageFeature(
|
||||
ProhibitVarargAsArrayAfterSamArgument(KOTLIN_1_5, kind = BUG_FIX),
|
||||
CorrectSourceMappingSyntax(KOTLIN_1_5, kind = UNSTABLE_FEATURE),
|
||||
ProperArrayConventionSetterWithDefaultCalls(KOTLIN_1_5, kind = OTHER),
|
||||
DisableCompatibilityModeForNewInference(null),
|
||||
AdaptedCallableReferenceAgainstReflectiveType(null),
|
||||
InferenceCompatibility(KOTLIN_1_5, kind = BUG_FIX),
|
||||
RequiredPrimaryConstructorDelegationCallInEnums(KOTLIN_1_5, kind = BUG_FIX),
|
||||
@@ -309,6 +308,7 @@ enum class LanguageFeature(
|
||||
ForbidInferringTypeVariablesIntoEmptyIntersection(KOTLIN_2_0, kind = BUG_FIX), // KT-51221
|
||||
ProhibitDefaultArgumentsInExpectActualizedByFakeOverride(KOTLIN_2_0, kind = BUG_FIX), // KT-62036
|
||||
JsAllowInvalidCharsIdentifiersEscaping(sinceVersion = KOTLIN_2_1, kind = OTHER), // KT-31799
|
||||
DisableCompatibilityModeForNewInference(KOTLIN_2_0, kind = OTHER), // KT-63558 (umbrella), KT-64306, KT-64307, KT-64308
|
||||
|
||||
// 2.1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user