Add test for KT-54742
This commit is contained in:
+6
@@ -15140,6 +15140,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/inference/coercionToUnit")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class CoercionToUnit {
|
||||
@Test
|
||||
@TestMetadata("afterBareReturn.kt")
|
||||
public void testAfterBareReturn() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/coercionToUnit/afterBareReturn.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAllFilesPresentInCoercionToUnit() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/inference/coercionToUnit"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||
|
||||
+6
@@ -15146,6 +15146,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/inference/coercionToUnit")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class CoercionToUnit {
|
||||
@Test
|
||||
@TestMetadata("afterBareReturn.kt")
|
||||
public void testAfterBareReturn() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/coercionToUnit/afterBareReturn.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAllFilesPresentInCoercionToUnit() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/inference/coercionToUnit"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||
|
||||
+6
@@ -15140,6 +15140,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/inference/coercionToUnit")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class CoercionToUnit {
|
||||
@Test
|
||||
@TestMetadata("afterBareReturn.kt")
|
||||
public void testAfterBareReturn() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/coercionToUnit/afterBareReturn.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAllFilesPresentInCoercionToUnit() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/inference/coercionToUnit"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
interface I
|
||||
open class C
|
||||
|
||||
fun completed(): String = "..."
|
||||
|
||||
fun <T> incomplete(): T = null!!
|
||||
|
||||
fun <T : I> incompatibleI(): T = null!!
|
||||
fun <T : C> incompatibleC(): T = null!!
|
||||
|
||||
val p = false
|
||||
|
||||
fun expectUnit(x: Unit) = x
|
||||
|
||||
fun test1() = run {
|
||||
if (p) return@run
|
||||
completed() // ok, not returned
|
||||
}
|
||||
|
||||
fun test2() = run {
|
||||
if (p) return@run
|
||||
incomplete() // ? either uninferred T or Unit
|
||||
}
|
||||
|
||||
fun test3() = run {
|
||||
if (p) return@run
|
||||
incompatibleI() // ? either uninferred T or error (Unit </: I)
|
||||
}
|
||||
|
||||
fun test4() = <!INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION!>run<!> {
|
||||
if (p) return@run
|
||||
incompatibleC() // ? either uninferred T or error (Unit </: C)
|
||||
}
|
||||
|
||||
fun main() {
|
||||
// all ok
|
||||
expectUnit(<!ARGUMENT_TYPE_MISMATCH!>test1()<!>)
|
||||
expectUnit(test2())
|
||||
expectUnit(test3())
|
||||
expectUnit(test4())
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
interface I
|
||||
open class C
|
||||
|
||||
fun completed(): String = "..."
|
||||
|
||||
fun <T> incomplete(): T = null!!
|
||||
|
||||
fun <T : I> incompatibleI(): T = null!!
|
||||
fun <T : C> incompatibleC(): T = null!!
|
||||
|
||||
val p = false
|
||||
|
||||
fun expectUnit(x: Unit) = x
|
||||
|
||||
fun test1() = run {
|
||||
if (p) return@run
|
||||
completed() // ok, not returned
|
||||
}
|
||||
|
||||
fun test2() = run {
|
||||
if (p) return@run
|
||||
incomplete() // ? either uninferred T or Unit
|
||||
}
|
||||
|
||||
fun test3() = <!INFERRED_TYPE_VARIABLE_INTO_POSSIBLE_EMPTY_INTERSECTION!>run<!> {
|
||||
if (p) return@run
|
||||
incompatibleI() // ? either uninferred T or error (Unit </: I)
|
||||
}
|
||||
|
||||
fun test4() = <!INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION_WARNING!>run<!> {
|
||||
if (p) return@run
|
||||
incompatibleC() // ? either uninferred T or error (Unit </: C)
|
||||
}
|
||||
|
||||
fun main() {
|
||||
// all ok
|
||||
expectUnit(test1())
|
||||
expectUnit(test2())
|
||||
expectUnit(test3())
|
||||
expectUnit(test4())
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
package
|
||||
|
||||
public val p: kotlin.Boolean = false
|
||||
public fun completed(): kotlin.String
|
||||
public fun expectUnit(/*0*/ x: kotlin.Unit): kotlin.Unit
|
||||
public fun </*0*/ T : C> incompatibleC(): T
|
||||
public fun </*0*/ T : I> incompatibleI(): T
|
||||
public fun </*0*/ T> incomplete(): T
|
||||
public fun main(): kotlin.Unit
|
||||
public fun test1(): kotlin.Unit
|
||||
public fun test2(): kotlin.Unit
|
||||
public fun test3(): kotlin.Unit
|
||||
public fun test4(): kotlin.Unit
|
||||
|
||||
public open class C {
|
||||
public constructor C()
|
||||
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 interface I {
|
||||
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
|
||||
}
|
||||
Generated
+6
@@ -15146,6 +15146,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/inference/coercionToUnit")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class CoercionToUnit {
|
||||
@Test
|
||||
@TestMetadata("afterBareReturn.kt")
|
||||
public void testAfterBareReturn() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/coercionToUnit/afterBareReturn.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAllFilesPresentInCoercionToUnit() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/inference/coercionToUnit"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||
|
||||
Reference in New Issue
Block a user