On Wed, 24 Jan 2024 14:53:19 GMT, Aggelos Biboudis <abimpou...@openjdk.org> 
wrote:

>> src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java line 4147:
>> 
>>> 4145:         }
>>> 4146:         if (clazztype.isPrimitive()) {
>>> 4147:             preview.checkSourceLevel(tree.pattern.pos(), 
>>> Feature.PRIMITIVE_PATTERNS);
>> 
>> So, if I have a primitive instanceof, I get two preview warnings, one for 
>> the expression, and one for the pattern type? Shouldn't one be enough?
>
> Meaning the `compiler.err.preview.feature.disabled.plural: 
> (compiler.misc.feature.primitive.patterns)` error due to the two `if 
> (clazztype.isPrimitive()) { preview.checkSourceLevel(tree.pattern.pos(), 
> Feature.PRIMITIVE_PATTERNS);` ifs? Isn't it better to keep both, for better 
> error reporting regarding the position? (i.e., which position do we report?)

What I mean is that, looking at the code, it seems like:

int x;
if (x instanceof int y) ...

will generate two warnings. Perhaps that's what we want, but it seems a bit on 
the heavy-side, subjectively. Anyway, no need to take any action.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1465569066

Reply via email to