eed3si9n / scalaxb

scalaxb is an XML data binding tool for Scala.

Home Page:http://scalaxb.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Scala 3 / Dotty support

kalejami opened this issue · comments

Hi,

the first RC for scala 3 was released. Any plans for scalaxb for supporting scala 3?

Tried to compile against 3.0.0-RC1. Got some errors/migration warnings:

soap11_async.scala:47:26
[warn] 47 |      ftr map { s: String =>
[warn]    |                          ^
[warn]    |parentheses are required around the parameter of a lambda
[warn]    |This construct can be rewritten automatically under -rewrite -source 3.0-migration.
scalaxb.scala:703:24
[warn] 703 |          lookupSuccess(current, in) match {
[warn]     |                        ^^^^^^^
[warn]     |The conversion (ParserExt.this.ev : P => AnyElemNameParser.this.Parser[T]) will not be applied implicitly here in Scala 3 because only implicit methods and instances of Conversion class will continue to work as implicit views.
xmlprotocol.scala:2443:8
[error] 2443 |  trait [...]SoapBindings { this: scalaxb.Soap11ClientsAsync =>
[error]      |        ^
[error]      |missing requirement: self type scalaxb.Soap11ClientsAsync &
[error]      |  XMLProtocol.this.[...]SoapBindings of trait [...]SoapBindings does not conform to self type scalaxb.HttpClientsAsync

First official scala 3 release is out now: https://github.com/lampepfl/dotty/releases/tag/3.0.0

I tried scalaxb with Scala 3.2.2 today and could not reproduce the first two warnings @kalejami mentioned in #557 (comment). Unfortunately the third error is still there. After a closer look at the generated code, it seems that the error is caused by constructs like this:

object Test {
  trait HttpClients {}

  trait Soap11Clients { this: HttpClients => }

  trait FooSoapBindings { this: Soap11Clients => } // error

  // trait FooSoapBindings { this: Soap11Clients with HttpClients => } // ok
}

The complete error message with the -explain compiler option is:

[error] -- [E058] Type Mismatch Error: Test.scala:6:8
[error] 6 |  trait FooSoapBindings { this: Soap11Clients => } // error
[error]   |        ^
[error]   |missing requirement: self type Test.Soap11Clients & Test.FooSoapBindings of trait FooSoapBindings does not conform to self type Test.HttpClients
[error]   |of required trait Soap11Clients
[error]   |-----------------------------------------------------------------------------
[error]   | Explanation (enabled by `-explain`)
[error]   |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[error]   | I tried to show that
[error]   |   Test.Soap11Clients & Test.FooSoapBindings
[error]   | conforms to
[error]   |   Test.HttpClients
[error]   | but the comparison trace ended with `false`:
[error]   |
[error]   |   ==> Test.Soap11Clients & Test.FooSoapBindings  <:  Test.HttpClients
[error]   |     ==> glb(<notype>, <notype>)
[error]   |     <== glb(<notype>, <notype>) = <notype>
[error]   |     ==> Test.Soap11Clients  <:  Test.HttpClients
[error]   |     <== Test.Soap11Clients  <:  Test.HttpClients = false
[error]   |     ==> Test.FooSoapBindings  <:  Test.HttpClients
[error]   |     <== Test.FooSoapBindings  <:  Test.HttpClients = false
[error]   |   <== Test.Soap11Clients & Test.FooSoapBindings  <:  Test.HttpClients = false
[error]   |
[error]   | The tests were made under the empty constraint
[error]    -----------------------------------------------------------------------------

I don't know yet if it is expected that such constructs do not compile with Scala 3 or if it is a regression. This behaviour change is expected: scala/scala3#2467

One possible fix here is to extend the self type of FooSoapBindings with the self type of Soap11Clients as shown in the comment above (trait FooSoapBindings { this: Soap11Clients with HttpClients => }). The Scala 3 and Scala 2 compiler are both happy with this code.

One possible fix here is to extend the self type of FooSoapBindings with the self type of Soap11Clients as shown in the comment above (trait FooSoapBindings { this: Soap11Clients with HttpClients => }).

I've a branch with that change at develop...fthomas:scalaxb:topic/transitive-self-types. Changing the self type was easy but testing this here in scalaxb's build with Scala 3 seems to be the hard part.