Integrated: 8291643: Consider omitting type annotations from type error diagnostics

Liam Miller-Cushon cushon at openjdk.org
Wed Jun 5 19:13:04 UTC 2024


On Thu, 9 Nov 2023 00:47:10 GMT, Liam Miller-Cushon <cushon at openjdk.org> wrote:

> 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`.

This pull request has now been integrated.

Changeset: 7564949a
Author:    Liam Miller-Cushon <cushon at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/7564949a56b533b9d955ff5feee75afd18e51f74
Stats:     35 lines in 10 files changed: 29 ins; 0 del; 6 mod

8291643: Consider omitting type annotations from type error diagnostics

Reviewed-by: vromero

-------------

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


More information about the compiler-dev mailing list