[java-inspections] IDEA-378586 Impossible to compute constant for '\''

GitOrigin-RevId: ba58288dab3e558c1a1fe4529e8abe4ef26482fa
This commit is contained in:
Mikhail Pyltsin
2025-09-02 18:14:43 +00:00
committed by intellij-monorepo-bot
parent 5991c4a01e
commit ab51e442f6
3 changed files with 25 additions and 1 deletions
@@ -162,7 +162,7 @@ public final class ConstantExpressionInspection extends AbstractBaseJavaLocalIns
newExpression = '"' + StringUtil.escapeStringCharacters(string) + '"';
}
else if (value instanceof Character) {
newExpression = '\'' + StringUtil.escapeStringCharacters(value.toString()) + '\'';
newExpression = '\'' + StringUtil.escapeCharCharacters(value.toString()) + '\'';
}
else if (value instanceof Long) {
newExpression = value.toString() + 'L';
@@ -0,0 +1,12 @@
// "Compute constant value of 'SINGLE_QUOTE'" "true-preview"
class ConstantCast {
public static final char SINGLE_QUOTE = '\'';
static void doSomething(Object o) {
}
public static void main(String[] args) {
doSomething('\'');
}
}
@@ -0,0 +1,12 @@
// "Compute constant value of 'SINGLE_QUOTE'" "true-preview"
class ConstantCast {
public static final char SINGLE_QUOTE = '\'';
static void doSomething(Object o) {
}
public static void main(String[] args) {
doSomething(SINGLE_QUOTE<caret>);
}
}