Skip to content

Commit

Permalink
avoid infix with _*. prepare Scala 3
Browse files Browse the repository at this point in the history
https://github.com/playframework/playframework/blob/6e614d11cca8070e6c3aa4940f682f8cc1183e73/core/play/src/main/scala/play/api/libs/typedmap/TypedMap.scala#L94

```
[error] 99 |    withAttrs(attrs + (entries: _*))
[error]    |                                ^
[error]    |          `_*` can be used only for last argument of method application.
[error]    |          It is no longer allowed in operands of infix operations.
```

```
Welcome to Scala 3.1.2 (11.0.15, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.

scala> object A { def +(xs: Int*): Unit = () }
// defined object A

scala> def a(xs: Int*) = A + (xs: _*)
-- Error: ----------------------------------------------------------------------
1 |def a(xs: Int*) = A + (xs: _*)
  |                           ^
  |            `_*` can be used only for last argument of method application.
  |            It is no longer allowed in operands of infix operations.

scala> def a(xs: Int*) = A.+(xs: _*)
def a(xs: Int*): Unit
```
  • Loading branch information
xuwei-k committed Jun 13, 2022
1 parent 6e614d1 commit a218a3c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion core/play/src/main/scala/play/api/mvc/Request.scala
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ trait Request[+A] extends RequestHeader {
override def addAttrs(e1: TypedEntry[_], e2: TypedEntry[_], e3: TypedEntry[_]): Request[A] =
withAttrs(attrs + (e1, e2, e3))
override def addAttrs(entries: TypedEntry[_]*): Request[A] =
withAttrs(attrs + (entries: _*))
withAttrs(attrs.+(entries: _*))
override def removeAttr(key: TypedKey[_]): Request[A] =
withAttrs(attrs - key)
override def withTransientLang(lang: Lang): Request[A] =
Expand Down
2 changes: 1 addition & 1 deletion core/play/src/main/scala/play/api/mvc/RequestHeader.scala
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ trait RequestHeader {
* @return The new version of this object with the new attributes.
*/
def addAttrs(entries: TypedEntry[_]*): RequestHeader =
withAttrs(attrs + (entries: _*))
withAttrs(attrs.+(entries: _*))

/**
* Create a new versions of this object with the given attribute removed.
Expand Down
2 changes: 1 addition & 1 deletion core/play/src/main/scala/play/api/mvc/Results.scala
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ case class Result(
* @return The new version of this object with the new attributes.
*/
def addAttrs(entries: TypedEntry[_]*): Result =
withAttrs(attrs + (entries: _*))
withAttrs(attrs.+(entries: _*))

/**
* Create a new versions of this object with the given attribute removed.
Expand Down

0 comments on commit a218a3c

Please sign in to comment.