Skip to content

Commit e1f00c8

Browse files
committed
-Yscala-release support: test cats-effect compiled with scala 3.0.2 while the dependencies are compiled with -Yscala-release 3.0; improve documentation
1 parent e39b618 commit e1f00c8

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

community-build/src/scala/dotty/communitybuild/projects.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ object projects:
517517
dependencies = () => List(cats, coop, disciplineSpecs2, scalacheck)
518518
)
519519

520-
lazy val catsEffect3ForwardCompat = catsEffect3.forwardCompat.withScalaRelease("3.0")
520+
lazy val catsEffect3ForwardCompat = catsEffect3.forwardCompat.copy(compilerVersion = "3.0.2")
521521

522522
lazy val scalaParallelCollections = SbtCommunityProject(
523523
project = "scala-parallel-collections",

compiler/src/dotty/tools/dotc/config/ScalaSettings.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ private sealed trait YSettings:
310310
val YexplicitNulls: Setting[Boolean] = BooleanSetting("-Yexplicit-nulls", "Make reference types non-nullable. Nullable types can be expressed with unions: e.g. String|Null.")
311311
val YcheckInit: Setting[Boolean] = BooleanSetting("-Ysafe-init", "Ensure safe initialization of objects")
312312
val YrequireTargetName: Setting[Boolean] = BooleanSetting("-Yrequire-targetName", "Warn if an operator is defined without a @targetName annotation")
313-
val YscalaRelease: Setting[String] = ChoiceSetting("-Yscala-release", "release", "Emit TASTy files that can be consumed by specified version of the compiler.", ScalaSettings.supportedScalaReleaseVersions, "", aliases = List("--Yscala-release"))
313+
val YscalaRelease: 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"))
314314

315315
/** Area-specific debug output */
316316
val YexplainLowlevel: Setting[Boolean] = BooleanSetting("-Yexplain-lowlevel", "When explaining type errors, show types at a lower level.")

docs/docs/contributing/testing.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,17 @@ $ sbt
127127
> testCompilation --help
128128
```
129129

130+
### Joint and separate sources compilation
131+
132+
When the sources of a test consist of multiple source files places in a single directory they are passed to the compiler in a single run and the compiler decides in which order to compile them. In some cases, however, to reproduce a specific test scenario it might be necessary to compile the source files in several steps in a specified order. To achieve that one can add a `_${step_index}` suffix to a file name (before the `.scala` or `.java` extension) indicating the order of compilation. E.g. if the test directory contains files named `Foo_1.scala`, `Bar_2.scala` and `Baz_2.scala` then `Foo_1.scala` will be compiled first and after that `Bar_2.scala` together with `Baz_2.scala`.
133+
134+
There are also other suffixes indicating how some particular files are compiled:
135+
* `_c${compilerVersion}` - compile a file with a specific version of the compiler instead of the one developed on the current branch
136+
(e.g. `Foo_c3.0.2.scala`)
137+
* `_r${release}` - compile a file with a given value of `-Yscala-release` flag (e.g. `Foo_r3.0.scala`)
138+
139+
Different suffixes can be mixed together (their order is not important although consistency is advised), e.g. `Foo_1_r3.0`, `Bar_2_c3.0.2`.
140+
130141
### Bootstrapped-only tests
131142

132143
To run `testCompilation` on a bootstrapped Dotty compiler, use

sbt-community-build/src/dotty/communitybuild/sbtplugin/CommunityBuildPlugin.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,12 @@ object CommunityBuildPlugin extends AutoPlugin {
5050
override val buildSettings: Seq[Setting[_]] = Seq(
5151
dependencyOverrides ++= {
5252
if (scalaVersion.value.startsWith("3.")) {
53-
val predicate: ModuleID => Boolean = if (isForwardCompatProject.value) (_.revision.contains("-forward-compat")) else (!_.revision.contains("-forward-compat"))
54-
CommunityBuildDependencies.allOverrides(sLog.value).filter(predicate)
53+
val forwardCompatFilter: ModuleID => Boolean = if (isForwardCompatProject.value) (_.revision.contains("-forward-compat")) else (!_.revision.contains("-forward-compat"))
54+
val stdlibOverrides = Seq(
55+
scalaOrganization.value %% "scala3-library" % scalaVersion.value,
56+
scalaOrganization.value %% "scala3-library_sjs1" % scalaVersion.value,
57+
)
58+
CommunityBuildDependencies.allOverrides(sLog.value).filter(forwardCompatFilter) ++ stdlibOverrides
5559
} else Nil
5660
}
5761
)

0 commit comments

Comments
 (0)