提交 fb812301 编写于 作者: M Mikhail Zarechenskiy

Add test to preserve behaviour

 It's important to have ambiguity in these cases to introduce overload
 resolution by suspend-modifier without breaking changes in future

 Relates to #KT-23610
上级 e72401c5
......@@ -23222,6 +23222,11 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
runTest("compiler/testData/diagnostics/tests/suspendConversion/chainedFunSuspendConversionForSimpleExpression.kt");
}
@TestMetadata("overloadResolutionBySuspendModifier.kt")
public void testOverloadResolutionBySuspendModifier() throws Exception {
runTest("compiler/testData/diagnostics/tests/suspendConversion/overloadResolutionBySuspendModifier.kt");
}
@TestMetadata("severalConversionsInOneCall.kt")
public void testSeveralConversionsInOneCall() throws Exception {
runTest("compiler/testData/diagnostics/tests/suspendConversion/severalConversionsInOneCall.kt");
// !DIAGNOSTICS: -UNUSED_PARAMETER
fun foo(x: () -> Int) {}
fun foo(x: suspend () -> Int) {}
fun usualCall(): Int = 42
suspend fun suspendCall(): Int = 42
// it's important to have ambiguity in these cases to introduce overload resolution by suspend modifier in future
fun test1() {
<!AMBIGUITY!>foo<!> { usualCall() }
<!AMBIGUITY!>foo<!> { suspendCall() }
}
// candidate without suspend conversions is more specific
fun test2(f: () -> Int, g: suspend () -> Int) {
foo(f)
foo(g)
}
\ No newline at end of file
// !DIAGNOSTICS: -UNUSED_PARAMETER
fun foo(x: () -> Int) {}
fun foo(x: suspend () -> Int) {}
fun usualCall(): Int = 42
suspend fun suspendCall(): Int = 42
// it's important to have ambiguity in these cases to introduce overload resolution by suspend modifier in future
fun test1() {
<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!> { usualCall() }
<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!> { <!ILLEGAL_SUSPEND_FUNCTION_CALL!>suspendCall<!>() }
}
// candidate without suspend conversions is more specific
fun test2(f: () -> Int, g: suspend () -> Int) {
foo(f)
foo(g)
}
\ No newline at end of file
package
public fun foo(/*0*/ x: () -> kotlin.Int): kotlin.Unit
public fun foo(/*0*/ x: suspend () -> kotlin.Int): kotlin.Unit
public suspend fun suspendCall(): kotlin.Int
public fun test1(): kotlin.Unit
public fun test2(/*0*/ f: () -> kotlin.Int, /*1*/ g: suspend () -> kotlin.Int): kotlin.Unit
public fun usualCall(): kotlin.Int
......@@ -23304,6 +23304,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTestWithFirVali
runTest("compiler/testData/diagnostics/tests/suspendConversion/chainedFunSuspendConversionForSimpleExpression.kt");
}
@TestMetadata("overloadResolutionBySuspendModifier.kt")
public void testOverloadResolutionBySuspendModifier() throws Exception {
runTest("compiler/testData/diagnostics/tests/suspendConversion/overloadResolutionBySuspendModifier.kt");
}
@TestMetadata("severalConversionsInOneCall.kt")
public void testSeveralConversionsInOneCall() throws Exception {
runTest("compiler/testData/diagnostics/tests/suspendConversion/severalConversionsInOneCall.kt");
......@@ -23224,6 +23224,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
runTest("compiler/testData/diagnostics/tests/suspendConversion/chainedFunSuspendConversionForSimpleExpression.kt");
}
@TestMetadata("overloadResolutionBySuspendModifier.kt")
public void testOverloadResolutionBySuspendModifier() throws Exception {
runTest("compiler/testData/diagnostics/tests/suspendConversion/overloadResolutionBySuspendModifier.kt");
}
@TestMetadata("severalConversionsInOneCall.kt")
public void testSeveralConversionsInOneCall() throws Exception {
runTest("compiler/testData/diagnostics/tests/suspendConversion/severalConversionsInOneCall.kt");
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册