From a218a3c759f81b572965744ee04c472155c6bb85 Mon Sep 17 00:00:00 2001 From: xuwei-k <6b656e6a69@gmail.com> Date: Mon, 13 Jun 2022 13:00:08 +0900 Subject: [PATCH] avoid infix with `_*`. prepare Scala 3 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 ``` --- core/play/src/main/scala/play/api/mvc/Request.scala | 2 +- core/play/src/main/scala/play/api/mvc/RequestHeader.scala | 2 +- core/play/src/main/scala/play/api/mvc/Results.scala | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/play/src/main/scala/play/api/mvc/Request.scala b/core/play/src/main/scala/play/api/mvc/Request.scala index 16aac385403..9881c9d87ae 100644 --- a/core/play/src/main/scala/play/api/mvc/Request.scala +++ b/core/play/src/main/scala/play/api/mvc/Request.scala @@ -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] = diff --git a/core/play/src/main/scala/play/api/mvc/RequestHeader.scala b/core/play/src/main/scala/play/api/mvc/RequestHeader.scala index d1021e1d5d3..b0de617c2ea 100644 --- a/core/play/src/main/scala/play/api/mvc/RequestHeader.scala +++ b/core/play/src/main/scala/play/api/mvc/RequestHeader.scala @@ -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. diff --git a/core/play/src/main/scala/play/api/mvc/Results.scala b/core/play/src/main/scala/play/api/mvc/Results.scala index 7767ad5896c..c2fabd02aa6 100644 --- a/core/play/src/main/scala/play/api/mvc/Results.scala +++ b/core/play/src/main/scala/play/api/mvc/Results.scala @@ -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.