Skip to content

Commit 5659ec8

Browse files
committed
Make FlagConjunction an alias of FlagSet
Drop .toFlags conversion
1 parent f312023 commit 5659ec8

File tree

15 files changed

+36
-44
lines changed

15 files changed

+36
-44
lines changed

compiler/src/dotty/tools/dotc/ast/Desugar.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ object desugar {
182182

183183
def makeImplicitParameters(tpts: List[Tree], implicitFlag: FlagSet, forPrimaryConstructor: Boolean = false)(implicit ctx: Context): List[ValDef] =
184184
for (tpt <- tpts) yield {
185-
val paramFlags: FlagSet = if (forPrimaryConstructor) PrivateLocalParamAccessor.toFlags else Param
185+
val paramFlags: FlagSet = if (forPrimaryConstructor) PrivateLocalParamAccessor else Param
186186
val epname = EvidenceParamName.fresh()
187187
ValDef(epname, tpt, EmptyTree).withFlags(paramFlags | implicitFlag)
188188
}
@@ -403,7 +403,7 @@ object desugar {
403403
val tparamReferenced = typeParamIsReferenced(
404404
enumClass.typeParams, originalTparams, originalVparamss, parents)
405405
if (originalTparams.isEmpty && (parents.isEmpty || tparamReferenced))
406-
derivedEnumParams.map(tdef => tdef.withFlags(tdef.mods.flags | PrivateLocal.toFlags))
406+
derivedEnumParams.map(tdef => tdef.withFlags(tdef.mods.flags | PrivateLocal))
407407
else originalTparams
408408
}
409409
else originalTparams
@@ -974,7 +974,7 @@ object desugar {
974974
case _ =>
975975
val tmpName = UniqueName.fresh()
976976
val patMods =
977-
mods & Lazy | Synthetic | (if (ctx.owner.isClass) PrivateLocal.toFlags else EmptyFlags)
977+
mods & Lazy | Synthetic | (if (ctx.owner.isClass) PrivateLocal else EmptyFlags)
978978
val firstDef =
979979
ValDef(tmpName, TypeTree(), matchExpr)
980980
.withSpan(pat.span.union(rhs.span)).withMods(patMods)

compiler/src/dotty/tools/dotc/ast/DesugarEnums.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ object DesugarEnums {
286286
val toStringDef = toStringMethLit(name.toString)
287287
val impl1 = cpy.Template(impl)(body = List(ordinalDef, toStringDef) ++ registerCall)
288288
.withAttachment(ExtendsSingletonMirror, ())
289-
val vdef = ValDef(name, TypeTree(), New(impl1)).withMods(mods | EnumValue.toFlags)
289+
val vdef = ValDef(name, TypeTree(), New(impl1)).withMods(mods | EnumValue)
290290
flatTree(scaffolding ::: vdef :: Nil).withSpan(span)
291291
}
292292
}
@@ -302,7 +302,7 @@ object DesugarEnums {
302302
else {
303303
val (tag, scaffolding) = nextOrdinal(CaseKind.Simple)
304304
val creator = Apply(Ident(nme.DOLLAR_NEW), List(Literal(Constant(tag)), Literal(Constant(name.toString))))
305-
val vdef = ValDef(name, enumClassRef, creator).withMods(mods | EnumValue.toFlags)
305+
val vdef = ValDef(name, enumClassRef, creator).withMods(mods | EnumValue)
306306
flatTree(scaffolding ::: vdef :: Nil).withSpan(span)
307307
}
308308
}

compiler/src/dotty/tools/dotc/ast/Trees.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,7 @@ object Trees {
866866
class EmptyValDef[T >: Untyped] extends ValDef[T](
867867
nme.WILDCARD, genericEmptyTree[T], genericEmptyTree[T])(NoSource) with WithoutTypeOrPos[T] {
868868
myTpe = NoType.asInstanceOf[T]
869-
setMods(untpd.Modifiers(PrivateLocal.toFlags))
869+
setMods(untpd.Modifiers(PrivateLocal))
870870
override def isEmpty: Boolean = true
871871
override def withSpan(span: Span) = throw new AssertionError("Cannot change span of EmptyValDef")
872872
}

compiler/src/dotty/tools/dotc/ast/untpd.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
415415
makeConstructor(Nil, Nil)
416416

417417
def makeSelfDef(name: TermName, tpt: Tree)(implicit ctx: Context): ValDef =
418-
ValDef(name, tpt, EmptyTree).withFlags(PrivateLocal.toFlags)
418+
ValDef(name, tpt, EmptyTree).withFlags(PrivateLocal)
419419

420420
def makeTupleOrParens(ts: List[Tree])(implicit ctx: Context): Tree = ts match {
421421
case t :: Nil => Parens(t)
@@ -437,7 +437,7 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
437437
vdef.withMods(mods | Param)
438438
}
439439

440-
def makeSyntheticParameter(n: Int = 1, tpt: Tree = null, flags: FlagSet = SyntheticTermParam.toFlags)(implicit ctx: Context): ValDef =
440+
def makeSyntheticParameter(n: Int = 1, tpt: Tree = null, flags: FlagSet = SyntheticTermParam)(implicit ctx: Context): ValDef =
441441
ValDef(nme.syntheticParamName(n), if (tpt == null) TypeTree() else tpt, EmptyTree)
442442
.withFlags(flags)
443443

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ class Definitions {
325325
Object_finalize, Object_notify, Object_notifyAll, Object_wait, Object_waitL, Object_waitLI)
326326

327327
@threadUnsafe lazy val AnyKindClass: ClassSymbol = {
328-
val cls = ctx.newCompleteClassSymbol(ScalaPackageClass, tpnme.AnyKind, AbstractFinal.toFlags | Permanent, Nil)
328+
val cls = ctx.newCompleteClassSymbol(ScalaPackageClass, tpnme.AnyKind, AbstractFinal | Permanent, Nil)
329329
if (!ctx.settings.YnoKindPolymorphism.value) {
330330
// Enable kind-polymorphism by exposing scala.AnyKind
331331
cls.entered
@@ -348,11 +348,11 @@ class Definitions {
348348
MethodType(List(ThrowableType), NothingType))
349349

350350
@threadUnsafe lazy val NothingClass: ClassSymbol = enterCompleteClassSymbol(
351-
ScalaPackageClass, tpnme.Nothing, AbstractFinal.toFlags, List(AnyClass.typeRef))
351+
ScalaPackageClass, tpnme.Nothing, AbstractFinal, List(AnyClass.typeRef))
352352
def NothingType: TypeRef = NothingClass.typeRef
353353
@threadUnsafe lazy val RuntimeNothingModuleRef: TermRef = ctx.requiredModuleRef("scala.runtime.Nothing")
354354
@threadUnsafe lazy val NullClass: ClassSymbol = enterCompleteClassSymbol(
355-
ScalaPackageClass, tpnme.Null, AbstractFinal.toFlags, List(ObjectClass.typeRef))
355+
ScalaPackageClass, tpnme.Null, AbstractFinal, List(ObjectClass.typeRef))
356356
def NullType: TypeRef = NullClass.typeRef
357357
@threadUnsafe lazy val RuntimeNullModuleRef: TermRef = ctx.requiredModuleRef("scala.runtime.Null")
358358

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1109,7 +1109,7 @@ object Denotations {
11091109
final def filterDisjoint(denots: PreDenotation)(implicit ctx: Context): SingleDenotation =
11101110
if (denots.exists && denots.matches(this)) NoDenotation else this
11111111
def filterWithFlags(required: FlagConjunction, excluded: FlagSet)(implicit ctx: Context): SingleDenotation =
1112-
if (required.toFlags.isEmpty && excluded.isEmpty || compatibleWith(required, excluded)) this else NoDenotation
1112+
if (required.isEmpty && excluded.isEmpty || compatibleWith(required, excluded)) this else NoDenotation
11131113

11141114
type AsSeenFromResult = SingleDenotation
11151115
protected def computeAsSeenFrom(pre: Type)(implicit ctx: Context): SingleDenotation = {

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

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -135,16 +135,8 @@ object Flags {
135135

136136
def termFlagSet(x: Long) = FlagSet(TERMS | x)
137137

138-
/** A class representing flag sets that should be tested
139-
* conjunctively. I.e. for a flag conjunction `fc`,
140-
* `x is fc` tests whether `x` contains all flags in `fc`.
141-
*/
142-
case class FlagConjunction(bits: Long) {
143-
def toFlags = FlagSet(bits)
144-
def flagsString: String = toFlags.flagsString
145-
def | (fs: FlagSet): FlagConjunction = FlagConjunction((toFlags | fs).bits)
146-
}
147-
138+
type FlagConjunction = FlagSet
139+
def FlagConjunction(bits: Long) = FlagSet(bits)
148140
def termFlagConjunction(x: Long) = FlagConjunction(TERMS | x)
149141

150142
private final val TYPESHIFT = 2

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,13 +208,13 @@ object SymDenotations {
208208

209209
/** Has this denotation all of the flags in `fs` set? */
210210
final def isAllOf(fs: FlagConjunction)(implicit ctx: Context): Boolean =
211-
(if (isCurrent(fs.toFlags)) myFlags else flags).isAllOf(fs)
211+
(if (isCurrent(fs)) myFlags else flags).isAllOf(fs)
212212

213213
/** Has this denotation all of the flags in `fs` set, whereas none of the flags
214214
* in `butNot` are set?
215215
*/
216216
final def isAllOf(fs: FlagConjunction, butNot: FlagSet)(implicit ctx: Context): Boolean =
217-
(if (isCurrent(fs.toFlags) && isCurrent(butNot)) myFlags else flags).isAllOf(fs, butNot)
217+
(if (isCurrent(fs) && isCurrent(butNot)) myFlags else flags).isAllOf(fs, butNot)
218218

219219
/** The type info, or, if symbol is not yet completed, the completer */
220220
final def infoOrCompleter: Type = myInfo

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,11 +296,11 @@ trait Symbols { this: Context =>
296296
/** Create a new skolem symbol. This is not the same as SkolemType, even though the
297297
* motivation (create a singleton referencing to a type) is similar.
298298
*/
299-
def newSkolem(tp: Type): TermSymbol = newSymbol(defn.RootClass, nme.SKOLEM, SyntheticArtifact.toFlags | NonMember | Permanent, tp)
299+
def newSkolem(tp: Type): TermSymbol = newSymbol(defn.RootClass, nme.SKOLEM, SyntheticArtifact | NonMember | Permanent, tp)
300300

301301
def newErrorSymbol(owner: Symbol, name: Name, msg: => Message): Symbol = {
302302
val errType = ErrorType(msg)
303-
newSymbol(owner, name, SyntheticArtifact.toFlags,
303+
newSymbol(owner, name, SyntheticArtifact,
304304
if (name.isTypeName) TypeAlias(errType) else errType)
305305
}
306306

compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,8 @@ class ClassfileParser(
185185
if (isEnum) {
186186
instanceScope.toList.map(_.ensureCompleted())
187187
staticScope.toList.map(_.ensureCompleted())
188-
classRoot.setFlag(Flags.JavaEnum.toFlags)
189-
moduleRoot.setFlag(Flags.JavaEnum.toFlags)
188+
classRoot.setFlag(Flags.JavaEnum)
189+
moduleRoot.setFlag(Flags.JavaEnum)
190190
}
191191

192192
result
@@ -276,7 +276,7 @@ class ClassfileParser(
276276
if (!enumClass.exists)
277277
ctx.warning(s"no linked class for java enum $sym in ${sym.owner}. A referencing class file might be missing an InnerClasses entry.")
278278
else {
279-
if (!enumClass.is(Flags.Sealed)) enumClass.setFlag(Flags.AbstractSealed.toFlags)
279+
if (!enumClass.is(Flags.Sealed)) enumClass.setFlag(Flags.AbstractSealed)
280280
enumClass.addAnnotation(Annotation.Child(sym))
281281
}
282282
}
@@ -555,7 +555,7 @@ class ClassfileParser(
555555
if (ctx.debug && ctx.verbose)
556556
println("" + sym + "; signature = " + sig + " type = " + newType)
557557
case tpnme.SyntheticATTR =>
558-
sym.setFlag(Flags.SyntheticArtifact.toFlags)
558+
sym.setFlag(Flags.SyntheticArtifact)
559559
case tpnme.BridgeATTR =>
560560
sym.setFlag(Flags.Bridge)
561561
case tpnme.DeprecatedATTR =>

0 commit comments

Comments
 (0)