IDEA-154668 MagicConstant on new Font(...) accepts 0 (Font.PLAIN) but rejects 1 (Font.BOLD)

This commit is contained in:
Alexey Kudravtsev
2016-04-14 15:51:36 +03:00
parent 84c0d19bc7
commit bc4c448968
3 changed files with 42 additions and 7 deletions
@@ -446,4 +446,10 @@
<description>Must be one of: SwingConstants.LEFT, SwingConstants.CENTER, SwingConstants.RIGHT, SwingConstants.LEADING, SwingConstants.TRAILING</description>
</problem>
<problem>
<file>X.java</file>
<line>268</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Magic Constant</problem_class>
<description>Must be one of: FontType.PLAIN, FontType.BOLD, FontType.ITALIC</description>
</problem>
</problems>
@@ -18,9 +18,9 @@ import org.intellij.lang.annotations.MagicConstant;
import java.io.*;
class Const {
public static final int X = 0;
public static final int X = 1;
public static final int Y = 2;
public static final int Z = 3;
public static final int Z = 4;
}
public class X {
@@ -256,4 +256,15 @@ public class X {
plusSupportedInFlags(0);
plusSupportedInFlags(-1);
}
///////////////////////////////////////
static class FontType {
public static final int PLAIN = 0;
public static final int BOLD = 1;
public static final int ITALIC = 2;
}
void font(@MagicConstant(flags = {FontType.PLAIN, FontType.BOLD, FontType.ITALIC}) int x) {
// 0 is not allowed despite the fact that it's flags parameter
font(0);
}
}