From e955dcfc147bffc9121610cf5e9a594f789ba520 Mon Sep 17 00:00:00 2001 From: Toshiaki Kameyama Date: Thu, 18 Apr 2019 19:45:33 +0900 Subject: [PATCH] WhenWithOnlyElse: don't remove when subject variable if needed #KT-30975 Fixed --- .../ConstantConditionIfInspection.kt | 75 +++++++-- .../blockElse/multiReference.kt | 14 ++ .../blockElse/multiReference.kt.after | 11 ++ .../subjectVariable/blockElse/noReference.kt | 14 ++ .../blockElse/noReference.kt.after | 11 ++ .../subjectVariable/blockElse/noReference2.kt | 12 ++ .../blockElse/noReference2.kt.after | 8 + .../blockElse/singleReference.kt | 14 ++ .../blockElse/singleReference.kt.after | 10 ++ .../multiReference.kt | 12 ++ .../multiReference.kt.after | 11 ++ .../blockElseUsedAsExpression/noReference.kt | 12 ++ .../noReference.kt.after | 11 ++ .../blockElseUsedAsExpression/noReference2.kt | 10 ++ .../noReference2.kt.after | 8 + .../singleReference.kt | 12 ++ .../singleReference.kt.after | 10 ++ .../subjectVariable/hasAnnotation.kt | 11 ++ .../subjectVariable/hasAnnotation.kt.after | 10 ++ .../subjectVariable/hasSameNameVariable.kt | 9 + .../hasSameNameVariable.kt.after | 10 ++ .../subjectVariable/hasSameNameVariable2.kt | 12 ++ .../hasSameNameVariable2.kt.after | 11 ++ .../subjectVariable/hasSameNameVariable3.kt | 9 + .../hasSameNameVariable3.kt.after | 7 + .../subjectVariable/hasSameNameVariable4.kt | 10 ++ .../hasSameNameVariable4.kt.after | 11 ++ .../singleElse/multiReference.kt | 9 + .../singleElse/multiReference.kt.after | 8 + .../multiReferenceUsedAsExpression.kt | 10 ++ .../multiReferenceUsedAsExpression.kt.after | 11 ++ .../subjectVariable/singleElse/noReference.kt | 9 + .../singleElse/noReference.kt.after | 8 + .../singleElse/noReference2.kt | 7 + .../singleElse/noReference2.kt.after | 5 + .../singleElse/noReferenceUsedAsExpression.kt | 10 ++ .../noReferenceUsedAsExpression.kt.after | 11 ++ .../noReferenceUsedAsExpression2.kt | 8 + .../noReferenceUsedAsExpression2.kt.after | 6 + .../singleElse/singleReference.kt | 9 + .../singleElse/singleReference.kt.after | 7 + .../singleReferenceUsedAsExpression.kt | 10 ++ .../singleReferenceUsedAsExpression.kt.after | 8 + .../LocalInspectionTestGenerated.java | 157 ++++++++++++++++++ 44 files changed, 636 insertions(+), 12 deletions(-) create mode 100644 idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElse/multiReference.kt create mode 100644 idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElse/multiReference.kt.after create mode 100644 idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElse/noReference.kt create mode 100644 idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElse/noReference.kt.after create mode 100644 idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElse/noReference2.kt create mode 100644 idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElse/noReference2.kt.after create mode 100644 idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElse/singleReference.kt create mode 100644 idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElse/singleReference.kt.after create mode 100644 idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElseUsedAsExpression/multiReference.kt create mode 100644 idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElseUsedAsExpression/multiReference.kt.after create mode 100644 idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElseUsedAsExpression/noReference.kt create mode 100644 idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElseUsedAsExpression/noReference.kt.after create mode 100644 idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElseUsedAsExpression/noReference2.kt create mode 100644 idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElseUsedAsExpression/noReference2.kt.after create mode 100644 idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElseUsedAsExpression/singleReference.kt create mode 100644 idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElseUsedAsExpression/singleReference.kt.after create mode 100644 idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/hasAnnotation.kt create mode 100644 idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/hasAnnotation.kt.after create mode 100644 idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/hasSameNameVariable.kt create mode 100644 idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/hasSameNameVariable.kt.after create mode 100644 idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/hasSameNameVariable2.kt create mode 100644 idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/hasSameNameVariable2.kt.after create mode 100644 idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/hasSameNameVariable3.kt create mode 100644 idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/hasSameNameVariable3.kt.after create mode 100644 idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/hasSameNameVariable4.kt create mode 100644 idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/hasSameNameVariable4.kt.after create mode 100644 idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/multiReference.kt create mode 100644 idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/multiReference.kt.after create mode 100644 idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/multiReferenceUsedAsExpression.kt create mode 100644 idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/multiReferenceUsedAsExpression.kt.after create mode 100644 idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/noReference.kt create mode 100644 idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/noReference.kt.after create mode 100644 idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/noReference2.kt create mode 100644 idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/noReference2.kt.after create mode 100644 idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/noReferenceUsedAsExpression.kt create mode 100644 idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/noReferenceUsedAsExpression.kt.after create mode 100644 idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/noReferenceUsedAsExpression2.kt create mode 100644 idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/noReferenceUsedAsExpression2.kt.after create mode 100644 idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/singleReference.kt create mode 100644 idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/singleReference.kt.after create mode 100644 idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/singleReferenceUsedAsExpression.kt create mode 100644 idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/singleReferenceUsedAsExpression.kt.after diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/ConstantConditionIfInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/ConstantConditionIfInspection.kt index 8751efb8817..7e75514bb54 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/ConstantConditionIfInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/ConstantConditionIfInspection.kt @@ -10,6 +10,8 @@ import com.intellij.codeInspection.ProblemDescriptor import com.intellij.codeInspection.ProblemsHolder import com.intellij.openapi.project.Project import com.intellij.psi.PsiElementVisitor +import com.intellij.psi.search.LocalSearchScope +import com.intellij.psi.search.searches.ReferencesSearch import org.jetbrains.kotlin.idea.caches.resolve.analyze import org.jetbrains.kotlin.idea.core.replaced import org.jetbrains.kotlin.idea.intentions.branchedTransformations.isElseIf @@ -17,10 +19,7 @@ import org.jetbrains.kotlin.idea.intentions.branchedTransformations.unwrapBlockO import org.jetbrains.kotlin.idea.references.mainReference import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.* -import org.jetbrains.kotlin.psi.psiUtil.containingClass -import org.jetbrains.kotlin.psi.psiUtil.getChildrenOfType -import org.jetbrains.kotlin.psi.psiUtil.getParentOfType -import org.jetbrains.kotlin.psi.psiUtil.startOffset +import org.jetbrains.kotlin.psi.psiUtil.* import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.bindingContextUtil.isUsedAsExpression import org.jetbrains.kotlin.resolve.calls.callUtil.getType @@ -157,27 +156,79 @@ private fun KtExpression.enumEntry(): KtEnumEntry? { } fun KtExpression.replaceWithBranch(branch: KtExpression, isUsedAsExpression: Boolean, keepBraces: Boolean = false) { - val lastExpression = when { - branch !is KtBlockExpression -> replaced(branch) + val caretModel = findExistingEditor()?.caretModel + + val subjectVariable = (this as? KtWhenExpression)?.subjectVariable?.let { it -> + if (it.annotationEntries.isNotEmpty()) return@let it + val initializer = it.initializer ?: return@let it + val references = ReferencesSearch.search(it, LocalSearchScope(this)).toList() + when (references.size) { + 0 -> when (initializer) { + is KtSimpleNameExpression, is KtStringTemplateExpression, is KtConstantExpression -> null + else -> it + } + 1 -> { + references.firstOrNull()?.element?.replace(initializer) + null + } + else -> it + } + } + val wrapSubjectVariableByRun = if (subjectVariable != null) { + val subjectVariableName = subjectVariable.nameAsName + val parentBlock = getStrictParentOfType() + parentBlock?.anyDescendantOfType { it != subjectVariable && it.nameAsName == subjectVariableName } == true + } else { + false + } + + val factory = KtPsiFactory(this) + val parent = this.parent + val replaced = when { + branch !is KtBlockExpression -> { + if (subjectVariable != null) { + if (isUsedAsExpression || wrapSubjectVariableByRun) { + replaced(KtPsiFactory(this).createExpressionByPattern("run { $0\n$1 }", subjectVariable, branch)) + } else { + parent.addBefore(subjectVariable, this).also { + parent.addAfter(factory.createNewLine(), it) + replaced(branch) + } + } + } else { + replaced(branch) + } + } isUsedAsExpression -> { - val factory = KtPsiFactory(this) + if (subjectVariable != null) { + branch.addAfter(factory.createNewLine(), branch.addBefore(subjectVariable, branch.statements.firstOrNull())) + } replaced(factory.createExpressionByPattern("run $0", branch.text)) } else -> { val firstChildSibling = branch.firstChild.nextSibling val lastChild = branch.lastChild - if (firstChildSibling != lastChild) { + val replaced = if (firstChildSibling != lastChild) { if (keepBraces) { parent.addAfter(branch, this) } else { - parent.addRangeAfter(firstChildSibling, lastChild.prevSibling, this) + if (subjectVariable != null && wrapSubjectVariableByRun) { + branch.addAfter(subjectVariable, branch.lBrace) + parent.addAfter(KtPsiFactory(this).createExpression("run ${branch.text}"), this) + } else { + parent.addRangeAfter(firstChildSibling, lastChild.prevSibling, this) + subjectVariable?.let { parent.addBefore(subjectVariable, this) } + } } + } else { + null } delete() - null + replaced } } - val caretModel = branch.findExistingEditor()?.caretModel - caretModel?.moveToOffset(lastExpression?.startOffset ?: return) + if (replaced != null) { + caretModel?.moveToOffset(replaced.startOffset) + } } \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElse/multiReference.kt b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElse/multiReference.kt new file mode 100644 index 00000000000..1a48d874379 --- /dev/null +++ b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElse/multiReference.kt @@ -0,0 +1,14 @@ +fun test() { + when (val a = create()) { + else -> { + use(a, a) + foo() + } + } +} + +fun create(): String = "" + +fun use(s: String, t: String) {} + +fun foo() {} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElse/multiReference.kt.after b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElse/multiReference.kt.after new file mode 100644 index 00000000000..993b29e7c2f --- /dev/null +++ b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElse/multiReference.kt.after @@ -0,0 +1,11 @@ +fun test() { + val a = create() + use(a, a) + foo() +} + +fun create(): String = "" + +fun use(s: String, t: String) {} + +fun foo() {} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElse/noReference.kt b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElse/noReference.kt new file mode 100644 index 00000000000..e713672b797 --- /dev/null +++ b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElse/noReference.kt @@ -0,0 +1,14 @@ +fun test() { + when (val a = create()) { + else -> { + use("") + foo() + } + } +} + +fun create(): String = "" + +fun use(s: String) {} + +fun foo() {} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElse/noReference.kt.after b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElse/noReference.kt.after new file mode 100644 index 00000000000..9ba37d2622d --- /dev/null +++ b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElse/noReference.kt.after @@ -0,0 +1,11 @@ +fun test() { + val a = create() + use("") + foo() +} + +fun create(): String = "" + +fun use(s: String) {} + +fun foo() {} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElse/noReference2.kt b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElse/noReference2.kt new file mode 100644 index 00000000000..da088194031 --- /dev/null +++ b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElse/noReference2.kt @@ -0,0 +1,12 @@ +fun test() { + when (val a = 42) { + else -> { + use("") + foo() + } + } +} + +fun use(s: String) {} + +fun foo() {} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElse/noReference2.kt.after b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElse/noReference2.kt.after new file mode 100644 index 00000000000..46ca1cb2ec5 --- /dev/null +++ b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElse/noReference2.kt.after @@ -0,0 +1,8 @@ +fun test() { + use("") + foo() +} + +fun use(s: String) {} + +fun foo() {} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElse/singleReference.kt b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElse/singleReference.kt new file mode 100644 index 00000000000..761af5566bf --- /dev/null +++ b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElse/singleReference.kt @@ -0,0 +1,14 @@ +fun test() { + when (val a = create()) { + else -> { + use(a) + foo() + } + } +} + +fun create(): String = "" + +fun use(s: String) {} + +fun foo() {} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElse/singleReference.kt.after b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElse/singleReference.kt.after new file mode 100644 index 00000000000..36554c4a028 --- /dev/null +++ b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElse/singleReference.kt.after @@ -0,0 +1,10 @@ +fun test() { + use(create()) + foo() +} + +fun create(): String = "" + +fun use(s: String) {} + +fun foo() {} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElseUsedAsExpression/multiReference.kt b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElseUsedAsExpression/multiReference.kt new file mode 100644 index 00000000000..e083cd87d13 --- /dev/null +++ b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElseUsedAsExpression/multiReference.kt @@ -0,0 +1,12 @@ +// WITH_RUNTIME +fun test() { + val x = when (val a = create()) { + else -> { + use(a, a) + } + } +} + +fun create(): String = "" + +fun use(s: String, t: String) {} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElseUsedAsExpression/multiReference.kt.after b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElseUsedAsExpression/multiReference.kt.after new file mode 100644 index 00000000000..4f2aaa8280c --- /dev/null +++ b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElseUsedAsExpression/multiReference.kt.after @@ -0,0 +1,11 @@ +// WITH_RUNTIME +fun test() { + val x = run { + val a = create() + use(a, a) + } +} + +fun create(): String = "" + +fun use(s: String, t: String) {} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElseUsedAsExpression/noReference.kt b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElseUsedAsExpression/noReference.kt new file mode 100644 index 00000000000..ab61e9ddf07 --- /dev/null +++ b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElseUsedAsExpression/noReference.kt @@ -0,0 +1,12 @@ +// WITH_RUNTIME +fun test() { + val x = when (val a = create()) { + else -> { + use("") + } + } +} + +fun create(): String = "" + +fun use(s: String) {} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElseUsedAsExpression/noReference.kt.after b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElseUsedAsExpression/noReference.kt.after new file mode 100644 index 00000000000..976a27c43d7 --- /dev/null +++ b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElseUsedAsExpression/noReference.kt.after @@ -0,0 +1,11 @@ +// WITH_RUNTIME +fun test() { + val x = run { + val a = create() + use("") + } +} + +fun create(): String = "" + +fun use(s: String) {} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElseUsedAsExpression/noReference2.kt b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElseUsedAsExpression/noReference2.kt new file mode 100644 index 00000000000..3508544c04f --- /dev/null +++ b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElseUsedAsExpression/noReference2.kt @@ -0,0 +1,10 @@ +// WITH_RUNTIME +fun test() { + val x = when (val a = 42) { + else -> { + use("") + } + } +} + +fun use(s: String) {} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElseUsedAsExpression/noReference2.kt.after b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElseUsedAsExpression/noReference2.kt.after new file mode 100644 index 00000000000..f10936bd23e --- /dev/null +++ b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElseUsedAsExpression/noReference2.kt.after @@ -0,0 +1,8 @@ +// WITH_RUNTIME +fun test() { + val x = run { + use("") + } +} + +fun use(s: String) {} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElseUsedAsExpression/singleReference.kt b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElseUsedAsExpression/singleReference.kt new file mode 100644 index 00000000000..0349bde9f76 --- /dev/null +++ b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElseUsedAsExpression/singleReference.kt @@ -0,0 +1,12 @@ +// WITH_RUNTIME +fun test() { + val x = when (val a = create()) { + else -> { + use(a) + } + } +} + +fun create(): String = "" + +fun use(s: String) {} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElseUsedAsExpression/singleReference.kt.after b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElseUsedAsExpression/singleReference.kt.after new file mode 100644 index 00000000000..160363e065d --- /dev/null +++ b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElseUsedAsExpression/singleReference.kt.after @@ -0,0 +1,10 @@ +// WITH_RUNTIME +fun test() { + val x = run { + use(create()) + } +} + +fun create(): String = "" + +fun use(s: String) {} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/hasAnnotation.kt b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/hasAnnotation.kt new file mode 100644 index 00000000000..73a5ed10e05 --- /dev/null +++ b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/hasAnnotation.kt @@ -0,0 +1,11 @@ +fun hasAnnotation() { + when (@Bar val a = create()) { + else -> use(a) + } +} + +fun create(): String = "" + +fun use(s: String) {} + +annotation class Bar \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/hasAnnotation.kt.after b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/hasAnnotation.kt.after new file mode 100644 index 00000000000..1f393ec15b9 --- /dev/null +++ b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/hasAnnotation.kt.after @@ -0,0 +1,10 @@ +fun hasAnnotation() { + @Bar val a = create() + use(a) +} + +fun create(): String = "" + +fun use(s: String) {} + +annotation class Bar \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/hasSameNameVariable.kt b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/hasSameNameVariable.kt new file mode 100644 index 00000000000..e26e7d106bb --- /dev/null +++ b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/hasSameNameVariable.kt @@ -0,0 +1,9 @@ +// WITH_RUNTIME +fun test() { + when (val a = 42) { + else -> use(a, a) + } + val a = 33 +} + +fun use(i: Int, j: Int) {} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/hasSameNameVariable.kt.after b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/hasSameNameVariable.kt.after new file mode 100644 index 00000000000..4f42ba8394f --- /dev/null +++ b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/hasSameNameVariable.kt.after @@ -0,0 +1,10 @@ +// WITH_RUNTIME +fun test() { + run { + val a = 42 + use(a, a) + } + val a = 33 +} + +fun use(i: Int, j: Int) {} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/hasSameNameVariable2.kt b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/hasSameNameVariable2.kt new file mode 100644 index 00000000000..7df861967d5 --- /dev/null +++ b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/hasSameNameVariable2.kt @@ -0,0 +1,12 @@ +// WITH_RUNTIME +fun test() { + when (val a = 42) { + else -> { + use(a, a) + use(a, a) + } + } + val a = 33 +} + +fun use(i: Int, j: Int) {} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/hasSameNameVariable2.kt.after b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/hasSameNameVariable2.kt.after new file mode 100644 index 00000000000..d1be7b11890 --- /dev/null +++ b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/hasSameNameVariable2.kt.after @@ -0,0 +1,11 @@ +// WITH_RUNTIME +fun test() { + run { + val a = 42 + use(a, a) + use(a, a) + } + val a = 33 +} + +fun use(i: Int, j: Int) {} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/hasSameNameVariable3.kt b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/hasSameNameVariable3.kt new file mode 100644 index 00000000000..b619735a90b --- /dev/null +++ b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/hasSameNameVariable3.kt @@ -0,0 +1,9 @@ +fun test() { + when (val a = 42) { + else -> use(a) + } + + val a = 33 +} + +fun use(i: Int) {} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/hasSameNameVariable3.kt.after b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/hasSameNameVariable3.kt.after new file mode 100644 index 00000000000..2bf9a91a68c --- /dev/null +++ b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/hasSameNameVariable3.kt.after @@ -0,0 +1,7 @@ +fun test() { + use(42) + + val a = 33 +} + +fun use(i: Int) {} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/hasSameNameVariable4.kt b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/hasSameNameVariable4.kt new file mode 100644 index 00000000000..bf08377ebae --- /dev/null +++ b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/hasSameNameVariable4.kt @@ -0,0 +1,10 @@ +// WITH_RUNTIME +fun test() { + val x = when (val a = 42) { + else -> use(a, a) + } + + val a = 33 +} + +fun use(i: Int, j: Int) {} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/hasSameNameVariable4.kt.after b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/hasSameNameVariable4.kt.after new file mode 100644 index 00000000000..2468519bd00 --- /dev/null +++ b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/hasSameNameVariable4.kt.after @@ -0,0 +1,11 @@ +// WITH_RUNTIME +fun test() { + val x = run { + val a = 42 + use(a, a) + } + + val a = 33 +} + +fun use(i: Int, j: Int) {} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/multiReference.kt b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/multiReference.kt new file mode 100644 index 00000000000..d8633826887 --- /dev/null +++ b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/multiReference.kt @@ -0,0 +1,9 @@ +fun test() { + when (val a = create()) { + else -> use(a, a) + } +} + +fun create(): String = "" + +fun use(s: String, t: String) {} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/multiReference.kt.after b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/multiReference.kt.after new file mode 100644 index 00000000000..d949293407a --- /dev/null +++ b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/multiReference.kt.after @@ -0,0 +1,8 @@ +fun test() { + val a = create() + use(a, a) +} + +fun create(): String = "" + +fun use(s: String, t: String) {} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/multiReferenceUsedAsExpression.kt b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/multiReferenceUsedAsExpression.kt new file mode 100644 index 00000000000..dd17b1d4c1f --- /dev/null +++ b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/multiReferenceUsedAsExpression.kt @@ -0,0 +1,10 @@ +// WITH_RUNTIME +fun test() { + val x = when (val a = create()) { + else -> use(a, a) + } +} + +fun create(): String = "" + +fun use(s: String, t: String) {} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/multiReferenceUsedAsExpression.kt.after b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/multiReferenceUsedAsExpression.kt.after new file mode 100644 index 00000000000..4f2aaa8280c --- /dev/null +++ b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/multiReferenceUsedAsExpression.kt.after @@ -0,0 +1,11 @@ +// WITH_RUNTIME +fun test() { + val x = run { + val a = create() + use(a, a) + } +} + +fun create(): String = "" + +fun use(s: String, t: String) {} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/noReference.kt b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/noReference.kt new file mode 100644 index 00000000000..0131beaa32c --- /dev/null +++ b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/noReference.kt @@ -0,0 +1,9 @@ +fun test() { + when (val a = create()) { + else -> use("") + } +} + +fun create(): String = "" + +fun use(s: String) {} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/noReference.kt.after b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/noReference.kt.after new file mode 100644 index 00000000000..cbb939a698b --- /dev/null +++ b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/noReference.kt.after @@ -0,0 +1,8 @@ +fun test() { + val a = create() + use("") +} + +fun create(): String = "" + +fun use(s: String) {} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/noReference2.kt b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/noReference2.kt new file mode 100644 index 00000000000..4f489cb5f3c --- /dev/null +++ b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/noReference2.kt @@ -0,0 +1,7 @@ +fun test() { + when (val a = 42) { + else -> use("") + } +} + +fun use(s: String) {} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/noReference2.kt.after b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/noReference2.kt.after new file mode 100644 index 00000000000..67b8d343162 --- /dev/null +++ b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/noReference2.kt.after @@ -0,0 +1,5 @@ +fun test() { + use("") +} + +fun use(s: String) {} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/noReferenceUsedAsExpression.kt b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/noReferenceUsedAsExpression.kt new file mode 100644 index 00000000000..356d0df4a1f --- /dev/null +++ b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/noReferenceUsedAsExpression.kt @@ -0,0 +1,10 @@ +// WITH_RUNTIME +fun test() { + val x = when (val a = create()) { + else -> use("") + } +} + +fun create(): String = "" + +fun use(s: String) {} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/noReferenceUsedAsExpression.kt.after b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/noReferenceUsedAsExpression.kt.after new file mode 100644 index 00000000000..976a27c43d7 --- /dev/null +++ b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/noReferenceUsedAsExpression.kt.after @@ -0,0 +1,11 @@ +// WITH_RUNTIME +fun test() { + val x = run { + val a = create() + use("") + } +} + +fun create(): String = "" + +fun use(s: String) {} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/noReferenceUsedAsExpression2.kt b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/noReferenceUsedAsExpression2.kt new file mode 100644 index 00000000000..44c272a7777 --- /dev/null +++ b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/noReferenceUsedAsExpression2.kt @@ -0,0 +1,8 @@ +// WITH_RUNTIME +fun test() { + val x = when (val a = 42) { + else -> use("") + } +} + +fun use(s: String) {} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/noReferenceUsedAsExpression2.kt.after b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/noReferenceUsedAsExpression2.kt.after new file mode 100644 index 00000000000..59d1458cc6c --- /dev/null +++ b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/noReferenceUsedAsExpression2.kt.after @@ -0,0 +1,6 @@ +// WITH_RUNTIME +fun test() { + val x = use("") +} + +fun use(s: String) {} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/singleReference.kt b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/singleReference.kt new file mode 100644 index 00000000000..0c14a75b43c --- /dev/null +++ b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/singleReference.kt @@ -0,0 +1,9 @@ +fun test() { + when (val a = create()) { + else -> use(a) + } +} + +fun create(): String = "" + +fun use(s: String) {} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/singleReference.kt.after b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/singleReference.kt.after new file mode 100644 index 00000000000..9c2b8505bab --- /dev/null +++ b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/singleReference.kt.after @@ -0,0 +1,7 @@ +fun test() { + use(create()) +} + +fun create(): String = "" + +fun use(s: String) {} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/singleReferenceUsedAsExpression.kt b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/singleReferenceUsedAsExpression.kt new file mode 100644 index 00000000000..001f999f648 --- /dev/null +++ b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/singleReferenceUsedAsExpression.kt @@ -0,0 +1,10 @@ +// WITH_RUNTIME +fun test() { + val x = when (val a = create()) { + else -> use(a) + } +} + +fun create(): String = "" + +fun use(s: String) {} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/singleReferenceUsedAsExpression.kt.after b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/singleReferenceUsedAsExpression.kt.after new file mode 100644 index 00000000000..08cde0eb0fb --- /dev/null +++ b/idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/singleReferenceUsedAsExpression.kt.after @@ -0,0 +1,8 @@ +// WITH_RUNTIME +fun test() { + val x = use(create()) +} + +fun create(): String = "" + +fun use(s: String) {} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java index 372c7beed7f..ed4d6a0fe02 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java @@ -10314,6 +10314,163 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest { public void testSimpleExpression() throws Exception { runTest("idea/testData/inspectionsLocal/whenWithOnlyElse/simpleExpression.kt"); } + + @TestMetadata("idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class SubjectVariable extends AbstractLocalInspectionTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath); + } + + public void testAllFilesPresentInSubjectVariable() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), TargetBackend.ANY, true); + } + + @TestMetadata("hasAnnotation.kt") + public void testHasAnnotation() throws Exception { + runTest("idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/hasAnnotation.kt"); + } + + @TestMetadata("hasSameNameVariable.kt") + public void testHasSameNameVariable() throws Exception { + runTest("idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/hasSameNameVariable.kt"); + } + + @TestMetadata("hasSameNameVariable2.kt") + public void testHasSameNameVariable2() throws Exception { + runTest("idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/hasSameNameVariable2.kt"); + } + + @TestMetadata("hasSameNameVariable3.kt") + public void testHasSameNameVariable3() throws Exception { + runTest("idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/hasSameNameVariable3.kt"); + } + + @TestMetadata("hasSameNameVariable4.kt") + public void testHasSameNameVariable4() throws Exception { + runTest("idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/hasSameNameVariable4.kt"); + } + + @TestMetadata("idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElse") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class BlockElse extends AbstractLocalInspectionTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath); + } + + public void testAllFilesPresentInBlockElse() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElse"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), TargetBackend.ANY, true); + } + + @TestMetadata("multiReference.kt") + public void testMultiReference() throws Exception { + runTest("idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElse/multiReference.kt"); + } + + @TestMetadata("noReference.kt") + public void testNoReference() throws Exception { + runTest("idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElse/noReference.kt"); + } + + @TestMetadata("noReference2.kt") + public void testNoReference2() throws Exception { + runTest("idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElse/noReference2.kt"); + } + + @TestMetadata("singleReference.kt") + public void testSingleReference() throws Exception { + runTest("idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElse/singleReference.kt"); + } + } + + @TestMetadata("idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElseUsedAsExpression") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class BlockElseUsedAsExpression extends AbstractLocalInspectionTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath); + } + + public void testAllFilesPresentInBlockElseUsedAsExpression() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElseUsedAsExpression"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), TargetBackend.ANY, true); + } + + @TestMetadata("multiReference.kt") + public void testMultiReference() throws Exception { + runTest("idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElseUsedAsExpression/multiReference.kt"); + } + + @TestMetadata("noReference.kt") + public void testNoReference() throws Exception { + runTest("idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElseUsedAsExpression/noReference.kt"); + } + + @TestMetadata("noReference2.kt") + public void testNoReference2() throws Exception { + runTest("idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElseUsedAsExpression/noReference2.kt"); + } + + @TestMetadata("singleReference.kt") + public void testSingleReference() throws Exception { + runTest("idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/blockElseUsedAsExpression/singleReference.kt"); + } + } + + @TestMetadata("idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class SingleElse extends AbstractLocalInspectionTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath); + } + + public void testAllFilesPresentInSingleElse() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), TargetBackend.ANY, true); + } + + @TestMetadata("multiReference.kt") + public void testMultiReference() throws Exception { + runTest("idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/multiReference.kt"); + } + + @TestMetadata("multiReferenceUsedAsExpression.kt") + public void testMultiReferenceUsedAsExpression() throws Exception { + runTest("idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/multiReferenceUsedAsExpression.kt"); + } + + @TestMetadata("noReference.kt") + public void testNoReference() throws Exception { + runTest("idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/noReference.kt"); + } + + @TestMetadata("noReference2.kt") + public void testNoReference2() throws Exception { + runTest("idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/noReference2.kt"); + } + + @TestMetadata("noReferenceUsedAsExpression.kt") + public void testNoReferenceUsedAsExpression() throws Exception { + runTest("idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/noReferenceUsedAsExpression.kt"); + } + + @TestMetadata("noReferenceUsedAsExpression2.kt") + public void testNoReferenceUsedAsExpression2() throws Exception { + runTest("idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/noReferenceUsedAsExpression2.kt"); + } + + @TestMetadata("singleReference.kt") + public void testSingleReference() throws Exception { + runTest("idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/singleReference.kt"); + } + + @TestMetadata("singleReferenceUsedAsExpression.kt") + public void testSingleReferenceUsedAsExpression() throws Exception { + runTest("idea/testData/inspectionsLocal/whenWithOnlyElse/subjectVariable/singleElse/singleReferenceUsedAsExpression.kt"); + } + } + } } @TestMetadata("idea/testData/inspectionsLocal/wrapUnaryOperator")