From f9d690db2105008f116978571558e84e20069aaa Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Tue, 28 Apr 2015 15:12:02 +0300 Subject: [PATCH] "Make types explicit in lambda" intention: not available on right brace + adapted to new lambda syntax + refactored --- .../kotlin/idea/JetBundle.properties | 2 - .../MakeTypeExplicitInLambdaIntention.kt | 74 +++++-------------- .../coercionToUnit.kt.after | 2 +- .../emptyParamListWithBrackets.kt | 2 +- .../emptyParamListWithIt.kt.after | 2 +- .../emptyParamListWithWhiteSpace.kt.after | 2 +- .../emptyParamListWithoutItWithArrow.kt | 1 + .../emptyParamListWithoutItWithArrow.kt.after | 3 - .../invalidCursorPosition.kt | 2 +- .../lambdaWithLambdaAsParam.kt.after | 2 +- .../manyNewlines.kt.after | 2 +- .../makeTypeExplicitInLambda/multipleParam.kt | 2 +- .../multipleParam.kt.after | 2 +- .../paramDeclaredReturnNotDeclared.kt | 3 - .../paramDeclaredReturnNotDeclared.kt.after | 3 - .../returnDeclaredParamNotDeclared.kt | 3 - .../returnDeclaredParamNotDeclared.kt.after | 3 - .../shortenReferencesForParams.kt | 2 +- .../shortenReferencesForParams.kt.after | 2 +- .../shortenReferencesForReceiver.kt | 5 -- .../shortenReferencesForReceiver.kt.after | 7 -- .../shortenReferencesForReturnType.kt | 5 -- .../shortenReferencesForReturnType.kt.after | 7 -- .../singleParam.kt.after | 2 +- .../singleParamWithReceiver.kt | 9 --- .../singleParamWithReceiver.kt.after | 9 --- .../typesAlreadyExplicit.kt | 2 +- .../typesNotInferable.kt | 2 +- .../intentions/IntentionTestGenerated.java | 30 -------- 29 files changed, 34 insertions(+), 158 deletions(-) delete mode 100644 idea/testData/intentions/makeTypeExplicitInLambda/emptyParamListWithoutItWithArrow.kt.after delete mode 100644 idea/testData/intentions/makeTypeExplicitInLambda/paramDeclaredReturnNotDeclared.kt delete mode 100644 idea/testData/intentions/makeTypeExplicitInLambda/paramDeclaredReturnNotDeclared.kt.after delete mode 100644 idea/testData/intentions/makeTypeExplicitInLambda/returnDeclaredParamNotDeclared.kt delete mode 100644 idea/testData/intentions/makeTypeExplicitInLambda/returnDeclaredParamNotDeclared.kt.after delete mode 100644 idea/testData/intentions/makeTypeExplicitInLambda/shortenReferencesForReceiver.kt delete mode 100644 idea/testData/intentions/makeTypeExplicitInLambda/shortenReferencesForReceiver.kt.after delete mode 100644 idea/testData/intentions/makeTypeExplicitInLambda/shortenReferencesForReturnType.kt delete mode 100644 idea/testData/intentions/makeTypeExplicitInLambda/shortenReferencesForReturnType.kt.after delete mode 100644 idea/testData/intentions/makeTypeExplicitInLambda/singleParamWithReceiver.kt delete mode 100644 idea/testData/intentions/makeTypeExplicitInLambda/singleParamWithReceiver.kt.after diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/JetBundle.properties b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/JetBundle.properties index 2d95d68f798..09da6119316 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/JetBundle.properties +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/JetBundle.properties @@ -320,8 +320,6 @@ remove.explicit.type.arguments=Remove explicit type arguments remove.explicit.type.arguments.family=Remove Explicit Type Arguments convert.if.with.throw.to.assert=Replace 'if' with 'assert' statement convert.if.with.throw.to.assert.family=Replace 'if' with 'assert' Statement -make.type.explicit.in.lambda=Make types explicit in lambda -make.type.explicit.in.lambda.family=Make Types Explicit In Lambda make.type.implicit.in.lambda=Make types implicit in lambda (may break code) make.type.implicit.in.lambda.family=Make Types Implicit In Lambda (May Break Code) diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/MakeTypeExplicitInLambdaIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/MakeTypeExplicitInLambdaIntention.kt index 51ccd3a6a6a..a715ec7e685 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/MakeTypeExplicitInLambdaIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/MakeTypeExplicitInLambdaIntention.kt @@ -26,47 +26,39 @@ import org.jetbrains.kotlin.idea.util.ShortenReferences import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers import org.jetbrains.kotlin.idea.caches.resolve.analyze -public class MakeTypeExplicitInLambdaIntention : JetSelfTargetingIntention( - "make.type.explicit.in.lambda", javaClass()) { +public class MakeTypeExplicitInLambdaIntention : JetSelfTargetingIntention(javaClass(), "Make types explicit in lambda") { override fun isApplicableTo(element: JetFunctionLiteralExpression, caretOffset: Int): Boolean { - val openBraceOffset = element.getLeftCurlyBrace().getStartOffset() - val closeBraceOffset = element.getRightCurlyBrace()?.getStartOffset() val arrow = element.getFunctionLiteral().getArrowNode() - if (arrow != null && !(openBraceOffset < caretOffset && caretOffset < arrow.getStartOffset() + 2) && - caretOffset != closeBraceOffset) return false - else if (arrow == null && caretOffset != openBraceOffset + 1 && caretOffset != closeBraceOffset) return false + if (arrow != null) { + if (caretOffset > arrow.getTextRange().getEndOffset()) return false + if (element.getValueParameters().all { it.getTypeReference() != null }) return false + } + else { + if (!element.getLeftCurlyBrace().getTextRange().containsOffset(caretOffset)) return false + } - val context = element.analyze() - val func = context[BindingContext.FUNCTION, element.getFunctionLiteral()] - if (func == null || ErrorUtils.containsErrorType(func)) return false - - if (hasImplicitReturnType(element) && func.getReturnType() != null) return true - if (hasImplicitReceiverType(element) && func.getExtensionReceiverParameter()?.getType() != null) return true - - val params = element.getValueParameters() - return params.any { it.getTypeReference() == null } + val functionDescriptor = element.analyze()[BindingContext.FUNCTION, element.getFunctionLiteral()] ?: return false + return functionDescriptor.getValueParameters().none { it.getType().isError() } } override fun applyTo(element: JetFunctionLiteralExpression, editor: Editor) { - val functionLiteral = element.getFunctionLiteral() - val context = element.analyze() - val func = context[BindingContext.FUNCTION, functionLiteral]!! - - // Step 1: make the parameters types explicit - val valueParameters = func.getValueParameters() - val parameterString = valueParameters.map({descriptor -> "" + descriptor.getName() + - ": " + IdeDescriptorRenderers.SOURCE_CODE.renderType(descriptor.getType()) - }).makeString(", ", "(", ")") val psiFactory = JetPsiFactory(element) - val newParameterList = psiFactory.createParameterList(parameterString) + val functionLiteral = element.getFunctionLiteral() + val functionDescriptor = element.analyze()[BindingContext.FUNCTION, functionLiteral]!! + + val parameterString = functionDescriptor.getValueParameters() + .map { "${it.getName()}: ${IdeDescriptorRenderers.SOURCE_CODE.renderType(it.getType())}" } + .joinToString(", ") + + val newParameterList = psiFactory.createFunctionLiteralParameterList(parameterString) val oldParameterList = functionLiteral.getValueParameterList() if (oldParameterList != null) { oldParameterList.replace(newParameterList) } else { val openBraceElement = functionLiteral.getLBrace() - val nextSibling = openBraceElement?.getNextSibling() + val nextSibling = openBraceElement.getNextSibling() val addNewline = nextSibling is PsiWhiteSpace && nextSibling.getText()?.contains("\n") ?: false val (whitespace, arrow) = psiFactory.createWhitespaceAndArrow() functionLiteral.addRangeAfter(whitespace, arrow, openBraceElement) @@ -76,33 +68,5 @@ public class MakeTypeExplicitInLambdaIntention : JetSelfTargetingIntention x + 2}, 20) + val coercion = TestingUse().test5({ x: Int -> x + 2}, 20) } diff --git a/idea/testData/intentions/makeTypeExplicitInLambda/emptyParamListWithBrackets.kt b/idea/testData/intentions/makeTypeExplicitInLambda/emptyParamListWithBrackets.kt index dd23b95a1f5..056645ac310 100644 --- a/idea/testData/intentions/makeTypeExplicitInLambda/emptyParamListWithBrackets.kt +++ b/idea/testData/intentions/makeTypeExplicitInLambda/emptyParamListWithBrackets.kt @@ -1,4 +1,4 @@ // IS_APPLICABLE: false fun main() { - val x = {(): Unit -> } + val x = { -> } } \ No newline at end of file diff --git a/idea/testData/intentions/makeTypeExplicitInLambda/emptyParamListWithIt.kt.after b/idea/testData/intentions/makeTypeExplicitInLambda/emptyParamListWithIt.kt.after index f5580763244..dced6b154ea 100644 --- a/idea/testData/intentions/makeTypeExplicitInLambda/emptyParamListWithIt.kt.after +++ b/idea/testData/intentions/makeTypeExplicitInLambda/emptyParamListWithIt.kt.after @@ -5,5 +5,5 @@ class TestingUse { } fun main() { - val num = TestingUse().test3({(it: Int): Int -> it * 2}, 20) + val num = TestingUse().test3({ it: Int -> it * 2}, 20) } diff --git a/idea/testData/intentions/makeTypeExplicitInLambda/emptyParamListWithWhiteSpace.kt.after b/idea/testData/intentions/makeTypeExplicitInLambda/emptyParamListWithWhiteSpace.kt.after index d9f347f4472..e26175c20b7 100644 --- a/idea/testData/intentions/makeTypeExplicitInLambda/emptyParamListWithWhiteSpace.kt.after +++ b/idea/testData/intentions/makeTypeExplicitInLambda/emptyParamListWithWhiteSpace.kt.after @@ -1,6 +1,6 @@ fun main() { val oom: (Int)->Int = { - (it: Int): Int -> + it: Int -> it * 2 } } \ No newline at end of file diff --git a/idea/testData/intentions/makeTypeExplicitInLambda/emptyParamListWithoutItWithArrow.kt b/idea/testData/intentions/makeTypeExplicitInLambda/emptyParamListWithoutItWithArrow.kt index e6f6b454919..5fd5094c633 100644 --- a/idea/testData/intentions/makeTypeExplicitInLambda/emptyParamListWithoutItWithArrow.kt +++ b/idea/testData/intentions/makeTypeExplicitInLambda/emptyParamListWithoutItWithArrow.kt @@ -1,3 +1,4 @@ +// IS_APPLICABLE: false fun main() { val oom = { -> 42} } diff --git a/idea/testData/intentions/makeTypeExplicitInLambda/emptyParamListWithoutItWithArrow.kt.after b/idea/testData/intentions/makeTypeExplicitInLambda/emptyParamListWithoutItWithArrow.kt.after deleted file mode 100644 index 9f6582965d4..00000000000 --- a/idea/testData/intentions/makeTypeExplicitInLambda/emptyParamListWithoutItWithArrow.kt.after +++ /dev/null @@ -1,3 +0,0 @@ -fun main() { - val oom = {(): Int -> 42} -} diff --git a/idea/testData/intentions/makeTypeExplicitInLambda/invalidCursorPosition.kt b/idea/testData/intentions/makeTypeExplicitInLambda/invalidCursorPosition.kt index 098ae20fd93..6d25834fb08 100644 --- a/idea/testData/intentions/makeTypeExplicitInLambda/invalidCursorPosition.kt +++ b/idea/testData/intentions/makeTypeExplicitInLambda/invalidCursorPosition.kt @@ -1,4 +1,4 @@ // IS_APPLICABLE: false fun main() { - val sum : (Int, Int) -> Int = { (x, y) -> x + y } + val sum : (Int, Int) -> Int = { x, y -> x + y } } diff --git a/idea/testData/intentions/makeTypeExplicitInLambda/lambdaWithLambdaAsParam.kt.after b/idea/testData/intentions/makeTypeExplicitInLambda/lambdaWithLambdaAsParam.kt.after index 217c9afeae6..7b53a0a3306 100644 --- a/idea/testData/intentions/makeTypeExplicitInLambda/lambdaWithLambdaAsParam.kt.after +++ b/idea/testData/intentions/makeTypeExplicitInLambda/lambdaWithLambdaAsParam.kt.after @@ -4,5 +4,5 @@ public class TestingUse { } fun main() { - val funcInfunc = TestingUse().test6({(f: (Int) -> Int): Boolean -> f(5) > 20}, {x -> x + 2}) + val funcInfunc = TestingUse().test6({ f: (Int) -> Int -> f(5) > 20}, {x -> x + 2}) } diff --git a/idea/testData/intentions/makeTypeExplicitInLambda/manyNewlines.kt.after b/idea/testData/intentions/makeTypeExplicitInLambda/manyNewlines.kt.after index 38f3bf3f09b..614881f168c 100644 --- a/idea/testData/intentions/makeTypeExplicitInLambda/manyNewlines.kt.after +++ b/idea/testData/intentions/makeTypeExplicitInLambda/manyNewlines.kt.after @@ -1,5 +1,5 @@ val foo: (Long) -> String = { - (it: Long): String -> + it: Long -> it.toString() diff --git a/idea/testData/intentions/makeTypeExplicitInLambda/multipleParam.kt b/idea/testData/intentions/makeTypeExplicitInLambda/multipleParam.kt index 45880decb20..37ff9e43c3a 100644 --- a/idea/testData/intentions/makeTypeExplicitInLambda/multipleParam.kt +++ b/idea/testData/intentions/makeTypeExplicitInLambda/multipleParam.kt @@ -6,5 +6,5 @@ class TestingUse { } fun main() { - val num = TestingUse().test4({(x, str) -> }, 5) + val num = TestingUse().test4({ x, str -> }, 5) } diff --git a/idea/testData/intentions/makeTypeExplicitInLambda/multipleParam.kt.after b/idea/testData/intentions/makeTypeExplicitInLambda/multipleParam.kt.after index 983d8a2ca41..85586820feb 100644 --- a/idea/testData/intentions/makeTypeExplicitInLambda/multipleParam.kt.after +++ b/idea/testData/intentions/makeTypeExplicitInLambda/multipleParam.kt.after @@ -6,5 +6,5 @@ class TestingUse { } fun main() { - val num = TestingUse().test4({(x: Int, str: String): Unit -> }, 5) + val num = TestingUse().test4({ x: Int, str: String -> }, 5) } diff --git a/idea/testData/intentions/makeTypeExplicitInLambda/paramDeclaredReturnNotDeclared.kt b/idea/testData/intentions/makeTypeExplicitInLambda/paramDeclaredReturnNotDeclared.kt deleted file mode 100644 index 5e6a7954e0c..00000000000 --- a/idea/testData/intentions/makeTypeExplicitInLambda/paramDeclaredReturnNotDeclared.kt +++ /dev/null @@ -1,3 +0,0 @@ -fun main() { - val foo: (Int) -> String = {(x: Int) -> "This number is " + x} -} diff --git a/idea/testData/intentions/makeTypeExplicitInLambda/paramDeclaredReturnNotDeclared.kt.after b/idea/testData/intentions/makeTypeExplicitInLambda/paramDeclaredReturnNotDeclared.kt.after deleted file mode 100644 index 1b3c48ff2d6..00000000000 --- a/idea/testData/intentions/makeTypeExplicitInLambda/paramDeclaredReturnNotDeclared.kt.after +++ /dev/null @@ -1,3 +0,0 @@ -fun main() { - val foo: (Int) -> String = {(x: Int): String -> "This number is " + x} -} diff --git a/idea/testData/intentions/makeTypeExplicitInLambda/returnDeclaredParamNotDeclared.kt b/idea/testData/intentions/makeTypeExplicitInLambda/returnDeclaredParamNotDeclared.kt deleted file mode 100644 index e3ea2cf2faa..00000000000 --- a/idea/testData/intentions/makeTypeExplicitInLambda/returnDeclaredParamNotDeclared.kt +++ /dev/null @@ -1,3 +0,0 @@ -fun main() { - val bar: (Array) -> Int = {(arr): Int -> arr.size()} -} diff --git a/idea/testData/intentions/makeTypeExplicitInLambda/returnDeclaredParamNotDeclared.kt.after b/idea/testData/intentions/makeTypeExplicitInLambda/returnDeclaredParamNotDeclared.kt.after deleted file mode 100644 index 47d116f73c3..00000000000 --- a/idea/testData/intentions/makeTypeExplicitInLambda/returnDeclaredParamNotDeclared.kt.after +++ /dev/null @@ -1,3 +0,0 @@ -fun main() { - val bar: (Array) -> Int = {(arr: Array): Int -> arr.size()} -} diff --git a/idea/testData/intentions/makeTypeExplicitInLambda/shortenReferencesForParams.kt b/idea/testData/intentions/makeTypeExplicitInLambda/shortenReferencesForParams.kt index df031f8598d..f7785151a54 100644 --- a/idea/testData/intentions/makeTypeExplicitInLambda/shortenReferencesForParams.kt +++ b/idea/testData/intentions/makeTypeExplicitInLambda/shortenReferencesForParams.kt @@ -1,5 +1,5 @@ fun main() { - val randomFunction: (x: kotlin.support.AbstractIterator, y: kotlin.String) -> kotlin.String = {(x, str) -> str} + val randomFunction: (x: kotlin.support.AbstractIterator, y: kotlin.String) -> kotlin.String = { x, str -> str} } // WITH_RUNTIME diff --git a/idea/testData/intentions/makeTypeExplicitInLambda/shortenReferencesForParams.kt.after b/idea/testData/intentions/makeTypeExplicitInLambda/shortenReferencesForParams.kt.after index ca4829fea0b..57f2ebec41f 100644 --- a/idea/testData/intentions/makeTypeExplicitInLambda/shortenReferencesForParams.kt.after +++ b/idea/testData/intentions/makeTypeExplicitInLambda/shortenReferencesForParams.kt.after @@ -1,7 +1,7 @@ import kotlin.support.AbstractIterator fun main() { - val randomFunction: (x: kotlin.support.AbstractIterator, y: kotlin.String) -> kotlin.String = {(x: AbstractIterator, str: String): String -> str} + val randomFunction: (x: kotlin.support.AbstractIterator, y: kotlin.String) -> kotlin.String = { x: AbstractIterator, str: String -> str} } // WITH_RUNTIME diff --git a/idea/testData/intentions/makeTypeExplicitInLambda/shortenReferencesForReceiver.kt b/idea/testData/intentions/makeTypeExplicitInLambda/shortenReferencesForReceiver.kt deleted file mode 100644 index 859964c0485..00000000000 --- a/idea/testData/intentions/makeTypeExplicitInLambda/shortenReferencesForReceiver.kt +++ /dev/null @@ -1,5 +0,0 @@ -fun main() { - val randomFunction: kotlin.support.AbstractIterator.(x: Int) -> Boolean = {y -> if (this.next() < y) true else false} -} - -// WITH_RUNTIME \ No newline at end of file diff --git a/idea/testData/intentions/makeTypeExplicitInLambda/shortenReferencesForReceiver.kt.after b/idea/testData/intentions/makeTypeExplicitInLambda/shortenReferencesForReceiver.kt.after deleted file mode 100644 index 48216e982c5..00000000000 --- a/idea/testData/intentions/makeTypeExplicitInLambda/shortenReferencesForReceiver.kt.after +++ /dev/null @@ -1,7 +0,0 @@ -import kotlin.support.AbstractIterator - -fun main() { - val randomFunction: kotlin.support.AbstractIterator.(x: Int) -> Boolean = { AbstractIterator.(y: Int): Boolean -> if (this.next() < y) true else false} -} - -// WITH_RUNTIME \ No newline at end of file diff --git a/idea/testData/intentions/makeTypeExplicitInLambda/shortenReferencesForReturnType.kt b/idea/testData/intentions/makeTypeExplicitInLambda/shortenReferencesForReturnType.kt deleted file mode 100644 index 78d9f627c3f..00000000000 --- a/idea/testData/intentions/makeTypeExplicitInLambda/shortenReferencesForReturnType.kt +++ /dev/null @@ -1,5 +0,0 @@ -fun main(c: kotlin.support.AbstractIterator) { - val f = { (x: Int) -> c} -} - -// WITH_RUNTIME \ No newline at end of file diff --git a/idea/testData/intentions/makeTypeExplicitInLambda/shortenReferencesForReturnType.kt.after b/idea/testData/intentions/makeTypeExplicitInLambda/shortenReferencesForReturnType.kt.after deleted file mode 100644 index 2db59b07c55..00000000000 --- a/idea/testData/intentions/makeTypeExplicitInLambda/shortenReferencesForReturnType.kt.after +++ /dev/null @@ -1,7 +0,0 @@ -import kotlin.support.AbstractIterator - -fun main(c: kotlin.support.AbstractIterator) { - val f = {(x: Int): AbstractIterator -> c} -} - -// WITH_RUNTIME \ No newline at end of file diff --git a/idea/testData/intentions/makeTypeExplicitInLambda/singleParam.kt.after b/idea/testData/intentions/makeTypeExplicitInLambda/singleParam.kt.after index 9de39b39c6b..6adcdabce40 100644 --- a/idea/testData/intentions/makeTypeExplicitInLambda/singleParam.kt.after +++ b/idea/testData/intentions/makeTypeExplicitInLambda/singleParam.kt.after @@ -5,5 +5,5 @@ class TestingUse { } fun main() { - val num = TestingUse().test3({(x: Int): Int -> 2*x}, 20) + val num = TestingUse().test3({ x: Int -> 2*x}, 20) } diff --git a/idea/testData/intentions/makeTypeExplicitInLambda/singleParamWithReceiver.kt b/idea/testData/intentions/makeTypeExplicitInLambda/singleParamWithReceiver.kt deleted file mode 100644 index e3d74a97d33..00000000000 --- a/idea/testData/intentions/makeTypeExplicitInLambda/singleParamWithReceiver.kt +++ /dev/null @@ -1,9 +0,0 @@ -class TestingUse { - fun test(sum: Int.(a: Int) -> Int, b: Int): Int { - return b.sum(b) - } -} - -fun main() { - val num = TestingUse().test({ x -> x + 2 }, 20) -} diff --git a/idea/testData/intentions/makeTypeExplicitInLambda/singleParamWithReceiver.kt.after b/idea/testData/intentions/makeTypeExplicitInLambda/singleParamWithReceiver.kt.after deleted file mode 100644 index 81cebbe7ce7..00000000000 --- a/idea/testData/intentions/makeTypeExplicitInLambda/singleParamWithReceiver.kt.after +++ /dev/null @@ -1,9 +0,0 @@ -class TestingUse { - fun test(sum: Int.(a: Int) -> Int, b: Int): Int { - return b.sum(b) - } -} - -fun main() { - val num = TestingUse().test({ Int.(x: Int): Int -> x + 2 }, 20) -} diff --git a/idea/testData/intentions/makeTypeExplicitInLambda/typesAlreadyExplicit.kt b/idea/testData/intentions/makeTypeExplicitInLambda/typesAlreadyExplicit.kt index 39895a0de09..1e73c8d4af4 100644 --- a/idea/testData/intentions/makeTypeExplicitInLambda/typesAlreadyExplicit.kt +++ b/idea/testData/intentions/makeTypeExplicitInLambda/typesAlreadyExplicit.kt @@ -1,4 +1,4 @@ // IS_APPLICABLE: false fun main() { - val sum = { Int.(x: Int, y: Int) : Int -> x + y } + val sum = { x: Int, y: Int -> x + y } } diff --git a/idea/testData/intentions/makeTypeExplicitInLambda/typesNotInferable.kt b/idea/testData/intentions/makeTypeExplicitInLambda/typesNotInferable.kt index 85ae3415552..2f7c6517d7d 100644 --- a/idea/testData/intentions/makeTypeExplicitInLambda/typesNotInferable.kt +++ b/idea/testData/intentions/makeTypeExplicitInLambda/typesNotInferable.kt @@ -2,5 +2,5 @@ // ERROR: Cannot infer a type for this parameter. Please specify it explicitly. // ERROR: Cannot infer a type for this parameter. Please specify it explicitly. fun main() { - val sum = { (x, y) -> x + y // Type of x and y cannot be inferred, so intention can't be used + val sum = { x, y -> x + y // Type of x and y cannot be inferred, so intention can't be used } diff --git a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java index 3e7167b4a3d..40e58752c17 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java @@ -4411,48 +4411,18 @@ public class IntentionTestGenerated extends AbstractIntentionTest { doTest(fileName); } - @TestMetadata("paramDeclaredReturnNotDeclared.kt") - public void testParamDeclaredReturnNotDeclared() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/makeTypeExplicitInLambda/paramDeclaredReturnNotDeclared.kt"); - doTest(fileName); - } - - @TestMetadata("returnDeclaredParamNotDeclared.kt") - public void testReturnDeclaredParamNotDeclared() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/makeTypeExplicitInLambda/returnDeclaredParamNotDeclared.kt"); - doTest(fileName); - } - @TestMetadata("shortenReferencesForParams.kt") public void testShortenReferencesForParams() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/makeTypeExplicitInLambda/shortenReferencesForParams.kt"); doTest(fileName); } - @TestMetadata("shortenReferencesForReceiver.kt") - public void testShortenReferencesForReceiver() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/makeTypeExplicitInLambda/shortenReferencesForReceiver.kt"); - doTest(fileName); - } - - @TestMetadata("shortenReferencesForReturnType.kt") - public void testShortenReferencesForReturnType() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/makeTypeExplicitInLambda/shortenReferencesForReturnType.kt"); - doTest(fileName); - } - @TestMetadata("singleParam.kt") public void testSingleParam() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/makeTypeExplicitInLambda/singleParam.kt"); doTest(fileName); } - @TestMetadata("singleParamWithReceiver.kt") - public void testSingleParamWithReceiver() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/makeTypeExplicitInLambda/singleParamWithReceiver.kt"); - doTest(fileName); - } - @TestMetadata("typesAlreadyExplicit.kt") public void testTypesAlreadyExplicit() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/makeTypeExplicitInLambda/typesAlreadyExplicit.kt");