FIR: Fix inference when unit value should be cast to Any
This commit is contained in:
committed by
teamcityserver
parent
d3fc22fc6a
commit
c3646b11ac
+5
@@ -2485,6 +2485,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract
|
||||
public void testTypeDepthForTypeAlias() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/inference/typeDepthForTypeAlias.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("unitUpperBound.kt")
|
||||
public void testUnitUpperBound() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/inference/unitUpperBound.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/inlineClasses")
|
||||
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
FILE: unitUpperBound.kt
|
||||
public final class A : R|kotlin/Any| {
|
||||
public constructor(): R|A| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final fun foo(x: R|kotlin/collections/List<kotlin/String>|): R|kotlin/Unit| {
|
||||
lvar w: R|kotlin/Int| = Int(1)
|
||||
R|<local>/x|.R|kotlin/collections/ifEmpty|<R|kotlin/collections/List<kotlin/String>|, R|kotlin/Any|>(<L> = ifEmpty@fun <anonymous>(): R|kotlin/Any| <inline=Inline, kind=UNKNOWN> {
|
||||
R|<local>/w| = R|<local>/w|.R|kotlin/Int.plus|(Int(2))
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// WITH_STDLIB
|
||||
// FULL_JDK
|
||||
|
||||
class A {
|
||||
fun foo(x: List<String>) {
|
||||
var w = 1
|
||||
x.ifEmpty {
|
||||
w += 2
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
@@ -2828,6 +2828,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest {
|
||||
public void testTypeDepthForTypeAlias() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/inference/typeDepthForTypeAlias.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unitUpperBound.kt")
|
||||
public void testUnitUpperBound() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/inference/unitUpperBound.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
+6
@@ -2828,6 +2828,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
|
||||
public void testTypeDepthForTypeAlias() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/inference/typeDepthForTypeAlias.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unitUpperBound.kt")
|
||||
public void testUnitUpperBound() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/inference/unitUpperBound.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
+2
-3
@@ -197,10 +197,9 @@ class PostponedArgumentsAnalyzer(
|
||||
}
|
||||
|
||||
if (!hasExpressionInReturnArguments && lambdaReturnType != null) {
|
||||
/*LambdaArgumentConstraintPosition(lambda)*/
|
||||
c.getBuilder().addEqualityConstraint(
|
||||
lambdaReturnType,
|
||||
c.getBuilder().addSubtypeConstraint(
|
||||
components.session.builtinTypes.unitType.type,
|
||||
lambdaReturnType,
|
||||
ConeLambdaArgumentConstraintPosition(lambda.atom)
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user