Skip to content

Commit 1994d6c

Browse files
committed
Drop FlagConjunction
1 parent 57382d5 commit 1994d6c

File tree

12 files changed

+66
-76
lines changed

12 files changed

+66
-76
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package dotty.tools.backend.jvm
33
import dotty.tools.dotc.ast.tpd
44
import dotty.tools.dotc.ast.Trees
55
import dotty.tools.dotc
6-
import dotty.tools.dotc.core.Flags.{termFlagSet, termFlagConjunction}
6+
import dotty.tools.dotc.core.Flags.{termFlagSet}
77
import dotty.tools.dotc.transform.{Erasure, GenericSignatures}
88
import dotty.tools.dotc.transform.SymUtils._
99
import java.io.{File => _}
@@ -881,7 +881,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
881881
def =:=(other: Type): Boolean = tp =:= other
882882

883883
def membersBasedOnFlags(excludedFlags: Flags, requiredFlags: Flags): List[Symbol] =
884-
tp.membersBasedOnFlags(termFlagConjunction(requiredFlags), termFlagSet(excludedFlags)).map(_.symbol).toList
884+
tp.membersBasedOnFlags(termFlagSet(requiredFlags), termFlagSet(excludedFlags)).map(_.symbol).toList
885885

886886
def resultType: Type = tp.resultType
887887

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
187187
def is(fs: FlagSet, butNot: FlagSet): Boolean = flags.is(fs, butNot = butNot)
188188
def isOneOf(fs: FlagSet): Boolean = flags.isOneOf(fs)
189189
def isOneOf(fs: FlagSet, butNot: FlagSet): Boolean = flags.isOneOf(fs, butNot = butNot)
190-
def isAllOf(fc: FlagConjunction): Boolean = flags.isAllOf(fc)
190+
def isAllOf(fc: FlagSet): Boolean = flags.isAllOf(fc)
191191

