Skip to content

Commit 4ff0d9f

Browse files
committed
chore: add -Yno-stdlib-patches flag for the stdlib migration
1 parent 03a54a7 commit 4ff0d9f

File tree

4 files changed

+23
-0
lines changed

4 files changed

+23
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,7 @@ private sealed trait YSettings:
397397
val Ylog: Setting[List[String]] = PhasesSetting(ForkSetting, "Ylog", "Log operations during")
398398
val YlogClasspath: Setting[Boolean] = BooleanSetting(ForkSetting, "Ylog-classpath", "Output information about what classpath is being applied.")
399399
val YdisableFlatCpCaching: Setting[Boolean] = BooleanSetting(ForkSetting, "YdisableFlatCpCaching", "Do not cache flat classpath representation of classpath elements from jars across compiler instances.")
400+
val YnoStdlibPatches: Setting[Boolean] = BooleanSetting(ForkSetting, "Yno-stdlib-patches", "Do not patch stdlib files (temporary and only to be used for the stdlib migration)", false)
400401

401402
val Yscala2Unpickler: Setting[String] = StringSetting(ForkSetting, "Yscala2-unpickler", "", "Control where we may get Scala 2 symbols from. This is either \"always\", \"never\", or a classpath.", "always")
402403

compiler/src/dotty/tools/dotc/core/Definitions.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1468,6 +1468,11 @@ class Definitions {
14681468
* is read from a classfile.
14691469
*/
14701470
def patchStdLibClass(denot: ClassDenotation)(using Context): Unit =
1471+
// Do not patch the stdlib files if we explicitly disable it
1472+
// This is only to be used during the migration of the stdlib
1473+
if ctx.settings.YnoStdlibPatches.value then
1474+
return
1475+
14711476
def patch2(denot: ClassDenotation, patchCls: Symbol): Unit =
14721477
val scope = denot.info.decls.openForMutations
14731478

tests/neg/no-patches.check

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
-- [E008] Not Found Error: tests/neg/no-patches.scala:3:23 -------------------------------------------------------------
2+
3 |val _ = scala.language.`3.4` // error: we do not patch `scala.language`
3+
| ^^^^^^^^^^^^^^^^^^^^
4+
| value 3.4 is not a member of object language
5+
-- [E008] Not Found Error: tests/neg/no-patches.scala:4:36 -------------------------------------------------------------
6+
4 |val _ = scala.language.experimental.captureChecking // error: we do not patch `scala.language.experimental`
7+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
8+
| value captureChecking is not a member of object language.experimental
9+
-- [E008] Not Found Error: tests/neg/no-patches.scala:5:15 -------------------------------------------------------------
10+
5 |val _ = Predef.summon[DummyImplicit] // error: we do not patch `scala.Predef`
11+
| ^^^^^^^^^^^^^
12+
| value summon is not a member of object Predef

tests/neg/no-patches.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
//> using options -Yno-stdlib-patches
2+
3+
val _ = scala.language.`3.4` // error: we do not patch `scala.language`
4+
val _ = scala.language.experimental.captureChecking // error: we do not patch `scala.language.experimental`
5+
val _ = Predef.summon[DummyImplicit] // error: we do not patch `scala.Predef`

0 commit comments

Comments
 (0)