You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix#19951: Align TASTy with the Java annotation model. (#20539)
Scala annotations are classes, with a real constructor, which has a real
signature where order is relevant but names are irrelevant.
On the contrary, Java annotations are interfaces, without any real
constructors. The names of "fields" are relevant, whereas their order is
irrelevant.
As illustrated by #19951, trying
to shoehorn Java annotations into the Scala annotation model is not
sustainable, and breaks in real ways. Therefore, in this commit we align
how Java annotations are stored in TASTy with the Java annotation model.
During pickling:
* Selection of the constructor is pickled without a signature.
* Default arguments are dropped.
* (Due to the parent commit, all arguments are `NamedArg`s at this point.)
During unpickling:
* Selection of the constructor resolves to the unique constructor
(instead of complaining because a signature-less `SELECT` should not
resolve to a member with a signature).
* Arguments to the constructor are reordered and extended with defaults
to match the target constructor; we can do this because all the
arguments are `NamedArg`s.
For backward compatibility, during unpickling:
* If we read a `SELECTin` for a Java annotation constructor, we
disregard its signature and pretend it was a `SELECT`.
* We adapt arguments in best-effort way if not all of them are
`NamedArg`s.
Copy file name to clipboardExpand all lines: tests/run-macros/annot-arg-value-in-java.check
+6-6
Original file line number
Diff line number
Diff line change
@@ -3,9 +3,9 @@ new java.lang.SuppressWarnings(value = "a")
3
3
new java.lang.SuppressWarnings(value = "b")
4
4
new java.lang.SuppressWarnings(value = _root_.scala.Array.apply[java.lang.String]("c", "d")(scala.reflect.ClassTag.apply[java.lang.String](classOf[java.lang.String])))
0 commit comments