RFR: 8337795: Type annotation attached to incorrect type during class reading
Liam Miller-Cushon
cushon at openjdk.org
Sun Aug 4 20:16:40 UTC 2024
This change fixes a bug in the logic for adding type annotations to types during class reading.
The implementation searched for contained types that type annotations applied to, and then separately rewrote the type to add the annotations using `StructuralTypeMapping`, relying on the object identity of `Type` instances to keep track of them between the two passes. This produced incorrect results if the same type (with the same identity) appeared multiple times as a contained type.
This fix merges the two passes into a single visitor that both locates annotated contained types, and rewrites them to add the annotations. This requires duplicating similar logic to `StructuralTypeMapping`, which seems unavoidable.
-------------
Commit messages:
- 8337795: Type annotation attached to incorrect type during class reading
Changes: https://git.openjdk.org/jdk/pull/20460/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=20460&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8337795
Stats: 109 lines in 2 files changed: 25 ins; 44 del; 40 mod
Patch: https://git.openjdk.org/jdk/pull/20460.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/20460/head:pull/20460
PR: https://git.openjdk.org/jdk/pull/20460
More information about the compiler-dev
mailing list