Skip to content

Command line options to control Scala versions and migration? #8571

Closed
@odersky

Description

@odersky

We should regularize our options for controlling language versions and migration.

The current state

Option What it does
-language:Scala2Compat Some effort is made to support Scala-2 idioms.
-migration Issue migration warnings, otherwise these are bunched, like deprecation warnings
-rewrite When used with -migration perform some rewrites from Scala 2 -> Scala 3
-strict Keep to a stricter language that avoids some fragile or unsound code

A possible alternative

Option What it does
-source Set source version. Legal values for now: 3.0, 3.1. 3.0 is the default.
-migration Some effort is made to also support earlier language versions (such as Scala 2.13, or Scala 3.0 if -source is 3.1) and migration warnings are issued where something is no longer supported without -migration in the new source version. Migration warnings are always emitted, never bunched
-rewrite When used with -migration perform some automatic rewrites from old to new version

So, we'd have the following equivalences between current state and alternative:

  • -language:Scala2Compat -migration maps to -source 3.0 -migration or simply -migration
  • -language:Scala2Compat -migration -rewrite maps to -migration -rewrite
  • -strict maps to -source 3.1
  • -language:Scala2Compat alone does not map to anything -- you can't support dropped features without migration warnings.

Btw, what was the motivation in Scala 2 to use -Xsource:version instead of -source version as Java does? It seems source version should be a standard option, so -X seems out of place.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions