RFR: 8343306: javac is failing to determine if a class and a sealed interface are disjoint [v4]

Vicente Romero vromero at openjdk.org
Fri Nov 1 14:55:29 UTC 2024


On Fri, 1 Nov 2024 13:44:12 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:

>> Vicente Romero has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   addressing review comments
>
> src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java line 1689:
> 
>> 1687:                     return false;
>> 1688: 
>> 1689:                 if (ts.isInterface() != ss.isInterface()) { // case I: one is a class and the other one is an interface
> 
> Only for consideration: the specification does not have 3 cases, but 4, when the second asks the "areDisjoint" question with swapped arguments. The code here is equivalent to that, but might be easier to just re-do what the spec is doing, having handle the case where `ts` is a class, `ss` is an interface, and then have something along the lines:
> 
> } else if (ts.isInterface() && !ss.isInterface()) {
>      return areDisjoint(ss, ts);
> }

you are right but given that these two cases can be folded into one, I mean when one is an interface an the other is a class, I think I prefer the current code. Both cases are symmetrical so I think they could naturally be folded into one

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

PR Review Comment: https://git.openjdk.org/jdk/pull/21794#discussion_r1825914971


More information about the compiler-dev mailing list