192192
def | (fs: FlagSet): Modifiers = withFlags(flags | fs)
193193
def & (fs: FlagSet): Modifiers = withFlags(flags & fs)

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ object Denotations {
113113
/** Keep only those denotations in this group that have all of the flags in `required`,
114114
* but none of the flags in `excluded`.
115115
*/
116-
def filterWithFlags(required: FlagConjunction, excluded: FlagSet)(implicit ctx: Context): PreDenotation
116+
def filterWithFlags(required: FlagSet, excluded: FlagSet)(implicit ctx: Context): PreDenotation
117117

118118
private[this] var cachedPrefix: Type = _
119119
private[this] var cachedAsSeenFrom: AsSeenFromResult = _
@@ -260,7 +260,7 @@ object Denotations {
260260
* flags and no `excluded` flag, and produce a denotation that contains the type of the member
261261
* as seen from given prefix `pre`.
262262
*/
263-
def findMember(name: Name, pre: Type, required: FlagConjunction, excluded: FlagSet)(implicit ctx: Context): Denotation =
263+
def findMember(name: Name, pre: Type, required: FlagSet, excluded: FlagSet)(implicit ctx: Context): Denotation =
264264
info.findMember(name, pre, required, excluded)
265265

266266
/** If this denotation is overloaded, filter with given predicate.
@@ -1108,7 +1108,7 @@ object Denotations {
11081108
if (p(this)) this else NoDenotation
11091109
final def filterDisjoint(denots: PreDenotation)(implicit ctx: Context): SingleDenotation =
11101110
if (denots.exists && denots.matches(this)) NoDenotation else this
1111-
def filterWithFlags(required: FlagConjunction, excluded: FlagSet)(implicit ctx: Context): SingleDenotation =
1111+
def filterWithFlags(required: FlagSet, excluded: FlagSet)(implicit ctx: Context): SingleDenotation =
11121112
if (required.isEmpty && excluded.isEmpty || compatibleWith(required, excluded)) this else NoDenotation
11131113

11141114
type AsSeenFromResult = SingleDenotation
@@ -1124,7 +1124,7 @@ object Denotations {
11241124

11251125
/** Does this denotation have all the `required` flags but none of the `excluded` flags?
11261126
*/
1127-
private def compatibleWith(required: FlagConjunction, excluded: FlagSet)(implicit ctx: Context): Boolean = {
1127+
private def compatibleWith(required: FlagSet, excluded: FlagSet)(implicit ctx: Context): Boolean = {
11281128
val symd: SymDenotation = this match {
11291129
case symd: SymDenotation => symd
11301130
case _ => symbol.denot
@@ -1214,7 +1214,7 @@ object Denotations {
12141214
derivedUnion(denot1 filterWithPredicate p, denot2 filterWithPredicate p)
12151215
def filterDisjoint(denot: PreDenotation)(implicit ctx: Context): PreDenotation =
12161216
derivedUnion(denot1 filterDisjoint denot, denot2 filterDisjoint denot)
1217-
def filterWithFlags(required: FlagConjunction, excluded: FlagSet)(implicit ctx: Context): PreDenotation =
1217+
def filterWithFlags(required: FlagSet, excluded: FlagSet)(implicit ctx: Context): PreDenotation =
12181218
derivedUnion(denot1.filterWithFlags(required, excluded), denot2.filterWithFlags(required, excluded))
12191219
protected def derivedUnion(denot1: PreDenotation, denot2: PreDenotation) =
12201220
if ((denot1 eq this.denot1) && (denot2 eq this.denot2)) this

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

Lines changed: 39 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,6 @@ object Flags {
135135

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

138-
type FlagConjunction = FlagSet
139-
def FlagConjunction(bits: Long) = FlagSet(bits)
140-
def termFlagConjunction(x: Long) = FlagConjunction(TERMS | x)
141-
142138
private final val TYPESHIFT = 2
143139
private final val TERMindex = 0
144140
private final val TYPEindex = 1
@@ -196,8 +192,6 @@ object Flags {
196192
/** The empty flag set */
197193
final val EmptyFlags: FlagSet = FlagSet(0)
198194

199-
final val EmptyFlagConjunction = FlagConjunction(0)
200-
201195
/** The undefined flag set */
202196
final val UndefinedFlags: FlagSet = FlagSet(~KINDFLAGS)
203197

@@ -589,28 +583,28 @@ object Flags {
589583
final val EffectivelyFinalFlags: FlagSet = Private | Final
590584

591585
/** A private method */
592-
final val PrivateMethod: FlagConjunction = Private | Method
586+
final val PrivateMethod: FlagSet = Private | Method
593587

594588
/** A private accessor */
595-
final val PrivateAccessor: FlagConjunction = Private | Accessor
589+
final val PrivateAccessor: FlagSet = Private | Accessor
596590

597591
/** An inline method */
598-
final val InlineMethod: FlagConjunction = Inline | Method
592+
final val InlineMethod: FlagSet = Inline | Method
599593

600594
/** An inline by-name parameter proxy */
601-
final val InlineByNameProxy: FlagConjunction = InlineProxy | Method
595+
final val InlineByNameProxy: FlagSet = InlineProxy | Method
602596

603597
/** An inline parameter */
604-
final val InlineParam: FlagConjunction = Inline | Param
598+
final val InlineParam: FlagSet = Inline | Param
605599

606600
/** An extension method */
607601
final val ExtensionMethod = Extension | Method
608602

609603
/** An implied method */
610-
final val SyntheticImpliedMethod: FlagConjunction = Synthetic | Implied | Method
604+
final val SyntheticImpliedMethod: FlagSet = Synthetic | Implied | Method
611605

612606
/** An enum case */
613-
final val EnumCase: FlagConjunction = Enum | Case
607+
final val EnumCase: FlagSet = Enum | Case
614608

615609
/** A term parameter or parameter accessor */
616610
final val TermParamOrAccessor: FlagSet = Param | ParamAccessor
@@ -637,10 +631,10 @@ object Flags {
637631
final val FinalOrSealed: FlagSet = Final | Sealed
638632

639633
/** A covariant type parameter instance */
640-
final val LocalCovariant: FlagConjunction = Local | Covariant
634+
final val LocalCovariant: FlagSet = Local | Covariant
641635

642636
/** A contravariant type parameter instance */
643-
final val LocalContravariant: FlagConjunction = Local | Contravariant
637+
final val LocalContravariant: FlagSet = Local | Contravariant
644638

645639
/** Has defined or inherited default parameters */
646640
final val HasDefaultParamsFlags: FlagSet = DefaultParameterized | InheritedDefaultParams
@@ -649,74 +643,74 @@ object Flags {
649643
final val ValidForeverFlags: FlagSet = Package | Permanent | Scala2ExistentialCommon
650644

651645
/** A type parameter of a class or trait */
652-
final val ClassTypeParam: FlagConjunction = TypeParam | Private
646+
final val ClassTypeParam: FlagSet = TypeParam | Private
653647

654648
/** Is a default parameter in Scala 2*/
655-
final val DefaultParameter: FlagConjunction = Param | DefaultParameterized
649+
final val DefaultParameter: FlagSet = Param | DefaultParameterized
656650

657651
/** A trait that does not need to be initialized */
658-
final val NoInitsTrait: FlagConjunction = Trait | NoInits
652+
final val NoInitsTrait: FlagSet = Trait | NoInits
659653

660654
/** A Java interface, potentially with default methods */
661-
final val JavaTrait: FlagConjunction = JavaDefined | Trait | NoInits
655+
final val JavaTrait: FlagSet = JavaDefined | Trait | NoInits
662656

663657
/** A Java interface */ // TODO when unpickling, reconstitute from context
664-
final val JavaInterface: FlagConjunction = JavaDefined | Trait
658+
final val JavaInterface: FlagSet = JavaDefined | Trait
665659

666660
/** A Java companion object */
667-
final val JavaModule: FlagConjunction = JavaDefined | Module
661+
final val JavaModule: FlagSet = JavaDefined | Module
668662

669663
/** A Java companion object */
670-
final val JavaProtected: FlagConjunction = JavaDefined | Protected
664+
final val JavaProtected: FlagSet = JavaDefined | Protected
671665

672666
/** A Java enum */
673-
final val JavaEnum: FlagConjunction = JavaDefined | Enum
667+
final val JavaEnum: FlagSet = JavaDefined | Enum
674668

675669
/** A Java enum trait */
676-
final val JavaEnumTrait: FlagConjunction = JavaDefined | Enum
670+
final val JavaEnumTrait: FlagSet = JavaDefined | Enum
677671

678672
/** A Java enum value */
679-
final val JavaEnumValue: FlagConjunction = StableRealizable | JavaStatic | JavaDefined | Enum
673+
final val JavaEnumValue: FlagSet = StableRealizable | JavaStatic | JavaDefined | Enum
680674

681675
/** An enum value */
682-
final val EnumValue: FlagConjunction = (StableRealizable | JavaStatic | Enum)
676+
final val EnumValue: FlagSet = StableRealizable | JavaStatic | Enum
683677

684678
/** Labeled private[this] */
685-
final val PrivateLocal: FlagConjunction = Private | Local
679+
final val PrivateLocal: FlagSet = Private | Local
686680

687681
/** A private[this] parameter accessor */
688-
final val PrivateLocalParamAccessor: FlagConjunction = Private | Local | ParamAccessor
682+
final val PrivateLocalParamAccessor: FlagSet = Private | Local | ParamAccessor
689683

690684
/** A parameter forwarder */
691-
final val ParamForwarder: FlagConjunction = Method | StableRealizable | ParamAccessor
685+
final val ParamForwarder: FlagSet = Method | StableRealizable | ParamAccessor
692686

693687
/** A private[this] parameter */
694-
final val PrivateLocalParam: FlagConjunction = Private | Local | Param
688+
final val PrivateLocalParam: FlagSet = Private | Local | Param
695689

696690
/** A private parameter accessor */
697-
final val PrivateParamAccessor: FlagConjunction = Private | ParamAccessor
691+
final val PrivateParamAccessor: FlagSet = Private | ParamAccessor
698692

699693
/** A local parameter */
700-
final val ParamAndLocal: FlagConjunction = Param | Local
694+
final val ParamAndLocal: FlagSet = Param | Local
701695

702696
/** Labeled protected[this] */
703-
final val ProtectedLocal: FlagConjunction = Protected | Local
697+
final val ProtectedLocal: FlagSet = Protected | Local
704698

705-
final val LiftedMethod: FlagConjunction = Lifted | Method
699+
final val LiftedMethod: FlagSet = Lifted | Method
706700

707701
/** Java symbol which is `protected` and `static` */
708-
final val StaticProtected: FlagConjunction = JavaDefined | Protected | JavaStatic
702+
final val StaticProtected: FlagSet = JavaDefined | Protected | JavaStatic
709703

710-
final val Scala2Trait: FlagConjunction = Scala2x | Trait
704+
final val Scala2Trait: FlagSet = Scala2x | Trait
711705

712-
final val AbstractFinal: FlagConjunction = Abstract | Final
713-
final val AbstractSealed: FlagConjunction = Abstract | Sealed
714-
final val AbstractAndOverride: FlagConjunction = Abstract | Override
706+
final val AbstractFinal: FlagSet = Abstract | Final
707+
final val AbstractSealed: FlagSet = Abstract | Sealed
708+
final val AbstractAndOverride: FlagSet = Abstract | Override
715709

716-
final val SyntheticArtifact: FlagConjunction = Synthetic | Artifact
717-
final val SyntheticModule: FlagConjunction = Synthetic | Module
718-
final val SyntheticTermParam: FlagConjunction = Synthetic | TermParam
719-
final val SyntheticTypeParam: FlagConjunction = Synthetic | TypeParam
720-
final val SyntheticCase: FlagConjunction = Synthetic | Case
721-
final val SyntheticOpaque: FlagConjunction = Synthetic | Opaque
710+
final val SyntheticArtifact: FlagSet = Synthetic | Artifact
711+
final val SyntheticModule: FlagSet = Synthetic | Module
712+
final val SyntheticTermParam: FlagSet = Synthetic | TermParam
713+
final val SyntheticTypeParam: FlagSet = Synthetic | TypeParam
714+
final val SyntheticCase: FlagSet = Synthetic | Case
715+
final val SyntheticOpaque: FlagSet = Synthetic | Opaque
722716
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,13 +207,13 @@ object SymDenotations {
207207
(if (isCurrent(fs) && isCurrent(butNot)) myFlags else flags).isOneOf(fs, butNot)
208208

209209
/** Has this denotation all of the flags in `fs` set? */
210-
final def isAllOf(fs: FlagConjunction)(implicit ctx: Context): Boolean =
210+
final def isAllOf(fs: FlagSet)(implicit ctx: Context): Boolean =
211211
(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
*/
216-
final def isAllOf(fs: FlagConjunction, butNot: FlagSet)(implicit ctx: Context): Boolean =
216+
final def isAllOf(fs: FlagSet, butNot: FlagSet)(implicit ctx: Context): Boolean =
217217
(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 */
@@ -1758,7 +1758,7 @@ object SymDenotations {
17581758
else collect(ownDenots, classParents)
17591759
}
17601760

1761-
override final def findMember(name: Name, pre: Type, required: FlagConjunction, excluded: FlagSet)(implicit ctx: Context): Denotation = {
1761+
override final def findMember(name: Name, pre: Type, required: FlagSet, excluded: FlagSet)(implicit ctx: Context): Denotation = {
17621762
val raw = if (excluded.is(Private)) nonPrivateMembersNamed(name) else membersNamed(name)
17631763
raw.filterWithFlags(required, excluded).asSeenFrom(pre).toDenot(pre)
17641764
}

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ object Types {
514514
*/
515515
@tailrec final def findDecl(name: Name, excluded: FlagSet)(implicit ctx: Context): Denotation = this match {
516516
case tp: ClassInfo =>
517-
tp.decls.denotsNamed(name).filterWithFlags(EmptyFlagConjunction, excluded).toDenot(NoPrefix)
517+
tp.decls.denotsNamed(name).filterWithFlags(EmptyFlags, excluded).toDenot(NoPrefix)
518518
case tp: TypeProxy =>
519519
tp.underlying.findDecl(name, excluded)
520520
case err: ErrorType =>
@@ -525,16 +525,16 @@ object Types {
525525

526526
/** The member of this type with the given name */
527527
final def member(name: Name)(implicit ctx: Context): Denotation = /*>|>*/ track("member") /*<|<*/ {
528-
memberBasedOnFlags(name, required = EmptyFlagConjunction, excluded = EmptyFlags)
528+
memberBasedOnFlags(name, required = EmptyFlags, excluded = EmptyFlags)
529529
}
530530

531531
/** The non-private member of this type with the given name. */
532532
final def nonPrivateMember(name: Name)(implicit ctx: Context): Denotation = track("nonPrivateMember") {
533-
memberBasedOnFlags(name, required = EmptyFlagConjunction, excluded = Flags.Private)
533+
memberBasedOnFlags(name, required = EmptyFlags, excluded = Flags.Private)
534534
}
535535

536536
/** The member with given `name` and required and/or excluded flags */
537-
final def memberBasedOnFlags(name: Name, required: FlagConjunction = EmptyFlagConjunction, excluded: FlagSet = EmptyFlags)(implicit ctx: Context): Denotation = {
537+
final def memberBasedOnFlags(name: Name, required: FlagSet = EmptyFlags, excluded: FlagSet = EmptyFlags)(implicit ctx: Context): Denotation = {
538538
// We need a valid prefix for `asSeenFrom`
539539
val pre = this match {
540540
case tp: ClassInfo => tp.appliedRef
@@ -547,7 +547,7 @@ object Types {
547547
* flags and no `excluded` flag and produce a denotation that contains
548548
* the type of the member as seen from given prefix `pre`.
549549
*/
550-
final def findMember(name: Name, pre: Type, required: FlagConjunction = EmptyFlagConjunction, excluded: FlagSet = EmptyFlags)(implicit ctx: Context): Denotation = {
550+
final def findMember(name: Name, pre: Type, required: FlagSet = EmptyFlags, excluded: FlagSet = EmptyFlags)(implicit ctx: Context): Denotation = {
551551
@tailrec def go(tp: Type): Denotation = tp match {
552552
case tp: TermRef =>
553553
go (tp.underlying match {
@@ -808,7 +808,7 @@ object Types {
808808
}
809809

810810
/** The set of members of this type that have all of `required` flags but none of `excluded` flags set. */
811-
final def membersBasedOnFlags(required: FlagConjunction, excluded: FlagSet)(implicit ctx: Context): Seq[SingleDenotation] = track("membersBasedOnFlags") {
811+
final def membersBasedOnFlags(required: FlagSet, excluded: FlagSet)(implicit ctx: Context): Seq[SingleDenotation] = track("membersBasedOnFlags") {
812812
memberDenots(takeAllFilter,
813813
(name, buf) => buf ++= memberBasedOnFlags(name, required, excluded).alternatives)
814814
}

compiler/src/dotty/tools/dotc/transform/patmat/Space.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -629,8 +629,8 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
629629
/** does the companion object of the given symbol have custom unapply */
630630
def hasCustomUnapply(sym: Symbol): Boolean = {
631631
val companion = sym.companionModule
632-
companion.findMember(nme.unapply, NoPrefix, required = EmptyFlagConjunction, excluded = Synthetic).exists ||
633-
companion.findMember(nme.unapplySeq, NoPrefix, required = EmptyFlagConjunction, excluded = Synthetic).exists
632+
companion.findMember(nme.unapply, NoPrefix, required = EmptyFlags, excluded = Synthetic).exists ||
633+
companion.findMember(nme.unapplySeq, NoPrefix, required = EmptyFlags, excluded = Synthetic).exists
634634
}
635635

636636
def doShow(s: Space, mergeList: Boolean = false): String = s match {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ trait NamerContextOps { this: Context =>
4545

4646
/** The denotation with the given `name` and all `required` flags in current context
4747
*/
48-
def denotNamed(name: Name, required: FlagConjunction = EmptyFlagConjunction): Denotation =
48+
def denotNamed(name: Name, required: FlagSet = EmptyFlags): Denotation =
4949
if (owner.isClass)
5050
if (outer.owner == owner) { // inner class scope; check whether we are referring to self
5151
if (scope.size == 1) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ trait TypeAssigner {
5353
def addRefinement(parent: Type, decl: Symbol) = {
5454
val inherited =
5555
parentType.findMember(decl.name, cls.thisType,
56-
required = EmptyFlagConjunction, excluded = Private)
56+
required = EmptyFlags, excluded = Private)
5757
.suchThat(decl.matches(_))
5858
val inheritedInfo = inherited.info
5959
val isPolyFunctionApply = decl.name == nme.apply && (parent <:< defn.PolyFunctionType)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ class Typer extends Namer
122122
* @param required flags the result's symbol must have
123123
* @param posd indicates position to use for error reporting
124124
*/
125-
def findRef(name: Name, pt: Type, required: FlagConjunction, posd: Positioned)(implicit ctx: Context): Type = {
125+
def findRef(name: Name, pt: Type, required: FlagSet, posd: Positioned)(implicit ctx: Context): Type = {
126126
val refctx = ctx
127127
val noImports = ctx.mode.is(Mode.InPackageClauseName)
128128

@@ -394,7 +394,7 @@ class Typer extends Namer
394394
unimported = Set.empty
395395
foundUnderScala2 = NoType
396396
try {
397-
var found = findRef(name, pt, EmptyFlagConjunction, tree.posd)
397+
var found = findRef(name, pt, EmptyFlags, tree.posd)
398398
if (foundUnderScala2.exists && !(foundUnderScala2 =:= found)) {
399399
ctx.migrationWarning(
400400
ex"""Name resolution will change.

0 commit comments

Comments
 (0)