[FIR] Add tests for non exhaustive when as last expression of lambda
KT-44810
This commit is contained in:
+10
@@ -1274,6 +1274,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract
|
||||
public void testMissingSealedInheritor() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/exhaustiveness/negative/missingSealedInheritor.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nonExhaustiveWhenWithoutCoercionToUnit.kt")
|
||||
public void testNonExhaustiveWhenWithoutCoercionToUnit() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/exhaustiveness/negative/nonExhaustiveWhenWithoutCoercionToUnit.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive")
|
||||
@@ -1327,6 +1332,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract
|
||||
public void testExhaustiveness_sealedSubClass() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/exhaustiveness_sealedSubClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nonExhaustiveWhenWithCoercionToUnit.kt")
|
||||
public void testNonExhaustiveWhenWithCoercionToUnit() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/nonExhaustiveWhenWithCoercionToUnit.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
FILE: nonExhaustiveWhenWithoutCoercionToUnit.kt
|
||||
public final fun <T> run(block: R|() -> T|): R|T| {
|
||||
^run R|<local>/block|.R|SubstitutionOverride<kotlin/Function0.invoke: R|T|>|()
|
||||
}
|
||||
public final fun test(a: R|kotlin/Any|): R|kotlin/Unit| {
|
||||
R|/run|<R|kotlin/Unit|>(<L> = run@fun <anonymous>(): R|kotlin/Unit| {
|
||||
when (R|<local>/a|) {
|
||||
($subj$ is R|kotlin/String|) -> {
|
||||
Int(1)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
)
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
fun <T> run(block: () -> T): T = block()
|
||||
|
||||
fun test(a: Any) {
|
||||
run {
|
||||
// Should be an error, see KT-44810
|
||||
when (a) {
|
||||
is String -> 1
|
||||
}
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
FILE: nonExhaustiveWhenWithCoercionToUnit.kt
|
||||
public final fun <T> run(block: R|() -> T|): R|T| {
|
||||
^run R|<local>/block|.R|SubstitutionOverride<kotlin/Function0.invoke: R|T|>|()
|
||||
}
|
||||
public final fun test(a: R|kotlin/Any|, b: R|kotlin/Boolean|): R|kotlin/Unit| {
|
||||
R|/run|<R|kotlin/Unit|>(<L> = run@fun <anonymous>(): R|kotlin/Unit| {
|
||||
when () {
|
||||
R|<local>/b| -> {
|
||||
^@run Unit
|
||||
}
|
||||
}
|
||||
|
||||
when (R|<local>/a|) {
|
||||
($subj$ is R|kotlin/String|) -> {
|
||||
Int(1)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
)
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
fun <T> run(block: () -> T): T = block()
|
||||
|
||||
fun test(a: Any, b: Boolean) {
|
||||
run {
|
||||
if (b) return@run
|
||||
when (a) {
|
||||
is String -> 1
|
||||
}
|
||||
}
|
||||
}
|
||||
+12
@@ -1459,6 +1459,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest {
|
||||
public void testMissingSealedInheritor() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/exhaustiveness/negative/missingSealedInheritor.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nonExhaustiveWhenWithoutCoercionToUnit.kt")
|
||||
public void testNonExhaustiveWhenWithoutCoercionToUnit() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/exhaustiveness/negative/nonExhaustiveWhenWithoutCoercionToUnit.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@@ -1517,6 +1523,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest {
|
||||
public void testExhaustiveness_sealedSubClass() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/exhaustiveness_sealedSubClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nonExhaustiveWhenWithCoercionToUnit.kt")
|
||||
public void testNonExhaustiveWhenWithCoercionToUnit() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/nonExhaustiveWhenWithCoercionToUnit.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+12
@@ -1473,6 +1473,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
|
||||
public void testMissingSealedInheritor() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/exhaustiveness/negative/missingSealedInheritor.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nonExhaustiveWhenWithoutCoercionToUnit.kt")
|
||||
public void testNonExhaustiveWhenWithoutCoercionToUnit() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/exhaustiveness/negative/nonExhaustiveWhenWithoutCoercionToUnit.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@@ -1532,6 +1538,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
|
||||
public void testExhaustiveness_sealedSubClass() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/exhaustiveness_sealedSubClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nonExhaustiveWhenWithCoercionToUnit.kt")
|
||||
public void testNonExhaustiveWhenWithCoercionToUnit() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/nonExhaustiveWhenWithCoercionToUnit.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user