Skip to content

Commit c88ca78

Browse files
committed
Fix #6795: Print flagString
1 parent ea57e36 commit c88ca78

File tree

6 files changed

+14
-2
lines changed

6 files changed

+14
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1697,7 +1697,7 @@ object messages {
16971697
case class ModifiersNotAllowed(flags: FlagSet, printableType: Option[String])(implicit ctx: Context)
16981698
extends Message(ModifiersNotAllowedID) {
16991699
val kind: String = "Syntax"
1700-
val msg: String = em"Modifier(s) $flags not allowed for ${printableType.getOrElse("combination")}"
1700+
val msg: String = em"Modifier(s) ${flags.flagsString} not allowed for ${printableType.getOrElse("combination")}"
17011701
val explanation: String = {
17021702
val first = "sealed def y: Int = 1"
17031703
val second = "sealed lazy class z"

compiler/src/dotty/tools/dotc/typer/Namer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ class Namer { typer: Typer =>
284284
case _ => (flags.isTermFlags, flags.toTermFlags, "value")
285285
}
286286
if (!ok)
287-
ctx.error(i"modifier(s) `$flags' incompatible with $kind definition", tree.sourcePos)
287+
ctx.error(i"modifier(s) `${flags.flagsString}' incompatible with $kind definition", tree.sourcePos)
288288
adapted
289289
}
290290

tests/neg/i6795-b.check

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-- [E083] Syntax Error: tests/neg/i6795-b.scala:1:11 -------------------------------------------------------------------
2+
1 |sealed def y: Int = 1 // error
3+
| ^
4+
| Modifier(s) sealed not allowed for method
5+
6+
longer explanation available when compiling with `-explain`

tests/neg/i6795-b.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sealed def y: Int = 1 // error

tests/neg/i6795.check

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-- Error: tests/neg/i6795.scala:1:13 -----------------------------------------------------------------------------------
2+
1 |erased class Foo // error
3+
|^^^^^^^^^^^^^^^^
4+
|modifier(s) `erased' incompatible with type definition

tests/neg/i6795.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
erased class Foo // error

0 commit comments

Comments
 (0)