You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
valsilentWarnings:Setting[Boolean] =BooleanSetting("-nowarn", "Silence all warnings.", aliases =List("--no-warnings"))
105
105
106
-
valrelease:Setting[String] =ChoiceSetting("-release", "release", "Compile code with classes specific to the given version of the Java platform available on the classpath and emit bytecode for this version.", ScalaSettings.supportedReleaseVersions, "", aliases =List("--release"))
106
+
valjavaOutputVersion:Setting[String] =ChoiceSetting("-java-output-version", "version", "Compile code with classes specific to the given version of the Java platform available on the classpath and emit bytecode for this version. Corresponds to -release flag in javac.", ScalaSettings.supportedReleaseVersions, "", aliases =List("-release", "--release"))
107
+
valscalaOutputVersion:Setting[String] =ChoiceSetting("-scala-output-version", "version", "Emit TASTy files that can be consumed by specified version of the compiler. The compilation will fail if for any reason valid TASTy cannot be produced (e.g. the code contains references to some parts of the standard library API that are missing in the older stdlib or uses language features unexpressible in the older version of TASTy format)", ScalaSettings.supportedScalaReleaseVersions, "")
108
+
107
109
valdeprecation:Setting[Boolean] =BooleanSetting("-deprecation", "Emit warning and location for usages of deprecated APIs.", aliases =List("--deprecation"))
108
110
valfeature:Setting[Boolean] =BooleanSetting("-feature", "Emit warning and location for usages of features that should be imported explicitly.", aliases =List("--feature"))
109
111
valexplain:Setting[Boolean] =BooleanSetting("-explain", "Explain errors in more detail.", aliases =List("--explain"))
valXignoreScala2Macros:Setting[Boolean] =BooleanSetting("-Xignore-scala2-macros", "Ignore errors when compiling code that calls Scala2 macros, these will fail at runtime.")
222
224
valXimportSuggestionTimeout:Setting[Int] =IntSetting("-Ximport-suggestion-timeout", "Timeout (in ms) for searching for import suggestions when errors are reported.", 8000)
223
225
valXsemanticdb:Setting[Boolean] =BooleanSetting("-Xsemanticdb", "Store information in SemanticDB.", aliases =List("-Ysemanticdb"))
224
-
valXtarget:Setting[String] =ChoiceSetting("-Xtarget", "target", "Emit bytecode for the specified version of the Java platform. This might produce bytecode that will break at runtime. When on JDK 9+, consider -release as a safer alternative.", ScalaSettings.supportedTargetVersions, "", aliases =List("--Xtarget"))
226
+
valXuncheckedJavaOutputVersion:Setting[String] =ChoiceSetting("-Xunchecked-java-output-version", "target", "Emit bytecode for the specified version of the Java platform. This might produce bytecode that will break at runtime. Corresponds to -target flag in javac. When on JDK 9+, consider -java-output-version as a safer alternative.", ScalaSettings.supportedTargetVersions, "", aliases =List("-Xtarget", "--Xtarget"))
225
227
valXcheckMacros:Setting[Boolean] =BooleanSetting("-Xcheck-macros", "Check some invariants of macro generated code while expanding macros", aliases =List("--Xcheck-macros"))
226
228
valXmainClass:Setting[String] =StringSetting("-Xmain-class", "path", "Class for manifest's Main-Class entry (only useful with -d <jar>)", "")
227
229
valXimplicitSearchLimit:Setting[Int] =IntSetting("-Ximplicit-search-limit", "Maximal number of expressions to be generated in an implicit search", 50000)
valYexplicitNulls:Setting[Boolean] =BooleanSetting("-Yexplicit-nulls", "Make reference types non-nullable. Nullable types can be expressed with unions: e.g. String|Null.")
311
313
valYcheckInit:Setting[Boolean] =BooleanSetting("-Ysafe-init", "Ensure safe initialization of objects")
312
314
valYrequireTargetName:Setting[Boolean] =BooleanSetting("-Yrequire-targetName", "Warn if an operator is defined without a @targetName annotation")
313
-
valYscalaRelease:Setting[String] =ChoiceSetting("-Yscala-release", "release", "Emit TASTy files that can be consumed by specified version of the compiler. The compilation will fail if for any reason valid TASTy cannot be produced (e.g. the code contains references to some parts of the standard library API that are missing in the older stdlib or uses language features unexpressible in the older version of TASTy format)", ScalaSettings.supportedScalaReleaseVersions, "", aliases =List("--Yscala-release"))
314
315
315
316
/** Area-specific debug output */
316
317
valYexplainLowlevel:Setting[Boolean] =BooleanSetting("-Yexplain-lowlevel", "When explaining type errors, show types at a lower level.")
Copy file name to clipboardExpand all lines: docs/docs/reference/language-versions/binary-compatibility.md
+5-5
Original file line number
Diff line number
Diff line change
@@ -14,14 +14,14 @@ TASTy version number has the format of `<major_version>.<minor_version>-<experim
14
14
Being able to bump the compiler version in a project without having to wait for all of its dependencies to do the same is already a big leap forward when compared to Scala 2. However, we might still try to do better, especially from the perspective of authors of libraries.
15
15
If you maintain a library and you would like it to be usable as a dependency for all Scala 3 projects, you would have to always emit TASTy in a version that would be readble by everyone, which would normally mean getting stuck at 3.0.x forever.
16
16
17
-
To solve this problem a new experimental compiler flag `-Yscala-release <release-version>` (available since 3.1.2-RC1) has been added. Setting this flag makes the compiler produce TASTy files that should be possible to use by all Scala 3 compilers in version `<release-version>` or newer (this flag was inspired by how `-release` works for specifying the target version of JDK). More specifically this enforces emitting TASTy files in an older format ensuring that:
18
-
* the code contains no references to parts of the standard library which were added to the API after `<release-version>` and would crash at runtime when a program is executed with the older version of the standard library on the classpath
19
-
* no dependency found on the classpath during compilation (except for the standard library itself) contains TASTy files produced by a compiler newer than `<release-version>` (otherwise they could potentially leak such disallowed references to the standard library).
17
+
To solve this problem a new experimental compiler flag `-scala-output-version <version>` (available since 3.1.2) has been added. Setting this flag makes the compiler produce TASTy files that should be possible to use by all Scala 3 compilers in version `<version>` or newer. This flag was inspired by how `-java-output-version` (formerly `-release`) works for specifying the target version of JDK. More specifically this enforces emitting TASTy files in an older format ensuring that:
18
+
* the code contains no references to parts of the standard library which were added to the API after `<version>` and would crash at runtime when a program is executed with the older version of the standard library on the classpath
19
+
* no dependency found on the classpath during compilation (except for the standard library itself) contains TASTy files produced by a compiler newer than `<version>` (otherwise they could potentially leak such disallowed references to the standard library).
20
20
21
21
If any of the checks above is not fulfilled or for any other reason older TASTy cannot be emitted (e.g. the code uses some new language features which cannot be expressed the the older format) the entire compilation fails (with errors reported for each of such issues).
22
22
23
23
As this feature is experimental it does not have any special support in build tools yet (at least not in sbt 1.6.1 or lower).
24
-
E.g. when a project gets compiled with Scala compiler `3.x1.y1` and `-Yscala-release 3.x2` option and then published using sbt
24
+
E.g. when a project gets compiled with Scala compiler `3.x1.y1` and `-scala-output-version 3.x2` option and then published using sbt
25
25
then the standard library in version `3.x1.y1` gets added to the project's dependencies instead of `3.x2.y2`.
26
26
When the dependencies are added to the classpath during compilation with Scala `3.x2.y2` the compiler will crash while trying to read TASTy files in the newer format.
27
27
A currently known workaround is to modify the build definition of the dependent project by explicitly overriding the version of Scala standard library in dependencies, e.g.
@@ -33,4 +33,4 @@ dependencyOverrides ++= Seq(
33
33
)
34
34
```
35
35
36
-
The behaviour of `-Yscala-release` flag might still change in the future, especially it's not guaranteed that every new version of the compiler would be able to generate TASTy in all older formats going back to the one produced by `3.0.x` compiler.
36
+
The behaviour of `-scala-output-version` flag might still change in the future, especially it's not guaranteed that every new version of the compiler would be able to generate TASTy in all older formats going back to the one produced by `3.0.x` compiler.
0 commit comments