On Thu, 2 Nov 2023 11:55:17 GMT, Jim Laskey <jlas...@openjdk.org> wrote:
>> src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Enter.java line 442: >> >>> 440: Errors.ClassPublicShouldBeInFile(topElement, >>> tree.name)); >>> 441: } >>> 442: if ((tree.mods.flags & IMPLICIT_CLASS) != 0) { >> >> I'm not 100% sure about this. Another option would be to tweak >> Resolve::findType and make sure that `typeNotFound` (or some more specific >> message!) is returned when an implicit class is referred to by name. If you >> look at the first few lines in that method you will see: >> >> >> if (name == names.empty) >> return typeNotFound; // do not allow inadvertent "lookup" of >> anonymous types >> >> >> So, there's already some logic there for skipping some types. > > The main thing here is that it is done once at the source instead of every > look up. The symbol should not exist in the compilation unit. Yep - I think the main consequence of this choice is the fact that we cannot generate a specific error message - but perhaps that's ok (after all, having a special message would equate to admitting that the compiler _does know_ about the name :-) ) ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/16461#discussion_r1380003979