[NI] Fix issue with returning non-deparenthesized lambdas from labmdas
#KT-36080 Fixed
This commit is contained in:
Generated
+5
@@ -10076,6 +10076,11 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
|
|||||||
runTest("compiler/testData/diagnostics/tests/inference/kt619.kt");
|
runTest("compiler/testData/diagnostics/tests/inference/kt619.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("lambdaArgumentWithLabel.kt")
|
||||||
|
public void testLambdaArgumentWithLabel() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/inference/lambdaArgumentWithLabel.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("lambdaInValInitializerWithAnonymousFunctions.kt")
|
@TestMetadata("lambdaInValInitializerWithAnonymousFunctions.kt")
|
||||||
public void testLambdaInValInitializerWithAnonymousFunctions() throws Exception {
|
public void testLambdaInValInitializerWithAnonymousFunctions() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/inference/lambdaInValInitializerWithAnonymousFunctions.kt");
|
runTest("compiler/testData/diagnostics/tests/inference/lambdaInValInitializerWithAnonymousFunctions.kt");
|
||||||
|
|||||||
+4
-1
@@ -896,7 +896,10 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
if (returnedExpression != null) {
|
if (returnedExpression != null) {
|
||||||
if (newInferenceLambdaInfo != null) {
|
if (newInferenceLambdaInfo != null) {
|
||||||
LambdaContextInfo contextInfo;
|
LambdaContextInfo contextInfo;
|
||||||
if (returnedExpression instanceof KtLambdaExpression || returnedExpression instanceof KtCallableReferenceExpression) {
|
KtExpression deparenthesizedReturnExpression = KtPsiUtil.deparenthesize(returnedExpression);
|
||||||
|
if (deparenthesizedReturnExpression instanceof KtLambdaExpression ||
|
||||||
|
deparenthesizedReturnExpression instanceof KtCallableReferenceExpression
|
||||||
|
) {
|
||||||
contextInfo = new LambdaContextInfo(
|
contextInfo = new LambdaContextInfo(
|
||||||
new KotlinTypeInfo(DONT_CARE, context.dataFlowInfo),
|
new KotlinTypeInfo(DONT_CARE, context.dataFlowInfo),
|
||||||
null,
|
null,
|
||||||
|
|||||||
+1
-1
@@ -385,7 +385,7 @@ public class ExpressionTypingServices {
|
|||||||
return blockLevelVisitor.getTypeInfo(statementExpression, context.replaceExpectedType(expectedType), true);
|
return blockLevelVisitor.getTypeInfo(statementExpression, context.replaceExpectedType(expectedType), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (statementExpression instanceof KtLambdaExpression) {
|
if (KtPsiUtil.deparenthesize(statementExpression) instanceof KtLambdaExpression) {
|
||||||
KotlinTypeInfo typeInfo = createDontCareTypeInfoForNILambda(statementExpression, context);
|
KotlinTypeInfo typeInfo = createDontCareTypeInfoForNILambda(statementExpression, context);
|
||||||
if (typeInfo != null) return typeInfo;
|
if (typeInfo != null) return typeInfo;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
// !LANGUAGE: +NewInference
|
||||||
|
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||||
|
|
||||||
|
val x1: (String) -> Unit = run {
|
||||||
|
lambda@{ foo ->
|
||||||
|
bar(foo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val x2: (String) -> Unit = run {
|
||||||
|
({ foo ->
|
||||||
|
bar(foo)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
val x3: (String) -> Unit = run {
|
||||||
|
(lambda@{ foo ->
|
||||||
|
bar(foo)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
val x4: (String) -> Unit = run {
|
||||||
|
return@run (lambda@{ foo ->
|
||||||
|
bar(foo)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fun bar(s: String) {}
|
||||||
|
fun <R> run(block: () -> R): R = block()
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
// !LANGUAGE: +NewInference
|
||||||
|
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||||
|
|
||||||
|
val x1: (String) -> Unit = run {
|
||||||
|
lambda@{ foo ->
|
||||||
|
bar(foo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val x2: (String) -> Unit = run {
|
||||||
|
({ foo ->
|
||||||
|
bar(foo)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
val x3: (String) -> Unit = run {
|
||||||
|
(lambda@{ foo ->
|
||||||
|
bar(foo)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
val x4: (String) -> Unit = run {
|
||||||
|
return@run (lambda@{ foo ->
|
||||||
|
bar(foo)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fun bar(s: String) {}
|
||||||
|
fun <R> run(block: () -> R): R = block()
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public val x1: (kotlin.String) -> kotlin.Unit
|
||||||
|
public val x2: (kotlin.String) -> kotlin.Unit
|
||||||
|
public val x3: (kotlin.String) -> kotlin.Unit
|
||||||
|
public val x4: (kotlin.String) -> kotlin.Unit
|
||||||
|
public fun bar(/*0*/ s: kotlin.String): kotlin.Unit
|
||||||
|
public fun </*0*/ R> run(/*0*/ block: () -> R): R
|
||||||
@@ -10083,6 +10083,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
|||||||
runTest("compiler/testData/diagnostics/tests/inference/kt619.kt");
|
runTest("compiler/testData/diagnostics/tests/inference/kt619.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("lambdaArgumentWithLabel.kt")
|
||||||
|
public void testLambdaArgumentWithLabel() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/inference/lambdaArgumentWithLabel.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("lambdaInValInitializerWithAnonymousFunctions.kt")
|
@TestMetadata("lambdaInValInitializerWithAnonymousFunctions.kt")
|
||||||
public void testLambdaInValInitializerWithAnonymousFunctions() throws Exception {
|
public void testLambdaInValInitializerWithAnonymousFunctions() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/inference/lambdaInValInitializerWithAnonymousFunctions.kt");
|
runTest("compiler/testData/diagnostics/tests/inference/lambdaInValInitializerWithAnonymousFunctions.kt");
|
||||||
|
|||||||
Generated
+5
@@ -10078,6 +10078,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
|
|||||||
runTest("compiler/testData/diagnostics/tests/inference/kt619.kt");
|
runTest("compiler/testData/diagnostics/tests/inference/kt619.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("lambdaArgumentWithLabel.kt")
|
||||||
|
public void testLambdaArgumentWithLabel() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/inference/lambdaArgumentWithLabel.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("lambdaInValInitializerWithAnonymousFunctions.kt")
|
@TestMetadata("lambdaInValInitializerWithAnonymousFunctions.kt")
|
||||||
public void testLambdaInValInitializerWithAnonymousFunctions() throws Exception {
|
public void testLambdaInValInitializerWithAnonymousFunctions() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/inference/lambdaInValInitializerWithAnonymousFunctions.kt");
|
runTest("compiler/testData/diagnostics/tests/inference/lambdaInValInitializerWithAnonymousFunctions.kt");
|
||||||
|
|||||||
+5
-5
@@ -14720,11 +14720,6 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
public static class NotNullAssertions extends AbstractLightAnalysisModeTest {
|
public static class NotNullAssertions extends AbstractLightAnalysisModeTest {
|
||||||
@TestMetadata("paramAssertionMessage.kt")
|
|
||||||
public void ignoreParamAssertionMessage() throws Exception {
|
|
||||||
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/paramAssertionMessage.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void runTest(String testDataFilePath) throws Exception {
|
private void runTest(String testDataFilePath) throws Exception {
|
||||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
|
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
|
||||||
}
|
}
|
||||||
@@ -14813,6 +14808,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullableTypeParameter.kt");
|
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullableTypeParameter.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("paramAssertionMessage.kt")
|
||||||
|
public void testParamAssertionMessage() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/paramAssertionMessage.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("staticCallErrorMessage.kt")
|
@TestMetadata("staticCallErrorMessage.kt")
|
||||||
public void testStaticCallErrorMessage() throws Exception {
|
public void testStaticCallErrorMessage() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/staticCallErrorMessage.kt");
|
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/staticCallErrorMessage.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user