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
Copy file name to clipboardExpand all lines: _posts/2024-12-05-release-notes-3.6.2.md
+30-14
Original file line number
Diff line number
Diff line change
@@ -186,29 +186,45 @@ Let's take the following example:
186
186
```
187
187
188
188
Reordering the fields is binary-compatible but it might affect the meaning of `@Annotation(1)`
189
-
Starting from Scala 3.6, named arguments are required for Java-defined annotations that define multiple parameters. Java defined annotations with a single parameter named `value` can still be used anonymously.
189
+
Starting from Scala 3.6, named arguments are required for Java-defined annotations that define multiple parameters.
190
+
If the Java-defined annotation contains paramter named `value` its name can be ommited only when annotation is applied using a single argument.
@Example("a", "b") // error, both parameters should be named
214
+
defmultipleUnnamedParams:Unit= ()
215
+
216
+
@Example("first", param ="second") // error, `"first"` argument should be named
217
+
defmultipleMixedParams:Unit= ()
218
+
219
+
// Annotation with `param: String = ""` parameters
220
+
@NoValueExample()
221
+
defdefaultOnly:Unit= ()
222
+
223
+
@NoValueExample(param ="foo")
224
+
defnamedParam:Unit= ()
225
+
226
+
@NoValueExample("foo") // error, the only parameter is not named `value`
227
+
definvalidUnnamedParam:Unit= ()
212
228
```
213
229
214
230
The compiler can provide you with automatic rewrites introducing now required names, using `-source:3.6-migration, -rewrite` flags. The rewrites are done on a best-effort basis and should be inspected for correctness by the users.
0 commit comments