Skip to content

Commit a1157db

Browse files
Merge pull request #15512 from dotty-staging/cleanup-some-flags
Cleanup some uses of Flags combinations
2 parents 4eabca5 + e987cdc commit a1157db

21 files changed

+28
-28
lines changed

compiler/src/dotty/tools/backend/sjs/JSCodeGen.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,7 @@ class JSCodeGen()(using genCtx: Context) {
846846

847847
// Term members that are neither methods nor modules are fields
848848
classSym.info.decls.filter { f =>
849-
!f.isOneOf(Method | Module) && f.isTerm
849+
!f.isOneOf(MethodOrModule) && f.isTerm
850850
&& !f.hasAnnotation(jsdefn.JSNativeAnnot)
851851
&& !f.hasAnnotation(jsdefn.JSOptionalAnnot)
852852
&& !f.hasAnnotation(jsdefn.JSExportStaticAnnot)

compiler/src/dotty/tools/backend/sjs/JSEncoding.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ object JSEncoding {
175175
js.StringLiteral(encodeFieldSymAsString(sym))
176176

177177
private def encodeFieldSymAsString(sym: Symbol)(using Context): String = {
178-
require(sym.owner.isClass && sym.isTerm && !sym.isOneOf(Method | Module),
178+
require(sym.owner.isClass && sym.isTerm && !sym.isOneOf(MethodOrModule),
179179
"encodeFieldSym called with non-field symbol: " + sym)
180180

181181
val name0 = sym.javaSimpleName

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
502502
else if (sym.is(Module))
503503
if (sym.moduleClass.isNoInitsRealClass) PurePath else IdempotentPath
504504
else if (sym.is(Lazy)) IdempotentPath
505-
else if sym.isAllOf(Inline | Param) then Impure
505+
else if sym.isAllOf(InlineParam) then Impure
506506
else PurePath
507507
}
508508

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,8 @@ class Definitions {
288288
@tu lazy val Any_## : TermSymbol = enterMethod(AnyClass, nme.HASHHASH, ExprType(IntType), Final)
289289
@tu lazy val Any_isInstanceOf: TermSymbol = enterT1ParameterlessMethod(AnyClass, nme.isInstanceOf_, _ => BooleanType, Final)
290290
@tu lazy val Any_asInstanceOf: TermSymbol = enterT1ParameterlessMethod(AnyClass, nme.asInstanceOf_, _.paramRefs(0), Final)
291-
@tu lazy val Any_typeTest: TermSymbol = enterT1ParameterlessMethod(AnyClass, nme.isInstanceOfPM, _ => BooleanType, Final | Synthetic | Artifact)
292-
@tu lazy val Any_typeCast: TermSymbol = enterT1ParameterlessMethod(AnyClass, nme.asInstanceOfPM, _.paramRefs(0), Final | Synthetic | Artifact | StableRealizable)
291+
@tu lazy val Any_typeTest: TermSymbol = enterT1ParameterlessMethod(AnyClass, nme.isInstanceOfPM, _ => BooleanType, Final | SyntheticArtifact)
292+
@tu lazy val Any_typeCast: TermSymbol = enterT1ParameterlessMethod(AnyClass, nme.asInstanceOfPM, _.paramRefs(0), Final | SyntheticArtifact | StableRealizable)
293293
// generated by pattern matcher and explicit nulls, eliminated by erasure
294294

295295
/** def getClass[A >: this.type](): Class[? <: A] */

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2873,7 +2873,7 @@ object Parsers {
28732873
if (mods.is(Private) && mods.hasPrivateWithin)
28742874
normalize(mods &~ Private)
28752875
else if (mods.isAllOf(AbstractOverride))
2876-
normalize(addFlag(mods &~ (Abstract | Override), AbsOverride))
2876+
normalize(addFlag(mods &~ AbstractOverride, AbsOverride))
28772877
else
28782878
mods
28792879

@@ -3034,7 +3034,7 @@ object Parsers {
30343034
val tps = commaSeparated(funArgType)
30353035
var counter = nparams
30363036
def nextIdx = { counter += 1; counter }
3037-
val paramFlags = if ofClass then Private | Local | ParamAccessor else Param
3037+
val paramFlags = if ofClass then LocalParamAccessor else Param
30383038
tps.map(makeSyntheticParameter(nextIdx, _, paramFlags | Synthetic | impliedMods.flags))
30393039

30403040
/** ClsParamClause ::= ‘(’ [‘erased’] ClsParams ‘)’ | UsingClsParamClause

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ class ExpandSAMs extends MiniPhase:
137137
def translateMatch(tree: Match, pfParam: Symbol, cases: List[CaseDef], defaultValue: Tree)(using Context) = {
138138
val selector = tree.selector
139139
val selectorTpe = selector.tpe.widen
140-
val defaultSym = newSymbol(pfParam.owner, nme.WILDCARD, Synthetic | Case, selectorTpe)
140+
val defaultSym = newSymbol(pfParam.owner, nme.WILDCARD, SyntheticCase, selectorTpe)
141141
val defaultCase =
142142
CaseDef(
143143
Bind(defaultSym, Underscore(selectorTpe)),

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,14 +185,14 @@ object ExplicitOuter {
185185

186186
/** A new param accessor for the outer field in class `cls` */
187187
private def newOuterParamAccessor(cls: ClassSymbol)(using Context) =
188-
newOuterSym(cls, cls, nme.OUTER, Private | Local | ParamAccessor)
188+
newOuterSym(cls, cls, nme.OUTER, LocalParamAccessor)
189189

190190
/** A new outer accessor for class `cls` which is a member of `owner` */
191191
private def newOuterAccessor(owner: ClassSymbol, cls: ClassSymbol)(using Context) = {
192192
val deferredIfTrait = if (owner.is(Trait)) Deferred else EmptyFlags
193193
val outerAccIfOwn = if (owner == cls) OuterAccessor else EmptyFlags
194194
newOuterSym(owner, cls, outerAccName(cls),
195-
Final | Method | StableRealizable | outerAccIfOwn | deferredIfTrait)
195+
Final | StableMethod | outerAccIfOwn | deferredIfTrait)
196196
}
197197

198198
private def outerAccName(cls: ClassSymbol)(using Context): TermName =

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ class InstrumentCoverage extends MacroTransform with IdentityDenotTransformer:
282282

283283
def isContextual(fun: Apply): Boolean =
284284
val args = fun.args
285-
args.nonEmpty && args.head.symbol.isAllOf(Given | Implicit)
285+
args.nonEmpty && args.head.symbol.isAllOf(GivenOrImplicit)
286286

287287
val fun = tree.fun
288288
val nestedApplyNeedsLift = fun match

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ object LambdaLift:
7070
private def generateProxies()(using Context): Unit =
7171
for owner <- deps.tracked do
7272
val fvs = deps.freeVars(owner).toList
73-
val newFlags = Synthetic | (if (owner.isClass) ParamAccessor | Private else Param)
73+
val newFlags = Synthetic | (if (owner.isClass) PrivateParamAccessor else Param)
7474
report.debuglog(i"free var proxy of ${owner.showLocated}: $fvs%, %")
7575
val freeProxyPairs =
7676
for fv <- fvs yield

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ class LazyVals extends MiniPhase with IdentityDenotTransformer {
345345
}
346346

347347
val retryCase = {
348-
val caseSymbol = newSymbol(methodSymbol, nme.DEFAULT_EXCEPTION_NAME, Synthetic | Case, defn.ThrowableType)
348+
val caseSymbol = newSymbol(methodSymbol, nme.DEFAULT_EXCEPTION_NAME, SyntheticCase, defn.ThrowableType)
349349
val triggerRetry = setFlagState.appliedTo(thiz, offset, initState, fieldId)
350350
CaseDef(
351351
Bind(caseSymbol, ref(caseSymbol)),

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class ParamForwarding extends MiniPhase with IdentityDenotTransformer:
6060
if alias.exists then
6161
sym.copySymDenotation(
6262
name = ParamAccessorName(sym.name),
63-
initFlags = sym.flags | Method | StableRealizable,
63+
initFlags = sym.flags | StableMethod,
6464
info = sym.info.ensureMethodic
6565
).installAfter(thisPhase)
6666
val superAcc =

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ object PatternMatcher {
9999
private val initializer = MutableSymbolMap[Tree]()
100100

101101
private def newVar(rhs: Tree, flags: FlagSet, tpe: Type): TermSymbol =
102-
newSymbol(ctx.owner, PatMatStdBinderName.fresh(), Synthetic | Case | flags,
102+
newSymbol(ctx.owner, PatMatStdBinderName.fresh(), SyntheticCase | flags,
103103
sanitize(tpe), coord = rhs.span)
104104
// TODO: Drop Case once we use everywhere else `isPatmatGenerated`.
105105

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ object SymUtils:
128128
isCodefined(mt.resultType)
129129
case res =>
130130
self.isCoDefinedGiven(res.typeSymbol)
131-
self.isAllOf(Given | Method) && isCodefined(self.info)
131+
self.isAllOf(GivenMethod) && isCodefined(self.info)
132132

133133
// TODO Scala 3.x: only check for inline vals (no final ones)
134134
def isInlineVal(using Context) =

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ class SyntheticMembers(thisPhase: DenotTransformer) {
257257
*
258258
*/
259259
def equalsBody(that: Tree)(using Context): Tree = {
260-
val thatAsClazz = newSymbol(ctx.owner, nme.x_0, Synthetic | Case, clazzType, coord = ctx.owner.span) // x$0
260+
val thatAsClazz = newSymbol(ctx.owner, nme.x_0, SyntheticCase, clazzType, coord = ctx.owner.span) // x$0
261261
def wildcardAscription(tp: Type) = Typed(Underscore(tp), TypeTree(tp))
262262
val pattern = Bind(thatAsClazz, wildcardAscription(AnnotatedType(clazzType, Annotation(defn.UncheckedAnnot)))) // x$0 @ (_: C @unchecked)
263263
// compare primitive fields first, slow equality checks of non-primitive fields can be skipped when primitives differ
@@ -405,11 +405,11 @@ class SyntheticMembers(thisPhase: DenotTransformer) {
405405
.exists
406406

407407
private def writeReplaceDef(clazz: ClassSymbol)(using Context): TermSymbol =
408-
newSymbol(clazz, nme.writeReplace, Method | Private | Synthetic,
408+
newSymbol(clazz, nme.writeReplace, PrivateMethod | Synthetic,
409409
MethodType(Nil, defn.AnyRefType), coord = clazz.coord).entered.asTerm
410410

411411
private def readResolveDef(clazz: ClassSymbol)(using Context): TermSymbol =
412-
newSymbol(clazz, nme.readResolve, Method | Private | Synthetic,
412+
newSymbol(clazz, nme.readResolve, PrivateMethod | Synthetic,
413413
MethodType(Nil, defn.AnyRefType), coord = clazz.coord).entered.asTerm
414414

415415
/** If this is a static object `Foo`, add the method:

compiler/src/dotty/tools/dotc/transform/sjs/ExplicitJSClasses.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ class ExplicitJSClasses extends MiniPhase with InfoTransformer { thisPhase =>
364364
}
365365

366366
val fieldName = jsclassFieldName(innerJSClass.name.asTypeName)
367-
val fieldFlags = Synthetic | Artifact
367+
val fieldFlags = SyntheticArtifact
368368
val field = newSymbol(cls, fieldName, fieldFlags, defn.AnyRefType, coord = innerJSClass.coord)
369369
addAnnotsIfInJSClass(field)
370370
decls1.enter(field)
@@ -376,7 +376,7 @@ class ExplicitJSClasses extends MiniPhase with InfoTransformer { thisPhase =>
376376
i"trying to ad-hoc expose objects in non-JS static object ${cls.fullName}")
377377

378378
val getterName = jsobjectGetterNameFor(innerObject)
379-
val getterFlags = Method | Synthetic | Artifact
379+
val getterFlags = Method | SyntheticArtifact
380380
val getter = newSymbol(cls, getterName, getterFlags, ExprType(defn.AnyRefType), coord = innerObject.coord)
381381
addAnnots(getter, innerObject)
382382
decls1.enter(getter)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ trait Deriving {
4949
// If we set the Synthetic flag here widenGiven will widen too far and the
5050
// derived instance will have too low a priority to be selected over a freshly
5151
// derived instance at the summoning site.
52-
val flags = if info.isInstanceOf[MethodOrPoly] then Given | Method else Given | Lazy
52+
val flags = if info.isInstanceOf[MethodOrPoly] then GivenMethod else Given | Lazy
5353
synthetics +=
5454
newSymbol(ctx.owner, instanceName, flags, info, coord = pos.span)
5555
.entered

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ object EtaExpansion extends LiftImpure {
258258
val paramTypes: List[Tree] =
259259
if (isLastApplication && mt.paramInfos.length == xarity) mt.paramInfos map (_ => TypeTree())
260260
else mt.paramInfos map TypeTree
261-
var paramFlag = Synthetic | Param
261+
var paramFlag = SyntheticParam
262262
if (mt.isContextualMethod) paramFlag |= Given
263263
else if (mt.isImplicitMethod) paramFlag |= Implicit
264264
val params = mt.paramNames.lazyZip(paramTypes).map((name, tpe) =>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ object Inliner {
435435
| Literal(_) =>
436436
true
437437
case Ident(_) =>
438-
isPureRef(tree) || tree.symbol.isAllOf(Inline | Param)
438+
isPureRef(tree) || tree.symbol.isAllOf(InlineParam)
439439
case Select(qual, _) =>
440440
if (tree.symbol.is(Erased)) true
441441
else isPureRef(tree) && apply(qual)
@@ -969,7 +969,7 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(using Context) {
969969
case t: ThisType => thisProxy.getOrElse(t.cls, t)
970970
case t: TypeRef => paramProxy.getOrElse(t, mapOver(t))
971971
case t: SingletonType =>
972-
if t.termSymbol.isAllOf(Inline | Param) then apply(t.widenTermRefExpr)
972+
if t.termSymbol.isAllOf(InlineParam) then apply(t.widenTermRefExpr)
973973
else paramProxy.getOrElse(t, mapOver(t))
974974
case t => mapOver(t)
975975
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,7 @@ class Namer { typer: Typer =>
905905
if denot.isClass && !sym.isEnumAnonymClass && !sym.isRefinementClass then
906906
val child = if (denot.is(Module)) denot.sourceModule else denot.symbol
907907
denot.info.parents.foreach { parent => register(child, parent.classSymbol.asClass) }
908-
else if denot.is(CaseVal, butNot = Method | Module) then
908+
else if denot.is(CaseVal, butNot = MethodOrModule) then
909909
assert(denot.is(Enum), denot)
910910
denot.info.classSymbols.foreach { parent => register(denot.symbol, parent) }
911911
end if

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ object Nullables:
267267
@tailrec def recur(s: Symbol): Boolean =
268268
s != NoSymbol
269269
&& s != refOwner
270-
&& (s.isOneOf(Lazy | Method) // not at the rhs of lazy ValDef or in a method (or lambda)
270+
&& (s.isOneOf(MethodOrLazy) // not at the rhs of lazy ValDef or in a method (or lambda)
271271
|| s.isClass // not in a class
272272
|| recur(s.owner))
273273

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ object RefChecks {
490490
"(this rule is designed to prevent ``accidental overrides'')")
491491
else if (other.isStableMember && !member.isStableMember) // (1.5)
492492
overrideError("needs to be a stable, immutable value")
493-
else if (member.is(ModuleVal) && !other.isRealMethod && !other.isOneOf(Deferred | Lazy))
493+
else if (member.is(ModuleVal) && !other.isRealMethod && !other.isOneOf(DeferredOrLazy))
494494
overrideError("may not override a concrete non-lazy value")
495495
else if (member.is(Lazy, butNot = Module) && !other.isRealMethod && !other.is(Lazy) &&
496496
!warnOnMigration(overrideErrorMsg("may not override a non-lazy value"), member.srcPos, version = `3.0`))

0 commit comments

Comments
 (0)