Commit 02912f0
committed
Fix handling of arrays in java annotation arguments
Previously, the array literal argument `{ "foo", "bar" }` was typed as
an `Array["foo" | "bar"]`, which is not a subtype of the corresponding
parameter type (`Array[String]`). This lead to a crash when forcing
the annotation. This is a serious problem because in Java 9+, JFrame
contains such an annotation, therefore this affects basically any code
using Swing/AWT.
Similary an empty array `{}` was always typed as `Array[Object]` which
does not always match the parameter type, this one is trickier to fix
since the serialized annotation does not keep track of the element type
of an empty array and we don't want to force the serialization at this
point, so we use a WildcardType.1 parent d165378 commit 02912f0
File tree
4 files changed
+14
-2
lines changed- compiler/src/dotty/tools/dotc/core/classfile
- tests/pos-java-interop-separate/array-annot
4 files changed
+14
-2
lines changedLines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
518 | 518 | | |
519 | 519 | | |
520 | 520 | | |
521 | | - | |
522 | | - | |
| 521 | + | |
| 522 | + | |
523 | 523 | | |
524 | 524 | | |
525 | 525 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
0 commit comments