[kotlin] String literal within if-clause is subject to be re-analyzed

#KTIJ-25528
#KTIJ-20783 Fixed

GitOrigin-RevId: 82db65b3450c1bdb1a031863853a4563273003db
This commit is contained in:
Vladimir Dolzhenko
2023-05-19 23:57:14 +00:00
committed by intellij-monorepo-bot
parent b23f0114de
commit 2713f97c5c
3 changed files with 16 additions and 1 deletions
@@ -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, KtWhenCondition::class) == null
it?.psi?.parentOfTypes(KtAnnotationEntry::class, KtIfExpression::class, KtWhenCondition::class) == null
}
/**
@@ -213,6 +213,11 @@ public class OutOfBlockModificationTestGenerated extends AbstractOutOfBlockModif
runTest("testData/codeInsight/outOfBlock/InGlobalPropertyWithGetter.kt");
}
@TestMetadata("InIfCondition.kt")
public void testInIfCondition() throws Exception {
runTest("testData/codeInsight/outOfBlock/InIfCondition.kt");
}
@TestMetadata("InKDocComment.kt")
public void testInKDocComment() throws Exception {
runTest("testData/codeInsight/outOfBlock/InKDocComment.kt");
@@ -0,0 +1,10 @@
// OUT_OF_CODE_BLOCK: FALSE
// ENABLE-WARNINGS
fun foo(count: Int): String {
return if (count == 0) {
"still zero"
} else {
"no longer zero!<caret>"
}
}