Skip to content

Commit

Permalink
Fix compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
WojciechMazur committed Dec 3, 2024
1 parent 1879cb7 commit f372d14
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
5 changes: 2 additions & 3 deletions compiler/src/dotty/tools/dotc/config/ScalaSettings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -282,15 +282,15 @@ private sealed trait WarningSettings:
|to prevent the shell from expanding patterns.""".stripMargin,
)

val WcheckInit: Setting[Boolean] = BooleanSetting("-Wsafe-init", "Ensure safe initialization of objects.")
val YcheckInit: Setting[Boolean] = BooleanSetting("-Ysafe-init", "Ensure safe initialization of objects.")

object Whas:
def allOr(s: Setting[Boolean])(using Context): Boolean =
Wall.value || s.value
def valueDiscard(using Context): Boolean = allOr(WvalueDiscard)
def nonUnitStatement(using Context): Boolean = allOr(WNonUnitStatement)
def enumCommentDiscard(using Context): Boolean = allOr(WenumCommentDiscard)
def checkInit(using Context): Boolean = allOr(WcheckInit)
def checkInit(using Context): Boolean = allOr(YcheckInit)

/** -X "Extended" or "Advanced" settings */
private sealed trait XSettings:
Expand Down Expand Up @@ -429,7 +429,6 @@ private sealed trait YSettings:
// Experimental language features
val YnoKindPolymorphism: Setting[Boolean] = BooleanSetting("-Yno-kind-polymorphism", "Disable kind polymorphism.")
val YexplicitNulls: Setting[Boolean] = BooleanSetting("-Yexplicit-nulls", "Make reference types non-nullable. Nullable types can be expressed with unions: e.g. String|Null.")
val YcheckInit: Setting[Boolean] = BooleanSetting("-Ysafe-init", "Ensure safe initialization of objects.")
val YrequireTargetName: Setting[Boolean] = BooleanSetting("-Yrequire-targetName", "Warn if an operator is defined without a @targetName annotation.")
val YrecheckTest: Setting[Boolean] = BooleanSetting("-Yrecheck-test", "Run basic rechecking (internal test only).")
val YccDebug: Setting[Boolean] = BooleanSetting("-Ycc-debug", "Used in conjunction with captureChecking language import, debug info for captured references.")
Expand Down
2 changes: 1 addition & 1 deletion tests/pos-with-compiler-cc/dotc/core/Symbols.scala
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ object Symbols {
ctx.settings.YretainTrees.value ||
denot.owner.isTerm || // no risk of leaking memory after a run for these
denot.isOneOf(InlineOrProxy) || // need to keep inline info
ctx.settings.YcheckInit.value // initialization check
ctx.settings.Whas.checkInit // initialization check

/** The last denotation of this symbol */
private var lastDenot: SymDenotation = _
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Checker extends Phase:
override val runsAfter = Set(Pickler.name)

override def isEnabled(using Context): Boolean =
super.isEnabled && ctx.settings.YcheckInit.value
super.isEnabled && ctx.settings.Whas.checkInit

override def runOn(units: List[CompilationUnit])(using Context): List[CompilationUnit] =
val checkCtx = ctx.fresh.setPhase(this.start)
Expand Down
16 changes: 8 additions & 8 deletions tests/warn/i18559b.check
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
8 | val localFile: String = s"${url.##}.tmp" // warn
| ^
| Access non-initialized value localFile. Calling trace:
| ├── class RemoteFile(url: String) extends AbstractFile: [ i18559b.scala:7 ]
| ^
| ├── abstract class AbstractFile: [ i18559b.scala:3 ]
| ^
| ├── val extension: String = name.substring(4) [ i18559b.scala:5 ]
| ^^^^
| └── def name: String = localFile [ i18559b.scala:9 ]
| ^^^^^^^^^
| -> class RemoteFile(url: String) extends AbstractFile: [ i18559b.scala:7 ]
| ^
| -> abstract class AbstractFile: [ i18559b.scala:3 ]
| ^
| -> val extension: String = name.substring(4) [ i18559b.scala:5 ]
| ^^^^
| -> def name: String = localFile [ i18559b.scala:9 ]
| ^^^^^^^^^

0 comments on commit f372d14

Please sign in to comment.