Skip to content

Commit 7ebf5f9

Browse files
committed
Drop FlagSet#toString
This is in preparation of making Flags an opaque type
1 parent a54d6f0 commit 7ebf5f9

File tree

10 files changed

+14
-12
lines changed

10 files changed

+14
-12
lines changed

compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
260260
val evalue = t.symbol.name.mangledString // value the actual enumeration value.
261261
av.visitEnum(name, edesc, evalue)
262262
} else {
263-
// println(i"not an enum: ${t.symbol} / ${t.symbol.denot.owner} / ${t.symbol.denot.owner.isTerm} / ${t.symbol.denot.owner.flags}")
263+
// println(i"not an enum: ${t.symbol} / ${t.symbol.denot.owner} / ${t.symbol.denot.owner.isTerm} / ${t.symbol.denot.owner.flagsString}")
264264
assert(toDenot(t.symbol).name.is(DefaultGetterName),
265265
s"${toDenot(t.symbol).name.debugString}") // this should be default getter. do not emit.
266266
}

compiler/src/dotty/tools/dotc/core/Flags.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ object Flags {
119119
}
120120

121121
/** The string representation of this flag set */
122-
override def toString: String = flagStrings.mkString(" ")
122+
def flagsString: String = flagStrings.mkString(" ")
123123
}
124124

125125
def termFlagSet(x: Long) = FlagSet(TERMS | x)
@@ -129,7 +129,7 @@ object Flags {
129129
* `x is fc` tests whether `x` contains all flags in `fc`.
130130
*/
131131
case class FlagConjunction(bits: Long) {
132-
override def toString: String = FlagSet(bits).toString
132+
def flagsString: String = FlagSet(bits).flagsString
133133
def | (fs: FlagSet): FlagConjunction = FlagConjunction((FlagSet(bits) | fs).bits)
134134
}
135135

compiler/src/dotty/tools/dotc/core/SymDenotations.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ object SymDenotations {
152152
*/
153153
private[dotc] final def flagsUNSAFE: FlagSet = myFlags
154154

155+
final def flagsString(implicit ctx: Context): String = flags.flagsString
156+
155157
/** Adapt flag set to this denotation's term or type nature */
156158
private def adaptFlags(flags: FlagSet) = if (isType) flags.toTypeFlags else flags.toTermFlags
157159

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1976,7 +1976,7 @@ object Parsers {
19761976
val name = in.name
19771977
val mod = atSpan(in.skipToken()) { modOfToken(tok, name) }
19781978

1979-
if (mods is mod.flags) syntaxError(RepeatedModifier(mod.flags.toString))
1979+
if (mods is mod.flags) syntaxError(RepeatedModifier(mod.flags.flagsString))
19801980
addMod(mods, mod)
19811981
}
19821982

compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
807807
val rawFlags = if (sym.exists) sym.flags else mods.flags
808808
if (rawFlags.is(Param)) flagMask = flagMask &~ Given
809809
val flags = rawFlags & flagMask
810-
val flagsText = if (flags.isEmpty) "" else keywordStr(flags.toString)
810+
val flagsText = if (flags.isEmpty) "" else keywordStr(flags.flagsString)
811811
val annotations =
812812
if (sym.exists) sym.annotations.filterNot(ann => dropAnnotForModText(ann.symbol)).map(_.tree)
813813
else mods.annotations.filterNot(tree => dropAnnotForModText(tree.symbol))

compiler/src/dotty/tools/dotc/transform/Bridges.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class Bridges(root: ClassSymbol, thisPhase: DenotTransformer)(implicit ctx: Cont
9191
ctx.debuglog(
9292
i"""generating bridge from ${other.showLocated}: ${other.info}
9393
|to ${member.showLocated}: ${member.info} @ ${member.span}
94-
|bridge: ${bridge.showLocated} with flags: ${bridge.flags}""")
94+
|bridge: ${bridge.showLocated} with flags: ${bridge.flagsString}""")
9595

9696
bridgeTarget(bridge) = member
9797
bridgesScope.enter(bridge)

compiler/src/dotty/tools/dotc/transform/TreeChecker.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ class TreeChecker extends Phase with SymTransformer {
392392
assert(vparam.symbol.is(Param),
393393
s"Parameter ${vparam.symbol} of ${sym.fullName} does not have flag `Param` set")
394394
assert(!vparam.symbol.is(AccessFlags),
395-
s"Parameter ${vparam.symbol} of ${sym.fullName} has invalid flag(s): ${vparam.symbol.flags & AccessFlags}")
395+
s"Parameter ${vparam.symbol} of ${sym.fullName} has invalid flag(s): ${(vparam.symbol.flags & AccessFlags).flagsString}")
396396
})
397397

398398
val tpdTree = super.typedDefDef(ddef, sym)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,8 @@ object RefChecks {
261261
sym.is(Module)) // synthetic companion
262262

263263
def overrideAccessError() = {
264-
ctx.log(i"member: ${member.showLocated} ${member.flags}") // DEBUG
265-
ctx.log(i"other: ${other.showLocated} ${other.flags}") // DEBUG
264+
ctx.log(i"member: ${member.showLocated} ${member.flagsString}") // DEBUG
265+
ctx.log(i"other: ${other.showLocated} ${other.flagsString}") // DEBUG
266266
val otherAccess = (other.flags & AccessFlags).toString
267267
overrideError("has weaker access privileges; it should be " +
268268
(if (otherAccess == "") "public" else "at least " + otherAccess))

compiler/test/dotty/tools/dotc/ast/DesugarTests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class DesugarTests extends DottyTest {
1717
sym.is(Synthetic) ||
1818
// or be a constructor:
1919
sym.name == nme.CONSTRUCTOR,
20-
s"found: $sym (${sym.flags})"
20+
s"found: $sym (${sym.flagsString})"
2121
)
2222
}
2323

compiler/test/dotty/tools/dotc/reporting/ErrorMessagesTests.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ class ErrorMessagesTests extends ErrorMessagesTest {
702702
assertMessageCount(1, messages)
703703
val AbstractMemberMayNotHaveModifier(symbol, flags) :: Nil = messages
704704
assertEquals("value s", symbol.show)
705-
assertEquals("final", flags.toString)
705+
assertEquals("final", flags.flagsString)
706706
}
707707

708708
@Test def typesAndTraitsCantBeImplicit =
@@ -1018,7 +1018,7 @@ class ErrorMessagesTests extends ErrorMessagesTest {
10181018
implicit val ctx: Context = ictx
10191019
assertMessageCount(1, messages)
10201020
val ModifiersNotAllowed(flags, sort) :: Nil = messages
1021-
assertEquals(modifierAssertion, flags.toString)
1021+
assertEquals(modifierAssertion, flags.flagsString)
10221022
assertEquals(typeAssertion, sort)
10231023
}
10241024
}

0 commit comments

Comments
 (0)