From 90cda71e63dd0def7898019aed1a1e130ebbc868 Mon Sep 17 00:00:00 2001 From: Vladimir Dolzhenko Date: Fri, 2 Jun 2023 10:53:05 +0200 Subject: [PATCH] [kotlin] String literal within val/var declaration should be re-analyzed #KTIJ-25528 #KTIJ-20783 Fixed GitOrigin-RevId: 4dbc9fceb7f45bd9450720f14286dfd90fbef8c2 --- .../caches/trackers/PureKotlinCodeBlockModificationListener.kt | 2 +- .../InPropertyWithInferencePureStringLiteralChange.kt | 2 +- .../tests/testData/codeInsight/outOfBlock/InWhenCondition.kt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/kotlin/base/analysis/src/org/jetbrains/kotlin/idea/caches/trackers/PureKotlinCodeBlockModificationListener.kt b/plugins/kotlin/base/analysis/src/org/jetbrains/kotlin/idea/caches/trackers/PureKotlinCodeBlockModificationListener.kt index 7c456ea5821b..7cc1b76255fb 100644 --- a/plugins/kotlin/base/analysis/src/org/jetbrains/kotlin/idea/caches/trackers/PureKotlinCodeBlockModificationListener.kt +++ b/plugins/kotlin/base/analysis/src/org/jetbrains/kotlin/idea/caches/trackers/PureKotlinCodeBlockModificationListener.kt @@ -75,7 +75,7 @@ class PureKotlinCodeBlockModificationListener(val project: Project) : Disposable private inline fun isStringLiteralChange(changeSet: TreeChangeEvent): Boolean = isSpecificChange(changeSet) { it?.elementType == KtTokens.REGULAR_STRING_PART && - it?.psi?.parentOfTypes(KtAnnotationEntry::class, KtIfExpression::class, KtWhenCondition::class) == null + it?.psi?.parentOfTypes(KtAnnotationEntry::class, KtValVarKeywordOwner::class) == null } /** diff --git a/plugins/kotlin/idea/tests/testData/codeInsight/outOfBlock/InPropertyWithInferencePureStringLiteralChange.kt b/plugins/kotlin/idea/tests/testData/codeInsight/outOfBlock/InPropertyWithInferencePureStringLiteralChange.kt index 4a35f6718360..9af4679ccdea 100644 --- a/plugins/kotlin/idea/tests/testData/codeInsight/outOfBlock/InPropertyWithInferencePureStringLiteralChange.kt +++ b/plugins/kotlin/idea/tests/testData/codeInsight/outOfBlock/InPropertyWithInferencePureStringLiteralChange.kt @@ -1,4 +1,4 @@ -// OUT_OF_CODE_BLOCK: FALSE +// OUT_OF_CODE_BLOCK: TRUE class Test { val q = "aasdf" } diff --git a/plugins/kotlin/idea/tests/testData/codeInsight/outOfBlock/InWhenCondition.kt b/plugins/kotlin/idea/tests/testData/codeInsight/outOfBlock/InWhenCondition.kt index 728971337bc6..604208a0224d 100644 --- a/plugins/kotlin/idea/tests/testData/codeInsight/outOfBlock/InWhenCondition.kt +++ b/plugins/kotlin/idea/tests/testData/codeInsight/outOfBlock/InWhenCondition.kt @@ -4,7 +4,7 @@ fun foo(s: String): Int { return when (s) { "hello" -> 0 - "hello" -> 1 + "ello" -> 1 else -> 42 } } \ No newline at end of file