Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Scala 2.12 #6691

Merged
merged 9 commits into from
Nov 30, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions framework/src/play/src/main/scala/play/api/mvc/Action.scala
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ trait Action[A] extends EssentialAction {
* @tparam A the body content type
*/
trait BodyParser[+A] extends (RequestHeader => Accumulator[ByteString, Either[Result, A]]) {
self =>
// "with Any" because we need to prevent 2.12 SAM inference here
self: BodyParser[A] with Any =>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scala 2.12 looks at Function types and attempts to convert them to JDK 1.8 SAM types -- since BodyParser extends Function1, it ends up conflicting with the other Action.apply method that takes only a (Request[A] => Result) (and therefore is also a SAM type, but does not share a common base type).

The solution here is to ensure the BodyParser cannot be treated as a SAM type by the compiler, by kludging the explicit self type reference.


/**
* Uses the provided function to transform the BodyParser's computed result
Expand Down Expand Up @@ -367,7 +368,7 @@ trait ActionBuilder[+R[_], B] extends ActionFunction[Request, R] {
* For example:
* {{{
* val hello = Action.async {
* WS.url("http://www.playframework.com").get().map { r =>
* ws.url("http://www.playframework.com").get().map { r =>
* if (r.status == 200) Ok("The website is up") else NotFound("The website is down")
* }
* }
Expand All @@ -385,7 +386,7 @@ trait ActionBuilder[+R[_], B] extends ActionFunction[Request, R] {
* For example:
* {{{
* val hello = Action.async { request =>
* WS.url(request.getQueryString("url").get).get().map { r =>
* ws.url(request.getQueryString("url").get).get().map { r =>
* if (r.status == 200) Ok("The website is up") else NotFound("The website is down")
* }
* }
Expand All @@ -402,7 +403,7 @@ trait ActionBuilder[+R[_], B] extends ActionFunction[Request, R] {
* For example:
* {{{
* val hello = Action.async { request =>
* WS.url(request.getQueryString("url").get).get().map { r =>
* ws.url(request.getQueryString("url").get).get().map { r =>
* if (r.status == 200) Ok("The website is up") else NotFound("The website is down")
* }
* }
Expand Down