Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

cross-building with source:3.0-migration compiler option #16720

RustedBones started this conversation in General Discussion
Discussion options

I'm cross-building a library with scala 2.12 and 2.13 and wanted to add support for scala 3.2.1
I added the -source:3.0-migration scalac option for scala 3, hoping to get some warnings from the compiler on the shared code.

However, this setup does not work if my module contains a specific scala-3 source folder.

if for instance I have in src/main/scala-3/example/Test.scala

package example
trait Test:
 def greet: Unit =
 println("Hello")

The compiler will not accept the new syntax and prints

[error] -- Error: /path/src/main/scala-3/example/Test.scala:4:2 
[error] 4 | def greet: Unit =
[error] | ^^^
[error] | indented definitions expected, def found

Shouldn't the compiler consider scala-3 source folder as already migrated ?

You must be logged in to vote

Replies: 1 comment

Comment options

I'm afraid that the scalac option is applied to the whole compilation classpath by sbt. In the compiler, we don't differentiate directories based on their name (like the scala-3 directory here, which sbt uses to filter the compilation classpath based on the used scala version). Moreover, it is not possible to apply an option to only a part of compilation classpath. Best idea I have for this case is to temporarily split the codebase into separate modules:

  1. one with only the files in scala-3 directory, which does not use the "-source:3.0-migration" option
  2. one with all of the other cross-compiled files, which uses the "-source:3.0-migration"

This could be problematic, since the (2.) would have to depend on (1.) (or vice versa), which may not always be possible.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /