RFR: 8291643: Consider omitting type annotations from type error diagnostics [v3]
Liam Miller-Cushon
cushon at openjdk.org
Tue Jun 4 18:03:44 UTC 2024
> Hi,
>
> Please consider this fix for [JDK-8291643](https://bugs.openjdk.org/browse/JDK-8291643), which causes javac to remove type-use annotations when formatting types in diagnostics.
>
> For the example like the one in the bug, this change causes javac to emit the diagnostic like `incompatible types: List<String> cannot be converted to List<Number>` rather than `incompatible types: List<String> cannot be converted to List<@Nullable Number>`. Including the type annotations can be confusing, because they do not impact the type checking done by the compiler.
>
> An alternative I considered was to remove type annotations from types for specific diagnostics, instead of doing it unconditionally in diagnostic formatting. I can revisit that if the current approach seems too broad.
>
> The test update to `test/langtools/tools/javac/lambda/LambdaConv25.out` is because a `ForAll` is being formatted, and `stripMetadata()` uses a `StructuralTypeMapping` which rewrites away the `ForAll`.
Liam Miller-Cushon has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains seven additional commits since the last revision:
- Update after merge of JDK-8043226
- Merge remote-tracking branch 'origin/master' into JDK-8291643
- Merge branch 'master' into JDK-8291643
- Use Type stripping logic added for JDK-8042981
- Merge branch 'master' into JDK-8291643
- Updates based on review thread
* Support optionally printing types with type annotations
* Move handling of types in AbstractDiagnosticFormatter
* Make annotation removal more robust, don't rely on stripMetadata
- 8291643: Consider omitting type annotations from type error diagnostics
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/16578/files
- new: https://git.openjdk.org/jdk/pull/16578/files/7331c7cb..eced87f0
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=16578&range=02
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=16578&range=01-02
Stats: 672872 lines in 8096 files changed: 158730 ins; 162063 del; 352079 mod
Patch: https://git.openjdk.org/jdk/pull/16578.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/16578/head:pull/16578
PR: https://git.openjdk.org/jdk/pull/16578
More information about the compiler-dev
mailing list