mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-15 02:59:33 +07:00
[java-dfa] Work-around K2 problem KT-71407 K2: Do not report @JvmField default value as PsiField initializer in K2
GitOrigin-RevId: 1cdf4ac181c63cf9e0d348c7e4b48d449cc031c2
This commit is contained in:
committed by
intellij-monorepo-bot
parent
40a941c038
commit
41c0081fd8
@@ -287,11 +287,18 @@ public final class JavaDfaValueFactory {
|
||||
* @return true if variable initializer should be ignored by analysis
|
||||
*/
|
||||
public static boolean ignoreInitializer(PsiVariable variable) {
|
||||
if (variable instanceof PsiField && variable.hasModifierProperty(PsiModifier.FINAL) && variable.getType().equals(PsiTypes.booleanType())) {
|
||||
// Skip boolean constant fields as they usually used as control knobs to modify program logic
|
||||
// it's better to analyze both true and false values even if it's predefined
|
||||
PsiLiteralExpression initializer = tryCast(PsiUtil.skipParenthesizedExprDown(variable.getInitializer()), PsiLiteralExpression.class);
|
||||
return initializer != null && initializer.getValue() instanceof Boolean;
|
||||
if (variable instanceof PsiField && variable.hasModifierProperty(PsiModifier.FINAL)) {
|
||||
if (variable.getClass().getName().equals("org.jetbrains.kotlin.light.classes.symbol.fields.SymbolLightFieldForProperty")) {
|
||||
// Kotlin light fields may report default value as initializer, which is wrong. See KT-71407
|
||||
return true;
|
||||
}
|
||||
if (variable.getType().equals(PsiTypes.booleanType())) {
|
||||
// Skip boolean constant fields as they usually used as control knobs to modify program logic
|
||||
// it's better to analyze both true and false values even if it's predefined
|
||||
PsiLiteralExpression initializer =
|
||||
tryCast(PsiUtil.skipParenthesizedExprDown(variable.getInitializer()), PsiLiteralExpression.class);
|
||||
return initializer != null && initializer.getValue() instanceof Boolean;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user