RFR: 8297158: Suspicious collection method call in Types.isSameTypeVisitor

Jan Lahoda jlahoda at openjdk.org
Tue Jan 31 11:52:58 UTC 2023

On Sun, 29 Jan 2023 02:20:10 GMT, Vicente Romero <vromero at openjdk.org> wrote:

> As reported there is a code in `com.sun.tools.javac.code.Types` that was basically a no-op. The code in question is:
>     if (tMap.containsKey(ti)) {
>         throw new AssertionError("Malformed intersection");
>     }
>     tMap.put(ti.tsym, ti); 
> where tMap is defined as: `Map<Symbol,Type>`, but `ti` is a type so the condition, `tMap.containsKey(ti)`, is always false. The assertion should be thrown if an intersection type has two or more repeated interfaces. But there are other places in the compiler where this is checked for and an error is issued if necessary. So it shouldn't be possible to get to this point during a compilation. There are several tests, including combo tests, already stressing this condition, intersection types with repeated interfaces, for this reason there is no need to add more regression tests.

Looks good to me.


Marked as reviewed by jlahoda (Reviewer).

PR: https://git.openjdk.org/jdk/pull/12279

More information about the compiler-dev mailing list