Skip to content

Fix generated code on Scala 3 - #697

Merged
eed3si9n merged 1 commit into
eed3si9n:developfrom
mrdziuban:fix-scala3-formatting
Oct 10, 2025
Merged

eed3si9n merged 1 commit into
eed3si9n:developfrom
mrdziuban:fix-scala3-formatting

Conversation

@mrdziuban

Copy link
Copy Markdown
Contributor

I was testing out scalaxb with sbt 2 and found that it generated invalid code:

trait BasicHttpBinding_IMyServiceBindings { this: scalaxb.Soap11ClientsAsync & scalaxb.HttpClientsAsync =>
  
  lazy val targetNamespace: Option[String] = Some("http://example.com/schemas/myervice")
  lazy val service: com.example.generated.IMyService = new BasicHttpBinding_IMyServiceBinding {}
  def baseAddress = new java.net.URI("https://example.com/MyService.svc")

  trait BasicHttpBinding_IMyServiceBinding extends com.example.generated.IMyService {
    import scalaxb.ElemName._
    def exampleOperation(message: com.example.generated.MessageType)(implicit ec: ExecutionContext): Future[com.example.generated.ResponseType] = 
                    case x => x
          })
  }
}

Note that the body of exampleOperation is missing a lot of what's supposed to be there, the only thing that makes it is

                      case x => x
            })

I think this has to do with significant whitespace/indentation in Scala 3, but it still happens even when setting the -no-indent scalac option.

Instead what does work is using format to interpolate all arguments, rather than combining it with string concatenation.

@eed3si9n eed3si9n left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks!

@eed3si9n
eed3si9n merged commit ad393a4 into eed3si9n:develop Oct 10, 2025
8 checks passed
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.

2 participants