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

Add source options #63

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions src/main/scala/io/github/davidgregory084/ScalacOptions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,39 @@ trait ScalacOptions {
def disableLintOption(name: String, isSupported: ScalaVersion => Boolean = _ => true) =
advancedOption(s"lint:-$name", isSupported)

/** Enables some Scala 3 syntax and behavior:
* - Most deprecated syntax generates an error.
* - Infix operators can start a line in the middle of a multiline expression.
* - Implicit search and overload resolution follow Scala 3 handling of contravariance when
* checking specificity.
*/
val earlySource3 =
advancedOption("source:3", version => version.isBetween(V2_13_0, V3_0_0))

def scala3Source(name: String) =
new ScalacOption(List(s"-source:$name", version => version >= V3_0_0))

/** Same as the enabled default `-source:3.0` but with additional helpers to migrate from 2.13. In addition:
* - flags some Scala 2 constructs that are disallowed in Scala 3 as migration warnings instead
* of hard errors
* - changes some rules to be more lenient and backwards compatible with Scala 2.13
* - gives some additional warnings where the semantics has changed between Scala 2.13 and 3.0
* - in conjunction with -rewrite, offer code rewrites from Scala 2.13 to 3.0
*/
val source3Migration =
scala3Source("3.0-migration")

/** A preview of changes introduced in the next versions after 3.0
*/
val source3Future =
scala3Source("future")

/** Same as `-source:future` but with additional helpers to migrate from 3.0. Similarly to the
* helpers available under 3.0-migration, these include migration warnings and optional rewrites.
*/
val source3FutureMigration =
scala3Source("future-migration")

/** Warn if an argument list is modified to match the receiver.
*/
val lintAdaptedArgs =
Expand Down