[FIR-TEST] Add test for KT-39075
This commit is contained in:
+19
@@ -0,0 +1,19 @@
|
|||||||
|
// ISSUE: KT-39075
|
||||||
|
|
||||||
|
class A {
|
||||||
|
fun unit() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun foo(x: () -> Unit) {}
|
||||||
|
|
||||||
|
fun main(x: A?) {
|
||||||
|
|
||||||
|
val lambda = l@{
|
||||||
|
if (x?.hashCode() == 0) return@l
|
||||||
|
|
||||||
|
x?.unit()
|
||||||
|
}
|
||||||
|
|
||||||
|
// lambda has a type (() -> Unit?)
|
||||||
|
foo(lambda)
|
||||||
|
}
|
||||||
+25
@@ -0,0 +1,25 @@
|
|||||||
|
FILE: coercionToUnitWithEarlyReturn.kt
|
||||||
|
public final class A : R|kotlin/Any| {
|
||||||
|
public constructor(): R|A| {
|
||||||
|
super<R|kotlin/Any|>()
|
||||||
|
}
|
||||||
|
|
||||||
|
public final fun unit(): R|kotlin/Unit| {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
public final fun foo(x: R|() -> kotlin/Unit|): R|kotlin/Unit| {
|
||||||
|
}
|
||||||
|
public final fun main(x: R|A?|): R|kotlin/Unit| {
|
||||||
|
lval lambda: R|() -> kotlin/Unit| = l@fun <anonymous>(): R|kotlin/Unit| {
|
||||||
|
when () {
|
||||||
|
==(R|<local>/x|?.{ $subj$.R|kotlin/Any.hashCode|() }, Int(0)) -> {
|
||||||
|
^@l Unit
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
^ R|<local>/x|?.{ $subj$.R|/A.unit|() }
|
||||||
|
}
|
||||||
|
|
||||||
|
R|/foo|(R|<local>/lambda|)
|
||||||
|
}
|
||||||
Generated
+5
@@ -1469,6 +1469,11 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest {
|
|||||||
runTest("compiler/fir/analysis-tests/testData/resolve/inference/capturedTypeForJavaTypeParameter.kt");
|
runTest("compiler/fir/analysis-tests/testData/resolve/inference/capturedTypeForJavaTypeParameter.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("coercionToUnitWithEarlyReturn.kt")
|
||||||
|
public void testCoercionToUnitWithEarlyReturn() throws Exception {
|
||||||
|
runTest("compiler/fir/analysis-tests/testData/resolve/inference/coercionToUnitWithEarlyReturn.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("definitelyNotNullIntersectionType.kt")
|
@TestMetadata("definitelyNotNullIntersectionType.kt")
|
||||||
public void testDefinitelyNotNullIntersectionType() throws Exception {
|
public void testDefinitelyNotNullIntersectionType() throws Exception {
|
||||||
runTest("compiler/fir/analysis-tests/testData/resolve/inference/definitelyNotNullIntersectionType.kt");
|
runTest("compiler/fir/analysis-tests/testData/resolve/inference/definitelyNotNullIntersectionType.kt");
|
||||||
|
|||||||
+5
@@ -1469,6 +1469,11 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
|
|||||||
runTest("compiler/fir/analysis-tests/testData/resolve/inference/capturedTypeForJavaTypeParameter.kt");
|
runTest("compiler/fir/analysis-tests/testData/resolve/inference/capturedTypeForJavaTypeParameter.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("coercionToUnitWithEarlyReturn.kt")
|
||||||
|
public void testCoercionToUnitWithEarlyReturn() throws Exception {
|
||||||
|
runTest("compiler/fir/analysis-tests/testData/resolve/inference/coercionToUnitWithEarlyReturn.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("definitelyNotNullIntersectionType.kt")
|
@TestMetadata("definitelyNotNullIntersectionType.kt")
|
||||||
public void testDefinitelyNotNullIntersectionType() throws Exception {
|
public void testDefinitelyNotNullIntersectionType() throws Exception {
|
||||||
runTest("compiler/fir/analysis-tests/testData/resolve/inference/definitelyNotNullIntersectionType.kt");
|
runTest("compiler/fir/analysis-tests/testData/resolve/inference/definitelyNotNullIntersectionType.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user