Skip to content

chore: add -Yno-stdlib-patches flag for the stdlib migration #23540

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

Merged
merged 1 commit into from
Jul 16, 2025
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions compiler/src/dotty/tools/dotc/config/ScalaSettings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ private sealed trait YSettings:
val Ylog: Setting[List[String]] = PhasesSetting(ForkSetting, "Ylog", "Log operations during")
val YlogClasspath: Setting[Boolean] = BooleanSetting(ForkSetting, "Ylog-classpath", "Output information about what classpath is being applied.")
val YdisableFlatCpCaching: Setting[Boolean] = BooleanSetting(ForkSetting, "YdisableFlatCpCaching", "Do not cache flat classpath representation of classpath elements from jars across compiler instances.")
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)

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")

Expand Down
5 changes: 5 additions & 0 deletions compiler/src/dotty/tools/dotc/core/Definitions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1468,6 +1468,11 @@ class Definitions {
* is read from a classfile.
*/
def patchStdLibClass(denot: ClassDenotation)(using Context): Unit =
// Do not patch the stdlib files if we explicitly disable it
// This is only to be used during the migration of the stdlib
if ctx.settings.YnoStdlibPatches.value then
return

def patch2(denot: ClassDenotation, patchCls: Symbol): Unit =
val scope = denot.info.decls.openForMutations

Expand Down
12 changes: 12 additions & 0 deletions tests/neg/no-patches.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
-- [E008] Not Found Error: tests/neg/no-patches.scala:3:23 -------------------------------------------------------------
3 |val _ = scala.language.`3.4` // error: we do not patch `scala.language`
| ^^^^^^^^^^^^^^^^^^^^
| value 3.4 is not a member of object language
-- [E008] Not Found Error: tests/neg/no-patches.scala:4:36 -------------------------------------------------------------
4 |val _ = scala.language.experimental.captureChecking // error: we do not patch `scala.language.experimental`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| value captureChecking is not a member of object language.experimental
-- [E008] Not Found Error: tests/neg/no-patches.scala:5:15 -------------------------------------------------------------
5 |val _ = Predef.summon[DummyImplicit] // error: we do not patch `scala.Predef`
| ^^^^^^^^^^^^^
| value summon is not a member of object Predef
5 changes: 5 additions & 0 deletions tests/neg/no-patches.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//> using options -Yno-stdlib-patches

val _ = scala.language.`3.4` // error: we do not patch `scala.language`
val _ = scala.language.experimental.captureChecking // error: we do not patch `scala.language.experimental`
val _ = Predef.summon[DummyImplicit] // error: we do not patch `scala.Predef`
Loading