Skip to content

Commit d06c06a

Browse files
committed
Guard the check under a flag
1 parent 4d2a084 commit d06c06a

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ private sealed trait YSettings:
379379
val YnoKindPolymorphism: Setting[Boolean] = BooleanSetting("-Yno-kind-polymorphism", "Disable kind polymorphism.")
380380
val YexplicitNulls: Setting[Boolean] = BooleanSetting("-Yexplicit-nulls", "Make reference types non-nullable. Nullable types can be expressed with unions: e.g. String|Null.")
381381
val YcheckInit: Setting[Boolean] = BooleanSetting("-Ysafe-init", "Ensure safe initialization of objects")
382+
val YcheckInitGlobal: Setting[Boolean] = BooleanSetting("-Ysafe-init-global", "Check safe initialization of global objects")
382383
val YrequireTargetName: Setting[Boolean] = BooleanSetting("-Yrequire-targetName", "Warn if an operator is defined without a @targetName annotation")
383384
val YrecheckTest: Setting[Boolean] = BooleanSetting("-Yrecheck-test", "Run basic rechecking (internal test only)")
384385
val YccDebug: Setting[Boolean] = BooleanSetting("-Ycc-debug", "Used in conjunction with captureChecking language import, debug info for captured references")
@@ -396,4 +397,3 @@ private sealed trait YSettings:
396397

397398
val YforceInlineWhileTyping: Setting[Boolean] = BooleanSetting("-Yforce-inline-while-typing", "Make non-transparent inline methods inline when typing. Emulates the old inlining behavior of 3.0.0-M3.")
398399
end YSettings
399-

compiler/src/dotty/tools/dotc/transform/init/Checker.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ class Checker extends Phase:
3737
val classes = traverser.getClasses()
3838

3939
Semantic.checkClasses(classes)(using checkCtx)
40-
Objects.checkClasses(classes)(using checkCtx)
40+
41+
if ctx.settings.YcheckInitGlobal.value then
42+
Objects.checkClasses(classes)(using checkCtx)
4143

4244
units
4345

0 commit comments

Comments
 (0)