Create DONT_CARE type only for dependent lambdas (i.e. to be resolved through the type inference later)

^KT-47493 Fixed
This commit is contained in:
Victor Petukhov
2021-08-06 10:13:35 +03:00
committed by teamcityserver
parent dbdc6176f0
commit 1966915e92
9 changed files with 58 additions and 1 deletions

View File

@@ -16610,6 +16610,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/functions/kt47527.kt");
}
@Test
@TestMetadata("kt48058.kt")
public void testKt48058() throws Exception {
runTest("compiler/testData/codegen/box/functions/kt48058.kt");
}
@Test
@TestMetadata("kt785.kt")
public void testKt785() throws Exception {

View File

@@ -394,7 +394,7 @@ public class ExpressionTypingServices {
return blockLevelVisitor.getTypeInfo(statementExpression, context.replaceExpectedType(expectedType), true);
}
if (KtPsiUtil.deparenthesize(statementExpression) instanceof KtLambdaExpression) {
if (KtPsiUtil.deparenthesize(statementExpression) instanceof KtLambdaExpression && context.contextDependency == ContextDependency.DEPENDENT) {
KotlinTypeInfo typeInfo = createDontCareTypeInfoForNILambda(statementExpression, context);
if (typeInfo != null) return typeInfo;
}

View File

@@ -0,0 +1,19 @@
// DONT_TARGET_EXACT_BACKEND: WASM
fun doCall(block: Any ):Int {
(block as () -> Unit)()
return 1
}
fun test1() =
doCall {
try {}
finally {
{}
}
}
fun box(): String {
test1()
return "OK"
}

View File

@@ -16490,6 +16490,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/functions/kt47527.kt");
}
@Test
@TestMetadata("kt48058.kt")
public void testKt48058() throws Exception {
runTest("compiler/testData/codegen/box/functions/kt48058.kt");
}
@Test
@TestMetadata("kt785.kt")
public void testKt785() throws Exception {

View File

@@ -16610,6 +16610,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/functions/kt47527.kt");
}
@Test
@TestMetadata("kt48058.kt")
public void testKt48058() throws Exception {
runTest("compiler/testData/codegen/box/functions/kt48058.kt");
}
@Test
@TestMetadata("kt785.kt")
public void testKt785() throws Exception {

View File

@@ -13614,6 +13614,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/functions/kt47527.kt");
}
@TestMetadata("kt48058.kt")
public void testKt48058() throws Exception {
runTest("compiler/testData/codegen/box/functions/kt48058.kt");
}
@TestMetadata("kt785.kt")
public void testKt785() throws Exception {
runTest("compiler/testData/codegen/box/functions/kt785.kt");

View File

@@ -11983,6 +11983,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
runTest("compiler/testData/codegen/box/functions/kt47527.kt");
}
@TestMetadata("kt48058.kt")
public void testKt48058() throws Exception {
runTest("compiler/testData/codegen/box/functions/kt48058.kt");
}
@TestMetadata("kt785.kt")
public void testKt785() throws Exception {
runTest("compiler/testData/codegen/box/functions/kt785.kt");

View File

@@ -11389,6 +11389,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/functions/kt47527.kt");
}
@TestMetadata("kt48058.kt")
public void testKt48058() throws Exception {
runTest("compiler/testData/codegen/box/functions/kt48058.kt");
}
@TestMetadata("kt785.kt")
public void testKt785() throws Exception {
runTest("compiler/testData/codegen/box/functions/kt785.kt");

View File

@@ -11389,6 +11389,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/functions/kt47527.kt");
}
@TestMetadata("kt48058.kt")
public void testKt48058() throws Exception {
runTest("compiler/testData/codegen/box/functions/kt48058.kt");
}
@TestMetadata("kt785.kt")
public void testKt785() throws Exception {
runTest("compiler/testData/codegen/box/functions/kt785.kt");