Skip to content

Commit 2858bd4

Browse files
committed
Guard the check under a flag
1 parent 2ccaed9 commit 2858bd4

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
@@ -380,6 +380,7 @@ private sealed trait YSettings:
380380
val YnoKindPolymorphism: Setting[Boolean] = BooleanSetting("-Yno-kind-polymorphism", "Disable kind polymorphism.")
381381
val YexplicitNulls: Setting[Boolean] = BooleanSetting("-Yexplicit-nulls", "Make reference types non-nullable. Nullable types can be expressed with unions: e.g. String|Null.")
382382
val YcheckInit: Setting[Boolean] = BooleanSetting("-Ysafe-init", "Ensure safe initialization of objects")
383+
val YcheckInitGlobal: Setting[Boolean] = BooleanSetting("-Ysafe-init-global", "Check safe initialization of global objects")
383384
val YrequireTargetName: Setting[Boolean] = BooleanSetting("-Yrequire-targetName", "Warn if an operator is defined without a @targetName annotation")
384385
val YrecheckTest: Setting[Boolean] = BooleanSetting("-Yrecheck-test", "Run basic rechecking (internal test only)")
385386
val YccDebug: Setting[Boolean] = BooleanSetting("-Ycc-debug", "Used in conjunction with captureChecking language import, debug info for captured references")
@@ -397,4 +398,3 @@ private sealed trait YSettings:
397398

398399
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.")
399400
end YSettings
400-

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)