Add compatibility warning for suspend conversions
This commit is contained in:
+5
@@ -23207,6 +23207,11 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
|
|||||||
runTest("compiler/testData/diagnostics/tests/suspendConversion/severalConversionsInOneCall.kt");
|
runTest("compiler/testData/diagnostics/tests/suspendConversion/severalConversionsInOneCall.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("suspendConversionCompatibility.kt")
|
||||||
|
public void testSuspendConversionCompatibility() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/suspendConversion/suspendConversionCompatibility.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("suspendConversionDisabled.kt")
|
@TestMetadata("suspendConversionDisabled.kt")
|
||||||
public void testSuspendConversionDisabled() throws Exception {
|
public void testSuspendConversionDisabled() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/suspendConversion/suspendConversionDisabled.kt");
|
runTest("compiler/testData/diagnostics/tests/suspendConversion/suspendConversionDisabled.kt");
|
||||||
|
|||||||
+3
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.resolve.calls.components
|
|||||||
import org.jetbrains.kotlin.builtins.*
|
import org.jetbrains.kotlin.builtins.*
|
||||||
import org.jetbrains.kotlin.config.LanguageFeature
|
import org.jetbrains.kotlin.config.LanguageFeature
|
||||||
import org.jetbrains.kotlin.descriptors.ParameterDescriptor
|
import org.jetbrains.kotlin.descriptors.ParameterDescriptor
|
||||||
|
import org.jetbrains.kotlin.resolve.calls.inference.model.LowerPriorityToPreserveCompatibility
|
||||||
import org.jetbrains.kotlin.resolve.calls.model.*
|
import org.jetbrains.kotlin.resolve.calls.model.*
|
||||||
import org.jetbrains.kotlin.types.UnwrappedType
|
import org.jetbrains.kotlin.types.UnwrappedType
|
||||||
|
|
||||||
@@ -53,6 +54,8 @@ object SuspendTypeConversions : ParameterTypeConversion {
|
|||||||
|
|
||||||
candidate.resolvedCall.registerArgumentWithSuspendConversion(argument, nonSuspendParameterType)
|
candidate.resolvedCall.registerArgumentWithSuspendConversion(argument, nonSuspendParameterType)
|
||||||
|
|
||||||
|
candidate.addDiagnostic(LowerPriorityToPreserveCompatibility)
|
||||||
|
|
||||||
return nonSuspendParameterType
|
return nonSuspendParameterType
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+28
@@ -0,0 +1,28 @@
|
|||||||
|
// !LANGUAGE: +SuspendConversion
|
||||||
|
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION
|
||||||
|
|
||||||
|
object Test1 {
|
||||||
|
fun foo(f: () -> Unit) {}
|
||||||
|
|
||||||
|
object Scope {
|
||||||
|
fun foo(f: suspend () -> Unit) {}
|
||||||
|
|
||||||
|
fun test(g: () -> Unit) {
|
||||||
|
<!DEBUG_INFO_CALL("fqName: Test1.foo; typeCall: function")!>foo(g)<!>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
object Test2 {
|
||||||
|
fun <T> foo(f: suspend () -> T): T = TODO()
|
||||||
|
suspend fun bar(): Int = 0
|
||||||
|
|
||||||
|
object Scope {
|
||||||
|
fun bar(): String = ""
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
val result = foo(::bar)
|
||||||
|
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int")!>result<!>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+28
@@ -0,0 +1,28 @@
|
|||||||
|
// !LANGUAGE: +SuspendConversion
|
||||||
|
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION
|
||||||
|
|
||||||
|
object Test1 {
|
||||||
|
fun foo(f: () -> Unit) {}
|
||||||
|
|
||||||
|
object Scope {
|
||||||
|
fun foo(f: suspend () -> Unit) {}
|
||||||
|
|
||||||
|
fun test(g: () -> Unit) {
|
||||||
|
<!COMPATIBILITY_WARNING, DEBUG_INFO_CALL("fqName: Test1.foo; typeCall: function")!>foo(g)<!>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
object Test2 {
|
||||||
|
fun <T> foo(f: suspend () -> T): T = TODO()
|
||||||
|
suspend fun bar(): Int = 0
|
||||||
|
|
||||||
|
object Scope {
|
||||||
|
fun bar(): String = ""
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
val result = foo(<!COMPATIBILITY_WARNING!>::bar<!>)
|
||||||
|
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int")!>result<!>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+36
@@ -0,0 +1,36 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public object Test1 {
|
||||||
|
private constructor Test1()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public final fun foo(/*0*/ f: () -> kotlin.Unit): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|
||||||
|
public object Scope {
|
||||||
|
private constructor Scope()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public final fun foo(/*0*/ f: suspend () -> kotlin.Unit): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public final fun test(/*0*/ g: () -> kotlin.Unit): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public object Test2 {
|
||||||
|
private constructor Test2()
|
||||||
|
public final suspend fun bar(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public final fun </*0*/ T> foo(/*0*/ f: suspend () -> T): T
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|
||||||
|
public object Scope {
|
||||||
|
private constructor Scope()
|
||||||
|
public final fun bar(): kotlin.String
|
||||||
|
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 final fun test(): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -23289,6 +23289,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTestWithFirVali
|
|||||||
runTest("compiler/testData/diagnostics/tests/suspendConversion/severalConversionsInOneCall.kt");
|
runTest("compiler/testData/diagnostics/tests/suspendConversion/severalConversionsInOneCall.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("suspendConversionCompatibility.kt")
|
||||||
|
public void testSuspendConversionCompatibility() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/suspendConversion/suspendConversionCompatibility.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("suspendConversionDisabled.kt")
|
@TestMetadata("suspendConversionDisabled.kt")
|
||||||
public void testSuspendConversionDisabled() throws Exception {
|
public void testSuspendConversionDisabled() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/suspendConversion/suspendConversionDisabled.kt");
|
runTest("compiler/testData/diagnostics/tests/suspendConversion/suspendConversionDisabled.kt");
|
||||||
|
|||||||
Generated
+5
@@ -23209,6 +23209,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
|
|||||||
runTest("compiler/testData/diagnostics/tests/suspendConversion/severalConversionsInOneCall.kt");
|
runTest("compiler/testData/diagnostics/tests/suspendConversion/severalConversionsInOneCall.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("suspendConversionCompatibility.kt")
|
||||||
|
public void testSuspendConversionCompatibility() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/suspendConversion/suspendConversionCompatibility.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("suspendConversionDisabled.kt")
|
@TestMetadata("suspendConversionDisabled.kt")
|
||||||
public void testSuspendConversionDisabled() throws Exception {
|
public void testSuspendConversionDisabled() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/suspendConversion/suspendConversionDisabled.kt");
|
runTest("compiler/testData/diagnostics/tests/suspendConversion/suspendConversionDisabled.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user