Skip to content

Commit b42c17f

Browse files
committed
Get rid of initialization order errors
1 parent 575e4a7 commit b42c17f

File tree

3 files changed

+15
-16
lines changed

3 files changed

+15
-16
lines changed

src/dotty/tools/dotc/reporting/diagnostic/MessageCreator.scala

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,31 +24,30 @@ object MessageCreator {
2424
trait MessageCreator {
2525
import messages._
2626

27-
val msgFn: String = msg
2827
def msg: String
2928
def kind: String
3029
def explanation: String
3130

3231
def error(pos: SourcePosition) =
33-
new Error(msgFn, pos, kind, explanation)
32+
new Error(msg, pos, kind, explanation)
3433

3534
def warning(pos: SourcePosition) =
36-
new Warning(msgFn, pos, kind, explanation)
35+
new Warning(msg, pos, kind, explanation)
3736

3837
def info(pos: SourcePosition) =
39-
new Info(msgFn, pos, kind, explanation)
38+
new Info(msg, pos, kind, explanation)
4039

4140
def featureWarnign(pos: SourcePosition) =
42-
new FeatureWarning(msgFn, pos, kind, explanation)
41+
new FeatureWarning(msg, pos, kind, explanation)
4342

4443
def uncheckedWarning(pos: SourcePosition) =
45-
new UncheckedWarning(msgFn, pos, kind, explanation)
44+
new UncheckedWarning(msg, pos, kind, explanation)
4645

4746
def deprecationWarning(pos: SourcePosition) =
48-
new DeprecationWarning(msgFn, pos, kind, explanation)
47+
new DeprecationWarning(msg, pos, kind, explanation)
4948

5049
def migrationWarning(pos: SourcePosition) =
51-
new MigrationWarning(msgFn, pos, kind, explanation)
50+
new MigrationWarning(msg, pos, kind, explanation)
5251
}
5352

5453
class NoExplanation(val msg: String) extends MessageCreator {

src/dotty/tools/dotc/reporting/diagnostic/syntax.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ object syntax {
1313
import dotc.ast.untpd
1414

1515
abstract class EmptyCatchOrFinallyBlock(tryBody: untpd.Tree)(implicit ctx: Context) extends MessageCreator {
16-
lazy val explanation = {
16+
val explanation = {
1717
val tryString = tryBody match {
1818
case Block(Nil, untpd.EmptyTree) => "{}"
1919
case _ => tryBody.show
@@ -47,16 +47,16 @@ object syntax {
4747

4848
class EmptyCatchBlock(tryBody: untpd.Tree)(implicit ctx: Context)
4949
extends EmptyCatchOrFinallyBlock(tryBody) {
50-
lazy val kind = "Syntax"
51-
lazy val msg =
50+
val kind = "Syntax"
51+
val msg =
5252
hl"""|The ${"catch"} block does not contain a valid expression, try
5353
|adding a case like - `${"case e: Exception =>"}` to the block""".stripMargin
5454
}
5555

5656
case class EmptyCatchAndFinallyBlock(tryBody: untpd.Tree)(implicit ctx: Context)
5757
extends EmptyCatchOrFinallyBlock(tryBody) {
58-
lazy val kind = "Syntax"
59-
lazy val msg =
58+
val kind = "Syntax"
59+
val msg =
6060
hl"""|A ${"try"} without ${"catch"} or ${"finally"} is equivalent to putting
6161
|its body in a block; no exceptions are handled.""".stripMargin
6262
}

src/dotty/tools/dotc/reporting/diagnostic/tpe.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ object tpe {
1616
bind: untpd.Bind,
1717
tree: untpd.CaseDef
1818
)(implicit ctx: Context) extends MessageCreator {
19-
lazy val kind = "Naming"
19+
val kind = "Naming"
2020

21-
lazy val msg =
21+
val msg =
2222
em"duplicate pattern variable: `${bind.name}`"
2323

24-
lazy val explanation = {
24+
val explanation = {
2525
val pat = tree.pat.show
2626
val guard = tree.guard match {
2727
case untpd.EmptyTree => ""

0 commit comments

Comments
 (0)