Skip to content

Commit b8c9d5a

Browse files
committed
fix: correct highlight interpolation in explain message
Currently the output of `explain` when you are missing a return type in an abstract declaration looks like this: ``` scala> trait Foo: | def foo -- [E019] Syntax Error: -------------------------------------------------------- 2 | def foo | ^ | Missing return type |----------------------------------------------------------------------------- | Explanation (enabled by `-explain`) |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | An abstract declaration must have a return type. For example: | | trait Shape {hl( | def area: Double // abstract declaration returning a Double | )} ----------------------------------------------------------------------------- ``` This fixes the interpolation issue so the return correctly shows: ``` scala> trait Foo: | def foo -- [E019] Syntax Error: -------------------------------------------------------- 2 | def foo | ^ | Missing return type |----------------------------------------------------------------------------- | Explanation (enabled by `-explain`) |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | An abstract declaration must have a return type. For example: | | trait Shape: | def area: Double // abstract declaration returning a Double ----------------------------------------------------------------------------- ``` The `def area: Double` is now also correctly colored.
1 parent 441afc5 commit b8c9d5a

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -589,9 +589,8 @@ import transform.SymUtils._
589589
def explain =
590590
em"""|An abstract declaration must have a return type. For example:
591591
|
592-
|trait Shape {hl(
593-
| def area: Double // abstract declaration returning a ${"Double"}
594-
|)}"""
592+
|trait Shape:
593+
| ${hl("def area: Double")} // abstract declaration returning a Double"""
595594
}
596595

597596
class MissingReturnTypeWithReturnStatement(method: Symbol)(using Context)

0 commit comments

Comments
 (0)