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

Drop Scala 2.12 support #149

Open
2 of 4 tasks
rtyley opened this issue Jul 25, 2024 · 0 comments
Open
2 of 4 tasks

Drop Scala 2.12 support #149

rtyley opened this issue Jul 25, 2024 · 0 comments

Comments

@rtyley
Copy link
Member

rtyley commented Jul 25, 2024

Dropping Scala 2.12 support would allow us to use all the good Scala 2.13 features, like LazyList, etc!

Current blockers

There are 4 non-archived repos that use Panda, still on Scala 2.12:

See also

rtyley added a commit that referenced this issue Aug 9, 2024
rtyley added a commit that referenced this issue Nov 22, 2024
See:

* #149 - dropping Scala 2.12
* #161 - supporting Scala 3

### Need to import `play.api.libs.ws._` for the `BodyWritable`

Panda's `OAuth` class posts some url-encoded data (defined as `Map[String, Seq[String]]`
in Scala) with `ws.url(dd.token_endpoint).post`, and this needs an implicit instance of
`BodyWritable[Map[String, Seq[String]]]` in order to work! For some reason, in Scala 2,
the compiler was able to find the correct implicit somewhere, but in Scala 3 we get a
compilation error:

```
[error] 81 |        }.flatMap { response =>
[error]    |         ^
[error]    |Cannot find an instance of Map[K, Seq[String]] to WSBody. Define a BodyWritable[Map[K, Seq[String]]] or extend play.api.libs.ws.ahc.DefaultBodyWritables
[error]    |
[error]    |where:    K is a type variable with constraint >: String
[error]    |
[error]    |One of the following imports might fix the problem:
[error]    |
[error]    |
[error]    |One of the following imports might fix the problem:
[error]    |
[error]    |  import play.api.libs.ws.DefaultBodyWritables.writeableOf_urlEncodedForm
[error]    |  import play.api.libs.ws.WSBodyWritables.writeableOf_urlEncodedForm
[error]    |  import play.api.libs.ws.writeableOf_urlEncodedForm
```

Importing the whole `ws` package fixes the problem:

```
import play.api.libs.ws._
```
rtyley added a commit that referenced this issue Nov 23, 2024
See:

* #149 - dropping Scala 2.12
* #161 - supporting Scala 3

### Need to import `play.api.libs.ws._` for the `BodyWritable`

Panda's `OAuth` class posts some url-encoded data (defined as `Map[String, Seq[String]]`
in Scala) with `ws.url(dd.token_endpoint).post`, and this needs an implicit instance of
`BodyWritable[Map[String, Seq[String]]]` in order to work! For some reason, in Scala 2,
the compiler was able to find the correct implicit somewhere, but in Scala 3 we get a
compilation error:

```
[error] 81 |        }.flatMap { response =>
[error]    |         ^
[error]    |Cannot find an instance of Map[K, Seq[String]] to WSBody. Define a BodyWritable[Map[K, Seq[String]]] or extend play.api.libs.ws.ahc.DefaultBodyWritables
[error]    |
[error]    |where:    K is a type variable with constraint >: String
[error]    |
[error]    |One of the following imports might fix the problem:
[error]    |
[error]    |
[error]    |One of the following imports might fix the problem:
[error]    |
[error]    |  import play.api.libs.ws.DefaultBodyWritables.writeableOf_urlEncodedForm
[error]    |  import play.api.libs.ws.WSBodyWritables.writeableOf_urlEncodedForm
[error]    |  import play.api.libs.ws.writeableOf_urlEncodedForm
```

Importing the whole `ws` package fixes the problem:

```
import play.api.libs.ws._
```
rtyley added a commit that referenced this issue Nov 23, 2024
See:

* #149 - dropping Scala 2.12
* #161 - supporting Scala 3

## Code changes required for Scala 3

### Controller endpoint definitions often need their return type declared

Explicitly declaring the return type is necessary on many endpoint definitions, or Scala 3
reports an 'ambiguous overload' error:

```
[error] -- [E051] Reference Error: /Users/Roberto_Tyley/code/pan-domain-authentication/pan-domain-auth-example/app/controllers/AdminController.scala:42:15
[error] 42 |  def logout = Action { implicit request =>
[error]    |               ^^^^^^
[error]    |Ambiguous overload. The overloaded alternatives of method apply in trait ActionBuilder with types
[error]    | (block: play.api.mvc.Request[play.api.mvc.AnyContent] => play.api.mvc.Result):
[error]    |  play.api.mvc.Action[play.api.mvc.AnyContent]
[error]    | [A]
[error]    |  (bodyParser: play.api.mvc.BodyParser[A]):
[error]    |    play.api.mvc.ActionBuilder[play.api.mvc.Request, A]
[error]    |both match arguments (<?> => <?>)
[error]    |
[error]    | longer explanation available when compiling with `-explain`
```

### Need to import `play.api.libs.ws._` for the `BodyWritable`

Panda's `OAuth` class posts some url-encoded data (defined as `Map[String, Seq[String]]`
in Scala) with `ws.url(dd.token_endpoint).post`, and this needs an implicit instance of
`BodyWritable[Map[String, Seq[String]]]` in order to work! For some reason, in Scala 2,
the compiler was able to find the correct implicit somewhere, but in Scala 3 we get a
compilation error:

