diff options
Diffstat (limited to 'src/dotty/tools/dotc/reporting/diagnostic/messages.scala')
-rw-r--r-- | src/dotty/tools/dotc/reporting/diagnostic/messages.scala | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/dotty/tools/dotc/reporting/diagnostic/messages.scala b/src/dotty/tools/dotc/reporting/diagnostic/messages.scala index b0ce5b132..f76512bc7 100644 --- a/src/dotty/tools/dotc/reporting/diagnostic/messages.scala +++ b/src/dotty/tools/dotc/reporting/diagnostic/messages.scala @@ -581,4 +581,28 @@ object messages { } } + + case class ByNameParameterNotSupported()(implicit ctx: Context) extends Message(21) { + val kind = "Syntax" + + val msg = "By-name parameter type not allowed here." + + val explanation = + hl"""|By-name parameters act like functions that are only evaluated when referenced, + |allowing for lazy evaluation of a parameter. + | + |An example of using a by-name parameter would look like: + |${"def func(f: => Boolean) = f // 'f' is evaluated when referenced within the function"} + | + |An example of the syntax of passing an actual function as a parameter: + |${"def func(f: (Boolean => Boolean)) = f(true)"} + | + |or: + | + |${"def func(f: Boolean => Boolean) = f(true)"} + | + |And the usage could be as such: + |${"func(bool => // do something...)"} + |""".stripMargin + } } |