From 2ef1a4bffb905b02cfd8ea46d1d41216c973d472 Mon Sep 17 00:00:00 2001 From: peter Date: Mon, 20 Mar 2017 13:22:45 +0100 Subject: [PATCH] a test for how dfa treats static final string comparison (IDEA-169892) --- .../dataFlow/fixture/InternedStringConstants.java | 10 ++++++++++ .../codeInspection/DataFlowInspectionTest.java | 1 + 2 files changed, 11 insertions(+) create mode 100644 java/java-tests/testData/inspection/dataFlow/fixture/InternedStringConstants.java diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/InternedStringConstants.java b/java/java-tests/testData/inspection/dataFlow/fixture/InternedStringConstants.java new file mode 100644 index 000000000000..aa452db55ab2 --- /dev/null +++ b/java/java-tests/testData/inspection/dataFlow/fixture/InternedStringConstants.java @@ -0,0 +1,10 @@ +class Example { + + public static final String FIRST = "f"; + public static final String SECOND = "d"; + public static final String THIRD = FIRST + SECOND; + + public static void main(String[] args) { + System.out.println(THIRD == "fd"); + } +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java index 59c7d90faf7f..fd790365d43c 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java @@ -95,6 +95,7 @@ public class DataFlowInspectionTest extends DataFlowInspectionTestCase { public void testCheckEnumConstantConstructor() { doTest(); } public void testCompareToEnumConstant() throws Throwable { doTest(); } public void testEqualsConstant() throws Throwable { doTest(); } + public void testInternedStringConstants() throws Throwable { doTest(); } public void testDontSaveTypeValue() { doTest(); } public void testFinalLoopVariableInstanceof() throws Throwable { doTest(); } public void testGreaterIsNotEquals() throws Throwable { doTest(); }