Skip to content

Commit 355bcc0

Browse files
Merge pull request #6797 from dotty-staging/fix-#6795
Fix #6795: Print flagString
2 parents e0962b3 + 18a49e8 commit 355bcc0

File tree

8 files changed

+20
-8
lines changed

8 files changed

+20
-8
lines changed

compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -464,9 +464,9 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
464464
def isModuleClassRoot = nameMatches(moduleClassRoot.name) && (owner == moduleClassRoot.owner) && flags.is(Module)
465465
def isModuleRoot = nameMatches(moduleClassRoot.name.sourceModuleName) && (owner == moduleClassRoot.owner) && flags.is(Module)
466466

467-
//if (isClassRoot) println(s"classRoot of $classRoot found at $readIndex, flags = $flags") // !!! DEBUG
468-
//if (isModuleRoot) println(s"moduleRoot of $moduleRoot found at $readIndex, flags = $flags") // !!! DEBUG
469-
//if (isModuleClassRoot) println(s"moduleClassRoot of $moduleClassRoot found at $readIndex, flags = $flags") // !!! DEBUG
467+
//if (isClassRoot) println(s"classRoot of $classRoot found at $readIndex, flags = ${flags.flagsString}") // !!! DEBUG
468+
//if (isModuleRoot) println(s"moduleRoot of $moduleRoot found at $readIndex, flags = ${flags.flagsString}") // !!! DEBUG
469+
//if (isModuleClassRoot) println(s"moduleClassRoot of $moduleClassRoot found at $readIndex, flags = ${flags.flagsString}") // !!! DEBUG
470470

471471
def completeRoot(denot: ClassDenotation, completer: LazyType): Symbol = {
472472
denot.setFlag(flags)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1504,7 +1504,7 @@ object messages {
15041504
case class AbstractMemberMayNotHaveModifier(sym: Symbol, flag: FlagSet)(
15051505
implicit ctx: Context)
15061506
extends Message(AbstractMemberMayNotHaveModifierID) {
1507-
val msg: String = em"""${hl("abstract")} $sym may not have `$flag' modifier"""
1507+
val msg: String = em"""${hl("abstract")} $sym may not have `${flag.flagsString}` modifier"""
15081508
val kind: String = "Syntax"
15091509
val explanation: String = ""
15101510
}
@@ -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/Checking.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,10 +394,10 @@ object Checking {
394394
def checkNoConflict(flag1: FlagSet, flag2: FlagSet, msg: => String) =
395395
if (sym.isAllOf(flag1 | flag2)) fail(msg)
396396
def checkCombination(flag1: FlagSet, flag2: FlagSet) =
397-
checkNoConflict(flag1, flag2, i"illegal combination of modifiers: `$flag1` and `$flag2` for: $sym")
397+
checkNoConflict(flag1, flag2, i"illegal combination of modifiers: `${flag1.flagsString}` and `${flag2.flagsString}` for: $sym")
398398
def checkApplicable(flag: FlagSet, ok: Boolean) =
399399
if (!ok && !sym.is(Synthetic))
400-
fail(i"modifier `$flag` is not allowed for this definition")
400+
fail(i"modifier `${flag.flagsString}` is not allowed for this definition")
401401

402402
if (sym.is(Inline) &&
403403
( sym.is(ParamAccessor) && sym.owner.isClass

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)