```
[error] 81 |        }.flatMap { response =>
[error]    |         ^
[error]    |Cannot find an instance of Map[K, Seq[String]] to WSBody. Define a BodyWritable[Map[K, Seq[String]]] or extend play.api.libs.ws.ahc.DefaultBodyWritables
[error]    |
[error]    |where:    K is a type variable with constraint >: String
[error]    |
[error]    |One of the following imports might fix the problem:
[error]    |
[error]    |
[error]    |One of the following imports might fix the problem:
[error]    |
[error]    |  import play.api.libs.ws.DefaultBodyWritables.writeableOf_urlEncodedForm
[error]    |  import play.api.libs.ws.WSBodyWritables.writeableOf_urlEncodedForm
[error]    |  import play.api.libs.ws.writeableOf_urlEncodedForm
```

Importing the whole `ws` package fixes the problem:

```
import play.api.libs.ws._
```
rtyley added a commit that referenced this issue Nov 28, 2024
See:

* #149 - dropping Scala 2.12
* #161 - supporting Scala 3

Explicitly declaring the return type is necessary on many endpoint definitions, or Scala 3
reports an 'ambiguous overload' error:

```
[error] -- [E051] Reference Error: /Users/Roberto_Tyley/code/pan-domain-authentication/pan-domain-auth-example/app/controllers/AdminController.scala:42:15
[error] 42 |  def logout = Action { implicit request =>
[error]    |               ^^^^^^
[error]    |Ambiguous overload. The overloaded alternatives of method apply in trait ActionBuilder with types
[error]    | (block: play.api.mvc.Request[play.api.mvc.AnyContent] => play.api.mvc.Result):
[error]    |  play.api.mvc.Action[play.api.mvc.AnyContent]
[error]    | [A]
[error]    |  (bodyParser: play.api.mvc.BodyParser[A]):
[error]    |    play.api.mvc.ActionBuilder[play.api.mvc.Request, A]
[error]    |both match arguments (<?> => <?>)
[error]    |
[error]    | longer explanation available when compiling with `-explain`
```

Panda's `OAuth` class posts some url-encoded data (defined as `Map[String, Seq[String]]`
in Scala) with `ws.url(dd.token_endpoint).post`, and this needs an implicit instance of
`BodyWritable[Map[String, Seq[String]]]` in order to work! For some reason, in Scala 2,
the compiler was able to find the correct implicit somewhere, but in Scala 3 we get a
compilation error:

```
[error] 81 |        }.flatMap { response =>
[error]    |         ^
[error]    |Cannot find an instance of Map[K, Seq[String]] to WSBody. Define a BodyWritable[Map[K, Seq[String]]] or extend play.api.libs.ws.ahc.DefaultBodyWritables
[error]    |
[error]    |where:    K is a type variable with constraint >: String
[error]    |
[error]    |One of the following imports might fix the problem:
[error]    |
[error]    |
[error]    |One of the following imports might fix the problem:
[error]    |
[error]    |  import play.api.libs.ws.DefaultBodyWritables.writeableOf_urlEncodedForm
[error]    |  import play.api.libs.ws.WSBodyWritables.writeableOf_urlEncodedForm
[error]    |  import play.api.libs.ws.writeableOf_urlEncodedForm
```

Importing the whole `ws` package fixes the problem:

```
import play.api.libs.ws._
```
rtyley added a commit that referenced this issue Nov 28, 2024
See:

* #149 - dropping Scala 2.12
* #161 - supporting Scala 3

Explicitly declaring the return type is necessary on many endpoint definitions, or Scala 3
reports an 'ambiguous overload' error:

```
[error] -- [E051] Reference Error: /Users/Roberto_Tyley/code/pan-domain-authentication/pan-domain-auth-example/app/controllers/AdminController.scala:42:15
[error] 42 |  def logout = Action { implicit request =>
[error]    |               ^^^^^^
[error]    |Ambiguous overload. The overloaded alternatives of method apply in trait ActionBuilder with types
[error]    | (block: play.api.mvc.Request[play.api.mvc.AnyContent] => play.api.mvc.Result):
[error]    |  play.api.mvc.Action[play.api.mvc.AnyContent]
[error]    | [A]
[error]    |  (bodyParser: play.api.mvc.BodyParser[A]):
[error]    |    play.api.mvc.ActionBuilder[play.api.mvc.Request, A]
[error]    |both match arguments (<?> => <?>)
[error]    |
[error]    | longer explanation available when compiling with `-explain`
```

Panda's `OAuth` class posts some url-encoded data (defined as `Map[String, Seq[String]]`
in Scala) with `ws.url(dd.token_endpoint).post`, and this needs an implicit instance of
`BodyWritable[Map[String, Seq[String]]]` in order to work! For some reason, in Scala 2,
the compiler was able to find the correct implicit somewhere, but in Scala 3 we get a
compilation error:

```
[error] 81 |        }.flatMap { response =>
[error]    |         ^
[error]    |Cannot find an instance of Map[K, Seq[String]] to WSBody. Define a BodyWritable[Map[K, Seq[String]]] or extend play.api.libs.ws.ahc.DefaultBodyWritables
[error]    |
[error]    |where:    K is a type variable with constraint >: String
[error]    |
[error]    |One of the following imports might fix the problem:
[error]    |
[error]    |
[error]    |One of the following imports might fix the problem:
[error]    |
[error]    |  import play.api.libs.ws.DefaultBodyWritables.writeableOf_urlEncodedForm
[error]    |  import play.api.libs.ws.WSBodyWritables.writeableOf_urlEncodedForm
[error]    |  import play.api.libs.ws.writeableOf_urlEncodedForm
```

Importing the whole `ws` package fixes the problem:

```
import play.api.libs.ws._
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant