From 5c445ca0033dd03b947d6b94ebc8de6ff9b1cf3b Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Tue, 19 May 2015 23:44:58 +0300 Subject: [PATCH] DeprecatedSymbolUsageFix: dealing with dropping arguments with potential side effects + stdlib's "let" has no receiver type bound --- .../idea/quickfix/DeprecatedSymbolUsageFix.kt | 80 +++++++++++-------- .../complexExpressionNotUsed1.kt | 14 ++++ .../complexExpressionNotUsed1.kt.after | 15 ++++ .../complexExpressionNotUsed2.kt | 16 ++++ .../complexExpressionNotUsed2.kt.after | 17 ++++ .../complexExpressionNotUsed3Runtime.kt | 14 ++++ .../complexExpressionNotUsed3Runtime.kt.after | 14 ++++ .../complexExpressionNotUsed4Runtime.kt | 12 +++ .../complexExpressionNotUsed4Runtime.kt.after | 12 +++ .../complexExpressionNotUsed5Runtime.kt | 14 ++++ .../complexExpressionNotUsed5Runtime.kt.after | 14 ++++ .../complexExpressionNotUsedSafeCall.kt | 16 ++++ .../complexExpressionNotUsedSafeCall.kt.after | 18 +++++ ...omplexExpressionNotUsedSafeCall2Runtime.kt | 16 ++++ ...ExpressionNotUsedSafeCall2Runtime.kt.after | 16 ++++ .../complexExpressionUsedTwice6Runtime.kt | 14 ++++ ...omplexExpressionUsedTwice6Runtime.kt.after | 14 ++++ .../simpleExpressionNotUsed.kt | 16 ++++ .../simpleExpressionNotUsed.kt.after | 16 ++++ .../idea/quickfix/QuickFixTestGenerated.java | 54 +++++++++++++ libraries/stdlib/src/kotlin/util/Standard.kt | 2 +- 21 files changed, 369 insertions(+), 35 deletions(-) create mode 100644 idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsed1.kt create mode 100644 idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsed1.kt.after create mode 100644 idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsed2.kt create mode 100644 idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsed2.kt.after create mode 100644 idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsed3Runtime.kt create mode 100644 idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsed3Runtime.kt.after create mode 100644 idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsed4Runtime.kt create mode 100644 idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsed4Runtime.kt.after create mode 100644 idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsed5Runtime.kt create mode 100644 idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsed5Runtime.kt.after create mode 100644 idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsedSafeCall.kt create mode 100644 idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsedSafeCall.kt.after create mode 100644 idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsedSafeCall2Runtime.kt create mode 100644 idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsedSafeCall2Runtime.kt.after create mode 100644 idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionUsedTwice6Runtime.kt create mode 100644 idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionUsedTwice6Runtime.kt.after create mode 100644 idea/testData/quickfix/deprecatedSymbolUsage/simpleExpressionNotUsed.kt create mode 100644 idea/testData/quickfix/deprecatedSymbolUsage/simpleExpressionNotUsed.kt.after diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedSymbolUsageFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedSymbolUsageFix.kt index 23afaef40ff..853c3ea584c 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedSymbolUsageFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedSymbolUsageFix.kt @@ -137,7 +137,6 @@ public class DeprecatedSymbolUsageFix( val introduceValuesForParameters = ArrayList>() - //TODO: check for dropping expressions with potential side effects for (parameter in descriptor.getValueParameters()) { val argument = argumentForParameter(parameter) ?: continue argument.putCopyableUserData(FROM_PARAMETER_KEY, parameter) @@ -146,7 +145,7 @@ public class DeprecatedSymbolUsageFix( val usages = parameterUsages[parameter.getOriginal()]!! usages.forEach { it.replace(argument) } - if (usages.size() > 1 && argument.shouldIntroduceVariableIfUsedTwice()) { + if (argument.shouldKeepValue(usages.size())) { introduceValuesForParameters.add(parameter to argument) } } @@ -158,16 +157,15 @@ public class DeprecatedSymbolUsageFix( expression = expression.keepInfixFormIfPossible() } - if (receiver != null && receiver.shouldIntroduceVariableIfUsedTwice()) { + if (receiver != null) { val thisReplaced = expression.collectElementsOfType { it.getCopyableUserData(FROM_THIS_KEY) != null } - if (thisReplaced.size() > 1) { + if (receiver.shouldKeepValue(thisReplaced.size())) { expression = expression.introduceValue(receiver, expressionToReplace, bindingContext, thisReplaced) } } for ((parameter, value) in introduceValuesForParameters) { val usagesReplaced = expression.collectElementsOfType { it.getCopyableUserData(FROM_PARAMETER_KEY) == parameter } - assert(usagesReplaced.size() > 1) expression = expression.introduceValue(value, expressionToReplace, bindingContext, usagesReplaced, nameSuggestion = parameter.getName().asString()) } @@ -282,33 +280,39 @@ public class DeprecatedSymbolUsageFix( if (block != null) { val resolutionScope = bindingContext[BindingContext.RESOLUTION_SCOPE, insertDeclarationsBefore] - val valueType = bindingContext.getType(value) - var explicitType: JetType? = null - if (valueType != null && !ErrorUtils.containsErrorType(valueType)) { - val valueTypeWithoutExpectedType = value.analyzeInContext( - resolutionScope, - dataFlowInfo = bindingContext.getDataFlowInfo(insertDeclarationsBefore) - ).getType(value) - if (valueTypeWithoutExpectedType == null || ErrorUtils.containsErrorType(valueTypeWithoutExpectedType)) { - explicitType = valueType + if (usages.isNotEmpty()) { + val valueType = bindingContext.getType(value) + var explicitType: JetType? = null + if (valueType != null && !ErrorUtils.containsErrorType(valueType)) { + val valueTypeWithoutExpectedType = value.analyzeInContext( + resolutionScope, + dataFlowInfo = bindingContext.getDataFlowInfo(insertDeclarationsBefore) + ).getType(value) + if (valueTypeWithoutExpectedType == null || ErrorUtils.containsErrorType(valueTypeWithoutExpectedType)) { + explicitType = valueType + } } - } - val name = suggestName(object : JetNameValidator() { - override fun validateInner(name: String): Boolean { - return resolutionScope.getLocalVariable(Name.identifier(name)) == null && !isNameUsed(name) + val name = suggestName(object : JetNameValidator() { + override fun validateInner(name: String): Boolean { + return resolutionScope.getLocalVariable(Name.identifier(name)) == null && !isNameUsed(name) + } + }) + + var declaration = psiFactory.createDeclaration("val ${nameInCode(name)} = " + value.getText()) + declaration = block.addBefore(declaration, insertDeclarationsBefore) as JetVariableDeclaration + block.addBefore(psiFactory.createNewLine(), insertDeclarationsBefore) + + if (explicitType != null) { + declaration.setType(explicitType) } - }) - var declaration = psiFactory.createDeclaration("val ${nameInCode(name)} = " + value.getText()) - declaration = block.addBefore(declaration, insertDeclarationsBefore) as JetVariableDeclaration - block.addBefore(psiFactory.createNewLine(), insertDeclarationsBefore) - - if (explicitType != null) { - declaration.setType(explicitType) + replaceUsages(name) + } + else { + block.addBefore(value, insertDeclarationsBefore) + block.addBefore(psiFactory.createNewLine(), insertDeclarationsBefore) } - - replaceUsages(name) return this } } @@ -331,15 +335,23 @@ public class DeprecatedSymbolUsageFix( private fun collectNameUsages(scope: JetExpression, name: String) = scope.collectElementsOfType { it.getReceiverExpression() == null && it.getReferencedName() == name } - private fun JetExpression?.shouldIntroduceVariableIfUsedTwice(): Boolean { + private fun JetExpression?.shouldKeepValue(usageCount: Int): Boolean { + if (usageCount == 1) return false + val sideEffectOnly = usageCount == 0 + return when (this) { is JetSimpleNameExpression -> false - is JetQualifiedExpression -> getReceiverExpression().shouldIntroduceVariableIfUsedTwice() || getSelectorExpression().shouldIntroduceVariableIfUsedTwice() - is JetUnaryExpression -> getOperationToken() in setOf(JetTokens.PLUSPLUS, JetTokens.MINUSMINUS) || getBaseExpression().shouldIntroduceVariableIfUsedTwice() - is JetStringTemplateExpression -> getEntries().any { it is JetStringTemplateEntryWithExpression } - is JetThisExpression, is JetSuperExpression -> false - is JetParenthesizedExpression -> getExpression().shouldIntroduceVariableIfUsedTwice() - is JetBinaryExpression, is JetIfExpression -> true // TODO: discuss it + is JetQualifiedExpression -> getReceiverExpression().shouldKeepValue(usageCount) || getSelectorExpression().shouldKeepValue(usageCount) + is JetUnaryExpression -> getOperationToken() in setOf(JetTokens.PLUSPLUS, JetTokens.MINUSMINUS) || getBaseExpression().shouldKeepValue(usageCount) + is JetStringTemplateExpression -> getEntries().any { if (sideEffectOnly) it.getExpression().shouldKeepValue(usageCount) else it is JetStringTemplateEntryWithExpression } + is JetThisExpression, is JetSuperExpression, is JetConstantExpression -> false + is JetParenthesizedExpression -> getExpression().shouldKeepValue(usageCount) + + // TODO: discuss it + is JetBinaryExpression -> if (sideEffectOnly) getLeft().shouldKeepValue(usageCount) || getRight().shouldKeepValue(usageCount) else true + is JetIfExpression -> if (sideEffectOnly) getCondition().shouldKeepValue(usageCount) || getThen().shouldKeepValue(usageCount) || getElse().shouldKeepValue(usageCount) else true + is JetBinaryExpressionWithTypeRHS -> true + else -> true // what else it can be? } } diff --git a/idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsed1.kt b/idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsed1.kt new file mode 100644 index 00000000000..56b414ca693 --- /dev/null +++ b/idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsed1.kt @@ -0,0 +1,14 @@ +// "Replace with 'newFun()'" "true" + +@deprecated("", ReplaceWith("newFun()")) +fun oldFun(p: Int) { + newFun() +} + +fun newFun(){} + +fun foo() { + oldFun(bar()) +} + +fun bar(): Int = 0 diff --git a/idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsed1.kt.after b/idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsed1.kt.after new file mode 100644 index 00000000000..05873ffda10 --- /dev/null +++ b/idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsed1.kt.after @@ -0,0 +1,15 @@ +// "Replace with 'newFun()'" "true" + +@deprecated("", ReplaceWith("newFun()")) +fun oldFun(p: Int) { + newFun() +} + +fun newFun(){} + +fun foo() { + bar() + newFun() +} + +fun bar(): Int = 0 diff --git a/idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsed2.kt b/idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsed2.kt new file mode 100644 index 00000000000..467229fac91 --- /dev/null +++ b/idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsed2.kt @@ -0,0 +1,16 @@ +// "Replace with 'newFun()'" "true" + +class C { + @deprecated("", ReplaceWith("newFun()")) + fun oldFun() { + newFun() + } +} + +fun newFun(){} + +fun foo() { + getC().oldFun() +} + +fun getC(): C = C() diff --git a/idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsed2.kt.after b/idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsed2.kt.after new file mode 100644 index 00000000000..ea910c831e8 --- /dev/null +++ b/idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsed2.kt.after @@ -0,0 +1,17 @@ +// "Replace with 'newFun()'" "true" + +class C { + @deprecated("", ReplaceWith("newFun()")) + fun oldFun() { + newFun() + } +} + +fun newFun(){} + +fun foo() { + getC() + newFun() +} + +fun getC(): C = C() diff --git a/idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsed3Runtime.kt b/idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsed3Runtime.kt new file mode 100644 index 00000000000..46b25eaa852 --- /dev/null +++ b/idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsed3Runtime.kt @@ -0,0 +1,14 @@ +// "Replace with 'newFun()'" "true" + +@deprecated("", ReplaceWith("newFun()")) +fun oldFun(p: Int): Int { + return newFun() +} + +fun newFun(): Int = 0 + +fun foo(): Int { + return oldFun(bar()) +} + +fun bar(): Int = 0 diff --git a/idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsed3Runtime.kt.after b/idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsed3Runtime.kt.after new file mode 100644 index 00000000000..a53b8e435c3 --- /dev/null +++ b/idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsed3Runtime.kt.after @@ -0,0 +1,14 @@ +// "Replace with 'newFun()'" "true" + +@deprecated("", ReplaceWith("newFun()")) +fun oldFun(p: Int): Int { + return newFun() +} + +fun newFun(): Int = 0 + +fun foo(): Int { + return bar().let { newFun() } +} + +fun bar(): Int = 0 diff --git a/idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsed4Runtime.kt b/idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsed4Runtime.kt new file mode 100644 index 00000000000..50b3fbb41af --- /dev/null +++ b/idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsed4Runtime.kt @@ -0,0 +1,12 @@ +// "Replace with 'newFun()'" "true" + +@deprecated("", ReplaceWith("newFun()")) +fun oldFun(p: Int?): Int { + return newFun() +} + +fun newFun(): Int = 0 + +fun foo(): Int = oldFun(bar()) + +fun bar(): Int? = 0 diff --git a/idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsed4Runtime.kt.after b/idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsed4Runtime.kt.after new file mode 100644 index 00000000000..4de0acd6fbf --- /dev/null +++ b/idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsed4Runtime.kt.after @@ -0,0 +1,12 @@ +// "Replace with 'newFun()'" "true" + +@deprecated("", ReplaceWith("newFun()")) +fun oldFun(p: Int?): Int { + return newFun() +} + +fun newFun(): Int = 0 + +fun foo(): Int = bar().let { newFun() } + +fun bar(): Int? = 0 diff --git a/idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsed5Runtime.kt b/idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsed5Runtime.kt new file mode 100644 index 00000000000..6e750cc783a --- /dev/null +++ b/idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsed5Runtime.kt @@ -0,0 +1,14 @@ +// "Replace with 'newFun(p2)'" "true" + +@deprecated("", ReplaceWith("newFun(p2)")) +fun oldFun(p1: Int, p2: Int): Boolean { + return newFun(p2) +} + +fun newFun(p: Int) = false + +fun foo(list: List) { + list.filter { !oldFun(bar(), it) } +} + +fun bar(): Int = 0 diff --git a/idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsed5Runtime.kt.after b/idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsed5Runtime.kt.after new file mode 100644 index 00000000000..94c6f89f57e --- /dev/null +++ b/idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsed5Runtime.kt.after @@ -0,0 +1,14 @@ +// "Replace with 'newFun(p2)'" "true" + +@deprecated("", ReplaceWith("newFun(p2)")) +fun oldFun(p1: Int, p2: Int): Boolean { + return newFun(p2) +} + +fun newFun(p: Int) = false + +fun foo(list: List) { + list.filter { !bar().let { p1 -> newFun(it) } } +} + +fun bar(): Int = 0 diff --git a/idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsedSafeCall.kt b/idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsedSafeCall.kt new file mode 100644 index 00000000000..1e64432d948 --- /dev/null +++ b/idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsedSafeCall.kt @@ -0,0 +1,16 @@ +// "Replace with 'newFun()'" "true" + +class C { + @deprecated("", ReplaceWith("newFun()")) + fun oldFun() { + newFun() + } +} + +fun newFun(){} + +fun foo() { + getC()?.oldFun() +} + +fun getC(): C? = null diff --git a/idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsedSafeCall.kt.after b/idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsedSafeCall.kt.after new file mode 100644 index 00000000000..a4a174d3cb9 --- /dev/null +++ b/idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsedSafeCall.kt.after @@ -0,0 +1,18 @@ +// "Replace with 'newFun()'" "true" + +class C { + @deprecated("", ReplaceWith("newFun()")) + fun oldFun() { + newFun() + } +} + +fun newFun(){} + +fun foo() { + if (getC() != null) { + newFun() + } +} + +fun getC(): C? = null diff --git a/idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsedSafeCall2Runtime.kt b/idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsedSafeCall2Runtime.kt new file mode 100644 index 00000000000..0ac62c9cf7c --- /dev/null +++ b/idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsedSafeCall2Runtime.kt @@ -0,0 +1,16 @@ +// "Replace with 'newFun()'" "true" + +class C { + @deprecated("", ReplaceWith("newFun()")) + fun oldFun(): Int { + return newFun() + } +} + +fun newFun(): Int = 0 + +fun foo(): Int? { + return getC()?.oldFun() +} + +fun getC(): C? = null diff --git a/idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsedSafeCall2Runtime.kt.after b/idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsedSafeCall2Runtime.kt.after new file mode 100644 index 00000000000..1ff8ab3d019 --- /dev/null +++ b/idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsedSafeCall2Runtime.kt.after @@ -0,0 +1,16 @@ +// "Replace with 'newFun()'" "true" + +class C { + @deprecated("", ReplaceWith("newFun()")) + fun oldFun(): Int { + return newFun() + } +} + +fun newFun(): Int = 0 + +fun foo(): Int? { + return getC()?.let { newFun() } +} + +fun getC(): C? = null diff --git a/idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionUsedTwice6Runtime.kt b/idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionUsedTwice6Runtime.kt new file mode 100644 index 00000000000..fd1de119fd2 --- /dev/null +++ b/idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionUsedTwice6Runtime.kt @@ -0,0 +1,14 @@ +// "Replace with 'newFun(p, p)'" "true" + +@deprecated("", ReplaceWith("newFun(p, p)")) +fun oldFun(p: Int?): Int { + return newFun(p, p) +} + +fun newFun(p1: Int?, p2: Int?): Int = 0 + +fun foo(): Int { + return oldFun(bar()) +} + +fun bar(): Int? = null diff --git a/idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionUsedTwice6Runtime.kt.after b/idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionUsedTwice6Runtime.kt.after new file mode 100644 index 00000000000..bf8a7705e0b --- /dev/null +++ b/idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionUsedTwice6Runtime.kt.after @@ -0,0 +1,14 @@ +// "Replace with 'newFun(p, p)'" "true" + +@deprecated("", ReplaceWith("newFun(p, p)")) +fun oldFun(p: Int?): Int { + return newFun(p, p) +} + +fun newFun(p1: Int?, p2: Int?): Int = 0 + +fun foo(): Int { + return bar().let { newFun(it, it) } +} + +fun bar(): Int? = null diff --git a/idea/testData/quickfix/deprecatedSymbolUsage/simpleExpressionNotUsed.kt b/idea/testData/quickfix/deprecatedSymbolUsage/simpleExpressionNotUsed.kt new file mode 100644 index 00000000000..e6101b5efe6 --- /dev/null +++ b/idea/testData/quickfix/deprecatedSymbolUsage/simpleExpressionNotUsed.kt @@ -0,0 +1,16 @@ +// "Replace with 'newFun()'" "true" + +@deprecated("", ReplaceWith("newFun()")) +fun oldFun(p: Int) { + newFun() +} + +fun newFun(){} + +fun foo() { + oldFun(O.x + 1) +} + +object O { + var x = 0 +} diff --git a/idea/testData/quickfix/deprecatedSymbolUsage/simpleExpressionNotUsed.kt.after b/idea/testData/quickfix/deprecatedSymbolUsage/simpleExpressionNotUsed.kt.after new file mode 100644 index 00000000000..26aa1039162 --- /dev/null +++ b/idea/testData/quickfix/deprecatedSymbolUsage/simpleExpressionNotUsed.kt.after @@ -0,0 +1,16 @@ +// "Replace with 'newFun()'" "true" + +@deprecated("", ReplaceWith("newFun()")) +fun oldFun(p: Int) { + newFun() +} + +fun newFun(){} + +fun foo() { + newFun() +} + +object O { + var x = 0 +} diff --git a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java index e24c22c1433..56a6c7d62dc 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java @@ -2932,6 +2932,48 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest { doTest(fileName); } + @TestMetadata("complexExpressionNotUsed1.kt") + public void testComplexExpressionNotUsed1() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsed1.kt"); + doTest(fileName); + } + + @TestMetadata("complexExpressionNotUsed2.kt") + public void testComplexExpressionNotUsed2() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsed2.kt"); + doTest(fileName); + } + + @TestMetadata("complexExpressionNotUsed3Runtime.kt") + public void testComplexExpressionNotUsed3Runtime() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsed3Runtime.kt"); + doTest(fileName); + } + + @TestMetadata("complexExpressionNotUsed4Runtime.kt") + public void testComplexExpressionNotUsed4Runtime() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsed4Runtime.kt"); + doTest(fileName); + } + + @TestMetadata("complexExpressionNotUsed5Runtime.kt") + public void testComplexExpressionNotUsed5Runtime() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsed5Runtime.kt"); + doTest(fileName); + } + + @TestMetadata("complexExpressionNotUsedSafeCall.kt") + public void testComplexExpressionNotUsedSafeCall() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsedSafeCall.kt"); + doTest(fileName); + } + + @TestMetadata("complexExpressionNotUsedSafeCall2Runtime.kt") + public void testComplexExpressionNotUsedSafeCall2Runtime() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionNotUsedSafeCall2Runtime.kt"); + doTest(fileName); + } + @TestMetadata("complexExpressionUsedTwice.kt") public void testComplexExpressionUsedTwice() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionUsedTwice.kt"); @@ -2962,6 +3004,12 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest { doTest(fileName); } + @TestMetadata("complexExpressionUsedTwice6Runtime.kt") + public void testComplexExpressionUsedTwice6Runtime() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/deprecatedSymbolUsage/complexExpressionUsedTwice6Runtime.kt"); + doTest(fileName); + } + @TestMetadata("doNotShortenUserReferences.kt") public void testDoNotShortenUserReferences() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/deprecatedSymbolUsage/doNotShortenUserReferences.kt"); @@ -3094,6 +3142,12 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest { doTest(fileName); } + @TestMetadata("simpleExpressionNotUsed.kt") + public void testSimpleExpressionNotUsed() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/deprecatedSymbolUsage/simpleExpressionNotUsed.kt"); + doTest(fileName); + } + @TestMetadata("simpleExpressionUsedTwice.kt") public void testSimpleExpressionUsedTwice() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/deprecatedSymbolUsage/simpleExpressionUsedTwice.kt"); diff --git a/libraries/stdlib/src/kotlin/util/Standard.kt b/libraries/stdlib/src/kotlin/util/Standard.kt index 12dc78a209d..7409886605a 100644 --- a/libraries/stdlib/src/kotlin/util/Standard.kt +++ b/libraries/stdlib/src/kotlin/util/Standard.kt @@ -21,4 +21,4 @@ public inline fun with(receiver: T, f: T.() -> R): R = receiver.f() /** * Converts receiver to body parameter */ -public inline fun T.let(f: (T) -> R): R = f(this) +public inline fun T.let(f: (T) -> R): R = f(this)