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

Generate scala code compliant with -Xsource:3 #307

Closed
Christewart opened this issue May 15, 2024 · 7 comments
Closed

Generate scala code compliant with -Xsource:3 #307

Christewart opened this issue May 15, 2024 · 7 comments

Comments

@Christewart
Copy link

Christewart commented May 15, 2024

I'm attempting to update my grpc project to use the -Xsource:3

https://docs.scala-lang.org/scala3/guides/migration/tooling-scala2-xsource3.html

I can use -quickfix:any to re-write the generated scala code, however if I don't constantly keep -quickfix:any in the scalacOptions, the code will revert back to the non compliant -Xsource:3 after a clean

In bitcoin-s, the project that uses grpc is lndRpc. You can reproduce this by running lndRpc/compile

bitcoin-s/bitcoin-s#5595

You can see the failures on CI here: https://github.com/bitcoin-s/bitcoin-s/actions/runs/9097285380/job/25004754803

@pjfanning
Copy link
Contributor

We still support scala 2.12 so we will not be making scala3 style source the default. If someone finds a way to make this configurable - then we can go that route.

@Christewart
Copy link
Author

Christewart commented May 15, 2024

We still support scala 2.12 so we will not be making scala3 style source the default. If someone finds a way to make this configurable - then we can go that route.

I think in my case, its literally just adding type annotations to the generated scala code

The non compliant -Xsource:3 code

//does not compile with `-Xsource:3`
lazy val values = scala.collection.immutable.Seq(LEGACY, ANCHOR)

what -quickfix:any rewrites it to

//compiles with -Xsource:3 because `values` has the type annotation
lazy val values: Seq[wtclientrpc.PolicyType.Recognized] = scala.collection.immutable.Seq(LEGACY, ANCHOR)

Now if I re-compile, removing the -quickfix:any compiler flag, I revert back to the first version with no type annotation on values

I know collections were redone in 2.13.x, does this mean this can't safely be done while still supporting 2.12.x?

@pjfanning
Copy link
Contributor

@Christewart this is a volunteer project. Noone works full time on it. If you would like to try a solution, we will review any PRs.

@pjfanning
Copy link
Contributor

pekko-grpc codegen is built on top of https://github.com/scalapb/ScalaPB and it is ScalaPB that generates the source for the lazy val values as far as I can see.

@pjfanning
Copy link
Contributor

ScalaPB recently added scalapb/ScalaPB@83b849f

In the next few weeks, we should be releasing a 1.1.0-M1 version of pekko-grpc that uses the latest ScalaPB release

@pjfanning
Copy link
Contributor

closing - as we already have #222

@pjfanning
Copy link
Contributor

https://pekko.apache.org/docs/pekko-grpc/current/buildtools/sbt.html#generating-server-

With Pekko-GRPC 1.1 snapshots or releases, you should be able to add this to your sbt file.

pekkoGrpcCodeGeneratorSettings += "scala3_sources"

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

2 participants