RFR: JDK-8273244: Improve diagnostic output related to ErroneousTree [v3]

Jonathan Gibbons jjg at openjdk.java.net
Thu Sep 30 19:15:30 UTC 2021

On Wed, 29 Sep 2021 10:39:28 GMT, Pavel Rappo <prappo at openjdk.org> wrote:

>> FWIW, I'm still in two minds whether this should be a switch or overriding methods. It's ... er, disappointing ... that the lack of support for `PROVIDES` and `USES` didn't "automatically" show up in testing.  That may suggest a lack of coverage in the `DocTree` tests, which suggests the need for a test to check coverage.
> For the sake of this review, using `switch` would be better: fewer changes, less cognitive load. Later we can think of ways of improving that code. It would be nice to structure it such that it would fail at compile time, if we forgot a case.

It's hard to know how to make it fail at compile time.  There are essentially 3 groups of trees ... inline tags (and other trees that use `DCEndPosTree`), block tags (the big block of cases round about line 177), and "other".  We could arguably move block tags into the `default` case and use a type test, which would improve the future-safety.  We could arguably catch missing cases at runtime with suitable use of `IllegalStateException`.

As for tests, we *do* have tests for `ProvidesTree` and `UsesTree`, but the new `RangeChecker` didn't catch the missing case labels because the basic checks in `RangeChecker` were satisfied by the code in the default case in the switch statement.


PR: https://git.openjdk.java.net/jdk/pull/5510

More information about the compiler-dev mailing list