FIR: Replicate coercion-to-unit behavior from FE 1.0

This commit is contained in:
Denis.Zharkov
2021-04-27 15:09:15 +03:00
committed by teamcityserver
parent dac5c31993
commit c67ae8a0a3
10 changed files with 109 additions and 30 deletions
@@ -2411,6 +2411,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract
runTest("compiler/fir/analysis-tests/testData/resolve/inference/definitelyNotNullIntersectionType.kt");
}
@TestMetadata("elvisAndUnit.kt")
public void testElvisAndUnit() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/inference/elvisAndUnit.kt");
}
@TestMetadata("extensionCallableReferences.kt")
public void testExtensionCallableReferences() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/inference/extensionCallableReferences.kt");
@@ -0,0 +1,18 @@
FILE: elvisAndUnit.kt
public final fun foo(x: R|(kotlin/Int) -> kotlin/Unit|): R|kotlin/Unit| {
}
public final class A : R|kotlin/Any| {
public constructor(): R|A| {
super<R|kotlin/Any|>()
}
public final fun bar(): R|kotlin/Unit| {
}
}
public final fun main(a: R|A?|, y: R|kotlin/String|): R|kotlin/Unit| {
R|/foo|(<L> = foo@fun <anonymous>(it: R|kotlin/Int|): R|kotlin/Unit| <inline=NoInline> {
R|<local>/a|?.{ $subj$.R|/A.bar|() } ?: R|<local>/y|.R|kotlin/String.get|(Int(0))
}
)
}
@@ -0,0 +1,11 @@
fun foo(x: (Int) -> Unit) {}
class A {
fun bar() {}
}
fun main(a: A?, y: String) {
foo {
a?.bar() ?: y.get(0)
}
}
@@ -2739,6 +2739,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest {
runTest("compiler/fir/analysis-tests/testData/resolve/inference/definitelyNotNullIntersectionType.kt");
}
@Test
@TestMetadata("elvisAndUnit.kt")
public void testElvisAndUnit() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/inference/elvisAndUnit.kt");
}
@Test
@TestMetadata("extensionCallableReferences.kt")
public void testExtensionCallableReferences() throws Exception {
@@ -2739,6 +2739,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
runTest("compiler/fir/analysis-tests/testData/resolve/inference/definitelyNotNullIntersectionType.kt");
}
@Test
@TestMetadata("elvisAndUnit.kt")
public void testElvisAndUnit() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/inference/elvisAndUnit.kt");
}
@Test
@TestMetadata("extensionCallableReferences.kt")
public void testExtensionCallableReferences() throws Exception {