diff --git a/compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala b/compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala index 811a8aebfbf1..9b4b626655fe 100644 --- a/compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala +++ b/compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala @@ -464,9 +464,9 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas def isModuleClassRoot = nameMatches(moduleClassRoot.name) && (owner == moduleClassRoot.owner) && flags.is(Module) def isModuleRoot = nameMatches(moduleClassRoot.name.sourceModuleName) && (owner == moduleClassRoot.owner) && flags.is(Module) - //if (isClassRoot) println(s"classRoot of $classRoot found at $readIndex, flags = $flags") // !!! DEBUG - //if (isModuleRoot) println(s"moduleRoot of $moduleRoot found at $readIndex, flags = $flags") // !!! DEBUG - //if (isModuleClassRoot) println(s"moduleClassRoot of $moduleClassRoot found at $readIndex, flags = $flags") // !!! DEBUG + //if (isClassRoot) println(s"classRoot of $classRoot found at $readIndex, flags = ${flags.flagsString}") // !!! DEBUG + //if (isModuleRoot) println(s"moduleRoot of $moduleRoot found at $readIndex, flags = ${flags.flagsString}") // !!! DEBUG + //if (isModuleClassRoot) println(s"moduleClassRoot of $moduleClassRoot found at $readIndex, flags = ${flags.flagsString}") // !!! DEBUG def completeRoot(denot: ClassDenotation, completer: LazyType): Symbol = { denot.setFlag(flags) diff --git a/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala b/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala index 675365864c98..7ce38fceb63a 100644 --- a/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala +++ b/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala @@ -1504,7 +1504,7 @@ object messages { case class AbstractMemberMayNotHaveModifier(sym: Symbol, flag: FlagSet)( implicit ctx: Context) extends Message(AbstractMemberMayNotHaveModifierID) { - val msg: String = em"""${hl("abstract")} $sym may not have `$flag' modifier""" + val msg: String = em"""${hl("abstract")} $sym may not have `${flag.flagsString}` modifier""" val kind: String = "Syntax" val explanation: String = "" } @@ -1697,7 +1697,7 @@ object messages { case class ModifiersNotAllowed(flags: FlagSet, printableType: Option[String])(implicit ctx: Context) extends Message(ModifiersNotAllowedID) { val kind: String = "Syntax" - val msg: String = em"Modifier(s) $flags not allowed for ${printableType.getOrElse("combination")}" + val msg: String = em"Modifier(s) `${flags.flagsString}` not allowed for ${printableType.getOrElse("combination")}" val explanation: String = { val first = "sealed def y: Int = 1" val second = "sealed lazy class z" diff --git a/compiler/src/dotty/tools/dotc/typer/Checking.scala b/compiler/src/dotty/tools/dotc/typer/Checking.scala index 334167b95b5f..8bb262a98494 100644 --- a/compiler/src/dotty/tools/dotc/typer/Checking.scala +++ b/compiler/src/dotty/tools/dotc/typer/Checking.scala @@ -394,10 +394,10 @@ object Checking { def checkNoConflict(flag1: FlagSet, flag2: FlagSet, msg: => String) = if (sym.isAllOf(flag1 | flag2)) fail(msg) def checkCombination(flag1: FlagSet, flag2: FlagSet) = - checkNoConflict(flag1, flag2, i"illegal combination of modifiers: `$flag1` and `$flag2` for: $sym") + checkNoConflict(flag1, flag2, i"illegal combination of modifiers: `${flag1.flagsString}` and `${flag2.flagsString}` for: $sym") def checkApplicable(flag: FlagSet, ok: Boolean) = if (!ok && !sym.is(Synthetic)) - fail(i"modifier `$flag` is not allowed for this definition") + fail(i"modifier `${flag.flagsString}` is not allowed for this definition") if (sym.is(Inline) && ( sym.is(ParamAccessor) && sym.owner.isClass diff --git a/compiler/src/dotty/tools/dotc/typer/Namer.scala b/compiler/src/dotty/tools/dotc/typer/Namer.scala index 0a4cd734479c..9a1f89ca7650 100644 --- a/compiler/src/dotty/tools/dotc/typer/Namer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Namer.scala @@ -284,7 +284,7 @@ class Namer { typer: Typer => case _ => (flags.isTermFlags, flags.toTermFlags, "value") } if (!ok) - ctx.error(i"modifier(s) `$flags' incompatible with $kind definition", tree.sourcePos) + ctx.error(i"modifier(s) `${flags.flagsString}` incompatible with $kind definition", tree.sourcePos) adapted } diff --git a/tests/neg/i6795-b.check b/tests/neg/i6795-b.check new file mode 100644 index 000000000000..69fa72fe840e --- /dev/null +++ b/tests/neg/i6795-b.check @@ -0,0 +1,6 @@ +-- [E083] Syntax Error: tests/neg/i6795-b.scala:1:11 ------------------------------------------------------------------- +1 |sealed def y: Int = 1 // error + | ^ + | Modifier(s) `sealed` not allowed for method + +longer explanation available when compiling with `-explain` diff --git a/tests/neg/i6795-b.scala b/tests/neg/i6795-b.scala new file mode 100644 index 000000000000..452df61a2ead --- /dev/null +++ b/tests/neg/i6795-b.scala @@ -0,0 +1 @@ +sealed def y: Int = 1 // error diff --git a/tests/neg/i6795.check b/tests/neg/i6795.check new file mode 100644 index 000000000000..bd16593edbc6 --- /dev/null +++ b/tests/neg/i6795.check @@ -0,0 +1,4 @@ +-- Error: tests/neg/i6795.scala:1:13 ----------------------------------------------------------------------------------- +1 |erased class Foo // error + |^^^^^^^^^^^^^^^^ + |modifier(s) `erased` incompatible with type definition diff --git a/tests/neg/i6795.scala b/tests/neg/i6795.scala new file mode 100644 index 000000000000..5bddc6d326b8 --- /dev/null +++ b/tests/neg/i6795.scala @@ -0,0 +1 @@ +erased class Foo // error