Skip to content

Commit 10339d1

Browse files
committed
Move 'var/val parameter may not be call-by-name' to error case class, improved explanation
1 parent e4b8e34 commit 10339d1

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,11 +1342,11 @@ object messages {
13421342
val msg = s"${if (mutable) "`var'" else "`val'"} parameters may not be call-by-name"
13431343
val kind = "Syntax"
13441344
val explanation =
1345-
hl"""Parameters of classes and traits may no be call-by-name. In case you
1346-
|want the parameter to be evaluated on demand, consider using a function
1347-
|and a lazy value in the class such as
1348-
| ${s"class MyClass(${name}Tick: () => String) {"}
1349-
| ${s" lazy val $name = ${name}Tick"}
1345+
hl"""${"var"} and ${"val"} parameters of classes and traits may no be call-by-name. In case you
1346+
|want the parameter to be evaluated on demand, consider making it just a parameter
1347+
|and a ${"def"} in the class such as
1348+
| ${s"class MyClass(${name}Tick: => String) {"}
1349+
| ${s" def $name() = ${name}Tick"}
13501350
| ${"}"}
13511351
|"""
13521352
}

0 commit comments

Comments
 (0)