提交 82b6ecfa 编写于 作者: D Dmitriy Novozhilov

[FIR-TEST] Add test for KT-39075

上级 59bedaaa
// 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)
}
\ No newline at end of file
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|)
}
......@@ -1469,6 +1469,11 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest {
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")
public void testDefinitelyNotNullIntersectionType() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/inference/definitelyNotNullIntersectionType.kt");
......
......@@ -1469,6 +1469,11 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
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")
public void testDefinitelyNotNullIntersectionType() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/inference/definitelyNotNullIntersectionType.kt");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册