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: docs/_docs/reference/changed-features/structural-types-spec.md
+12Lines changed: 12 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -55,6 +55,18 @@ Both versions are passed the actual arguments in the `args` parameter. The secon
55
55
if `applyDynamic` is implemented using Java reflection, but it could be
56
56
useful in other cases as well. `selectDynamic` and `applyDynamic` can also take additional context parameters in using clauses. These are resolved in the normal way at the callsite.
57
57
58
+
Typically, vararg arguments of a function at callsite are represented as an `Array(elems)`. But in case of `scala.Selectable` implementation relied on Java reflection `scala.reflect.Selectable` when vararg arguments passed to `applyDynamic` method, they get interpreted as single parameter instead of multiple.
59
+
To overcome this they should be wrapped in `Seq(elems)` to be considered as multiple parameters at callsite of `scala.reflect.Selectable.applyDynamic`.
60
+
```scala
61
+
classReflectiveextends reflect.Selectable
62
+
classFoo(vali:Int) extendsAnyVal
63
+
valreflective=newReflective {
64
+
defvarargs(x: Int, foo: Foo*) = foo.map(_.i).sum + x
65
+
}
66
+
valvarargs=List(Foo(1), Foo(2), Foo(3))
67
+
reflective.varargs(1, varargs:_*)
68
+
```
69
+
58
70
Given a value `v` of type `C { Rs }`, where `C` is a class reference
59
71
and `Rs` are structural refinement declarations, and given `v.a` of type `U`, we consider three distinct cases:
0 commit comments