Skip to content

Enumerate all transitive self types in generated SOAP bindings#595

Merged
eed3si9n merged 2 commits into
eed3si9n:developfrom
fthomas:topic/transitive-self-types
Feb 11, 2023
Merged

Enumerate all transitive self types in generated SOAP bindings#595
eed3si9n merged 2 commits into
eed3si9n:developfrom
fthomas:topic/transitive-self-types

Conversation

@fthomas
Copy link
Copy Markdown
Contributor

@fthomas fthomas commented Feb 10, 2023

Problem

In Scala 3 the self type must enumerate all transitive self types. That means that generated code like this is rejected by the Scala 3 compiler:

trait HttpClients {}
trait Soap11Clients { this: HttpClients => }
trait FooSoapBindings { this: Soap11Clients => }

It complains with:

[error] -- [E058] Type Mismatch Error: Test.scala:6:8
[error] 6 |  trait FooSoapBindings { this: Soap11Clients => } // error
[error]   |        ^
[error]   |missing requirement: self type Soap11Clients & FooSoapBindings of trait FooSoapBindings does not conform to self type HttpClients
[error]   |of required trait Soap11Clients

Solution

The solution is to add scalaxb.HttpClients (or scalaxb.HttpClientsAsync) to the self type of the generated SOAP bindings. Scala 2 is still happy with this change and Scala 3 is now able to compile the generated bindings.

I've tested these changes by publishing this branch locally and by using the local sbt-scalaxb 1.9.1-SNAPSHOT plugin to generate code that was then compiled with Scala 3.2.2. It compiled successfully with both scalaxbAsync := true and false.

Closes: #557

Problem
-------

In Scala 3 the self type must enumerate all transitive self types. That
means that generated code like this is rejected by the Scala 3
compiler:
```scala
trait HttpClients {}
trait Soap11Clients { this: HttpClients => }
trait FooSoapBindings { this: Soap11Clients => }
```

It complains with:
```
[error] -- [E058] Type Mismatch Error: Test.scala:6:8
[error] 6 |  trait FooSoapBindings { this: Soap11Clients => } // error
[error]   |        ^
[error]   |missing requirement: self type Soap11Clients & FooSoapBindings of trait FooSoapBindings does not conform to self type HttpClients
[error]   |of required trait Soap11Clients
```

Solution
--------

The solution is to add `HttpClients` (or `scalaxb.HttpClientsAsync`) to
the self type of the generated SOAP bindings. Scala 2 is still happy
with this change and Scala 3 is now able to compile the generated
bindings.
Copy link
Copy Markdown
Owner

@eed3si9n eed3si9n left a comment

Choose a reason for hiding this comment

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

Thanks @fthomas!

@eed3si9n eed3si9n merged commit 1434921 into eed3si9n:develop Feb 11, 2023
@fthomas fthomas deleted the topic/transitive-self-types branch February 11, 2023 19:00
@fthomas
Copy link
Copy Markdown
Contributor Author

fthomas commented Feb 11, 2023

Thanks for releasing this so quickly @eed3si9n!

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

Successfully merging this pull request may close these issues.

Scala 3 / Dotty support

2 participants