RFR: 8194743: Compiler implementation for Statements before super() [v14]
Maurizio Cimadamore
mcimadamore at openjdk.org
Mon Sep 25 14:06:15 UTC 2023
On Mon, 25 Sep 2023 13:55:44 GMT, Archie Cobbs <acobbs at openjdk.org> wrote:
>> I'm aware of that - but I note that the implementation uses a STATIC_ERR under the hood. Hence my comment on using a custom static error with a custom diagnostic.
>
> Oh I see. Hmm, I'll admit ignorance on how exactly these `Kind` enum error values like `STATICERR`, `HIDDEN`, etc. are used. Is there a better `Kind` choice for this error? Or does this warrant a new `Kind` value? In the latter case, there is a scary warning about ordering of the enum values so any advice appreciated. Thanks.
The kind is used in some other parts of Resolve to determine whether some errors should be skipped in some places, or recovered from. I'd advise against creating a new error kind, which might end up invalidating some existing check which depend on STATICERR. E.g.:
final boolean shouldStop(Symbol sym, MethodResolutionPhase phase) {
return phase.ordinal() > maxPhase.ordinal() ||
!sym.kind.isResolutionError() || sym.kind == AMBIGUOUS || sym.kind == STATICERR;
}
E.g. you don't want overload resolution to try new candidates because you tried to call a method and you don't have a `this` - e.g. the compiler behavior should be similar as to when an instance method is called and no `this` is available (meaning: the found method is correct, and the error should be reported, no attempt should be made at recovery).
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13656#discussion_r1335937230
More information about the compiler-dev
mailing list