Add compatibility warning for chained sam->suspend-conversion
This commit is contained in:
+5
@@ -23207,6 +23207,11 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
|
||||
runTest("compiler/testData/diagnostics/tests/suspendConversion/severalConversionsInOneCall.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("suspendAndFunConversionInDisabledMode.kt")
|
||||
public void testSuspendAndFunConversionInDisabledMode() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/suspendConversion/suspendAndFunConversionInDisabledMode.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("suspendConversionCompatibility.kt")
|
||||
public void testSuspendConversionCompatibility() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/suspendConversion/suspendConversionCompatibility.kt");
|
||||
|
||||
+7
-8
@@ -38,17 +38,16 @@ object TypeConversions {
|
||||
val samConversionData = performConversionBeforeSubtyping(
|
||||
candidate, argument, candidateParameter, candidateExpectedType, SamTypeConversions
|
||||
)
|
||||
val suspendConversionData = if (samConversionData.convertedType == null) {
|
||||
performConversionBeforeSubtyping(candidate, argument, candidateParameter, candidateExpectedType, SuspendTypeConversions)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
||||
val suspendConversionData = performConversionBeforeSubtyping(
|
||||
candidate, argument, candidateParameter, samConversionData.convertedType ?: candidateExpectedType, SuspendTypeConversions
|
||||
)
|
||||
|
||||
return ConversionData(
|
||||
convertedType = samConversionData.convertedType ?: suspendConversionData?.convertedType,
|
||||
wasConversion = samConversionData.wasConversion || suspendConversionData?.wasConversion == true,
|
||||
convertedType = suspendConversionData.convertedType ?: samConversionData.convertedType,
|
||||
wasConversion = samConversionData.wasConversion || suspendConversionData.wasConversion,
|
||||
conversionDefinitelyNotNeeded = samConversionData.conversionDefinitelyNotNeeded &&
|
||||
(suspendConversionData == null || suspendConversionData.conversionDefinitelyNotNeeded)
|
||||
suspendConversionData.conversionDefinitelyNotNeeded
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -9,5 +9,5 @@ fun foo(s: SuspendRunnable) {}
|
||||
|
||||
fun test(f: () -> Unit) {
|
||||
foo { }
|
||||
foo(<!TYPE_MISMATCH!>f<!>)
|
||||
foo(f)
|
||||
}
|
||||
|
||||
Vendored
+31
@@ -0,0 +1,31 @@
|
||||
// !LANGUAGE: -SuspendConversion
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION
|
||||
|
||||
fun interface SuspendRunnable {
|
||||
suspend fun run()
|
||||
}
|
||||
|
||||
object Test1 {
|
||||
fun call(r: () -> Unit) {}
|
||||
|
||||
object Scope {
|
||||
fun call(r: SuspendRunnable) {}
|
||||
|
||||
fun bar(f: () -> Unit) {
|
||||
<!DEBUG_INFO_CALL("fqName: Test1.call; typeCall: function")!>call(f)<!>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
object Test2 {
|
||||
fun call(r: Runnable) {}
|
||||
|
||||
object Scope {
|
||||
fun call(r: SuspendRunnable) {}
|
||||
|
||||
fun bar(f: () -> Unit) {
|
||||
<!DEBUG_INFO_CALL("fqName: Test2.call; typeCall: function")!>call(f)<!>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+30
@@ -0,0 +1,30 @@
|
||||
// !LANGUAGE: -SuspendConversion
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION
|
||||
|
||||
fun interface SuspendRunnable {
|
||||
suspend fun run()
|
||||
}
|
||||
|
||||
object Test1 {
|
||||
fun call(r: () -> Unit) {}
|
||||
|
||||
object Scope {
|
||||
fun call(r: SuspendRunnable) {}
|
||||
|
||||
fun bar(f: () -> Unit) {
|
||||
<!COMPATIBILITY_WARNING, DEBUG_INFO_CALL("fqName: Test1.call; typeCall: function")!>call(f)<!>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
object Test2 {
|
||||
fun call(r: Runnable) {}
|
||||
|
||||
object Scope {
|
||||
fun call(r: SuspendRunnable) {}
|
||||
|
||||
fun bar(f: () -> Unit) {
|
||||
<!DEBUG_INFO_CALL("fqName: Test2.Scope.call; typeCall: function")!>call(<!UNSUPPORTED_FEATURE!>f<!>)<!>
|
||||
}
|
||||
}
|
||||
}
|
||||
Vendored
+42
@@ -0,0 +1,42 @@
|
||||
package
|
||||
|
||||
public fun interface SuspendRunnable {
|
||||
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 suspend fun run(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public object Test1 {
|
||||
private constructor Test1()
|
||||
public final fun call(/*0*/ r: () -> kotlin.Unit): kotlin.Unit
|
||||
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 object Scope {
|
||||
private constructor Scope()
|
||||
public final fun bar(/*0*/ f: () -> kotlin.Unit): kotlin.Unit
|
||||
public final fun call(/*0*/ r: SuspendRunnable): kotlin.Unit
|
||||
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 object Test2 {
|
||||
private constructor Test2()
|
||||
public final fun call(/*0*/ r: java.lang.Runnable): kotlin.Unit
|
||||
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 object Scope {
|
||||
private constructor Scope()
|
||||
public final fun bar(/*0*/ f: () -> kotlin.Unit): kotlin.Unit
|
||||
public final fun call(/*0*/ r: SuspendRunnable): kotlin.Unit
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -23289,6 +23289,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTestWithFirVali
|
||||
runTest("compiler/testData/diagnostics/tests/suspendConversion/severalConversionsInOneCall.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("suspendAndFunConversionInDisabledMode.kt")
|
||||
public void testSuspendAndFunConversionInDisabledMode() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/suspendConversion/suspendAndFunConversionInDisabledMode.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("suspendConversionCompatibility.kt")
|
||||
public void testSuspendConversionCompatibility() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/suspendConversion/suspendConversionCompatibility.kt");
|
||||
|
||||
Generated
+5
@@ -23209,6 +23209,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
|
||||
runTest("compiler/testData/diagnostics/tests/suspendConversion/severalConversionsInOneCall.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("suspendAndFunConversionInDisabledMode.kt")
|
||||
public void testSuspendAndFunConversionInDisabledMode() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/suspendConversion/suspendAndFunConversionInDisabledMode.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("suspendConversionCompatibility.kt")
|
||||
public void testSuspendConversionCompatibility() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/suspendConversion/suspendConversionCompatibility.kt");
|
||||
|
||||
Reference in New Issue
Block a user