Add compatibility warning for chained sam->suspend-conversion

This commit is contained in:
Mikhail Zarechenskiy
2020-06-01 02:45:29 +03:00
parent a5203428a4
commit 599f520fd8
8 changed files with 126 additions and 9 deletions
@@ -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");
@@ -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
)
}
@@ -9,5 +9,5 @@ fun foo(s: SuspendRunnable) {}
fun test(f: () -> Unit) {
foo { }
foo(<!TYPE_MISMATCH!>f<!>)
foo(f)
}
@@ -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)<!>
}
}
}
@@ -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<!>)<!>
}
}
}
@@ -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");
@@ -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");