Skip to content

Commit 84c3d1d

Browse files
authored
Merge pull request scala#7176 from retronym/review/6567
Change flags from Int to Long, and remove hasFlag(flag: Int) method.
2 parents 58c50d9 + 3c8604d commit 84c3d1d

File tree

7 files changed

+66
-68
lines changed

7 files changed

+66
-68
lines changed

src/compiler/scala/reflect/quasiquotes/Parsers.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ trait Parsers { self: Quasiquotes =>
9494
import treeBuilder.{global => _, unit => _}
9595

9696
// q"def foo($x)"
97-
override def param(owner: Name, implicitmod: Int, caseParam: Boolean): ValDef =
97+
override def param(owner: Name, implicitmod: Long, caseParam: Boolean): ValDef =
9898
if (isHole && lookingAhead { in.token == COMMA || in.token == RPAREN }) {
9999
ParamPlaceholder(implicitmod, ident())
100100
} else super.param(owner, implicitmod, caseParam)

src/compiler/scala/tools/nsc/ast/parser/Parsers.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2377,7 +2377,7 @@ self =>
23772377
}
23782378
}
23792379

2380-
def param(owner: Name, implicitmod: Int, caseParam: Boolean): ValDef = {
2380+
def param(owner: Name, implicitmod: Long, caseParam: Boolean): ValDef = {
23812381
val start = in.offset
23822382
val annots = annotations(skipNewLines = false)
23832383
var mods = Modifiers(Flags.PARAM)
@@ -2397,7 +2397,7 @@ self =>
23972397
}
23982398
val nameOffset = in.offset
23992399
val name = ident()
2400-
var bynamemod = 0
2400+
var bynamemod = 0L
24012401
val tpt = {
24022402
accept(COLON)
24032403
if (in.token == ARROW) {
@@ -2417,7 +2417,7 @@ self =>
24172417
expr()
24182418
} else EmptyTree
24192419
atPos(start, if (name == nme.ERROR) start else nameOffset) {
2420-
ValDef((mods | implicitmod.toLong | bynamemod) withAnnotations annots, name.toTermName, tpt, default)
2420+
ValDef((mods | implicitmod | bynamemod) withAnnotations annots, name.toTermName, tpt, default)
24212421
}
24222422
}
24232423

@@ -3253,10 +3253,10 @@ self =>
32533253
}
32543254
*/
32553255

3256-
def localDef(implicitMod: Int): List[Tree] = {
3256+
def localDef(implicitMod: Long): List[Tree] = {
32573257
val annots = annotations(skipNewLines = true)
32583258
val pos = in.offset
3259-
val mods = (localModifiers() | implicitMod.toLong) withAnnotations annots
3259+
val mods = (localModifiers() | implicitMod) withAnnotations annots
32603260
val defs =
32613261
if (!(mods hasFlag ~(Flags.IMPLICIT | Flags.LAZY))) defOrDcl(pos, mods)
32623262
else List(tmplDef(pos, mods))

src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,12 +1305,12 @@ trait ContextErrors {
13051305
}
13061306

13071307

1308-
def AbstractMemberWithModiferError(sym: Symbol, flag: Int) =
1309-
issueSymbolTypeError(sym, "abstract member may not have " + Flags.flagsToString(flag.toLong) + " modifier")
1308+
def AbstractMemberWithModiferError(sym: Symbol, flag: Long) =
1309+
issueSymbolTypeError(sym, "abstract member may not have " + Flags.flagsToString(flag) + " modifier")
13101310

1311-
def IllegalModifierCombination(sym: Symbol, flag1: Int, flag2: Int) =
1311+
def IllegalModifierCombination(sym: Symbol, flag1: Long, flag2: Long) =
13121312
issueSymbolTypeError(sym, "illegal combination of modifiers: %s and %s for: %s".format(
1313-
Flags.flagsToString(flag1.toLong), Flags.flagsToString(flag2.toLong), sym))
1313+
Flags.flagsToString(flag1), Flags.flagsToString(flag2), sym))
13141314

13151315
def IllegalDependentMethTpeError(sym: Symbol)(context: Context) = {
13161316
val errorAddendum =

src/compiler/scala/tools/nsc/typechecker/Namers.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1906,8 +1906,8 @@ trait Namers extends MethodSynthesis {
19061906
import SymValidateErrors._
19071907
def fail(kind: SymValidateErrors.Value) = SymbolValidationError(sym, kind)
19081908

1909-
def checkNoConflict(flag1: Int, flag2: Int) = {
1910-
if (sym hasAllFlags flag1.toLong | flag2)
1909+
def checkNoConflict(flag1: Long, flag2: Long) = {
1910+
if (sym hasAllFlags flag1 | flag2)
19111911
IllegalModifierCombination(sym, flag1, flag2)
19121912
}
19131913
if (sym.isImplicit) {
@@ -1945,7 +1945,7 @@ trait Namers extends MethodSynthesis {
19451945
checkNoConflict(ABSTRACT, FINAL)
19461946

19471947
if (sym.isDeferred) {
1948-
def checkWithDeferred(flag: Int) = {
1948+
def checkWithDeferred(flag: Long) = {
19491949
if (sym hasFlag flag)
19501950
AbstractMemberWithModiferError(sym, flag)
19511951
}

src/reflect/scala/reflect/internal/Flags.scala

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -81,36 +81,36 @@ package internal
8181
/** Flags set on Modifiers instances in the parsing stage.
8282
*/
8383
class ModifierFlags {
84-
final val IMPLICIT = 1 << 9
85-
final val FINAL = 1 << 5 // May not be overridden. Note that java final implies much more than scala final.
86-
final val PRIVATE = 1 << 2
87-
final val PROTECTED = 1 << 0
88-
89-
final val SEALED = 1 << 10
90-
final val OVERRIDE = 1 << 1
91-
final val CASE = 1 << 11
92-
final val ABSTRACT = 1 << 3 // abstract class, or used in conjunction with abstract override.
84+
final val IMPLICIT = 1L << 9
85+
final val FINAL = 1L << 5 // May not be overridden. Note that java final implies much more than scala final.
86+
final val PRIVATE = 1L << 2
87+
final val PROTECTED = 1L << 0
88+
89+
final val SEALED = 1L << 10
90+
final val OVERRIDE = 1L << 1
91+
final val CASE = 1L << 11
92+
final val ABSTRACT = 1L << 3 // abstract class, or used in conjunction with abstract override.
9393
// Note difference to DEFERRED!
94-
final val DEFERRED = 1 << 4 // was `abstract' for members | trait is virtual
95-
final val INTERFACE = 1 << 7 // symbol is an interface. the flag is set for:
94+
final val DEFERRED = 1L << 4 // was `abstract' for members | trait is virtual
95+
final val INTERFACE = 1L << 7 // symbol is an interface. the flag is set for:
9696
// - scala-defined traits with only abstract methods or fields
9797
// - any java-defined interface (even if it has default methods)
98-
final val MUTABLE = 1 << 12 // symbol is a mutable variable.
99-
final val PARAM = 1 << 13 // symbol is a (value or type) parameter to a method
100-
final val MACRO = 1 << 15 // symbol is a macro definition
101-
102-
final val COVARIANT = 1 << 16 // symbol is a covariant type variable
103-
final val BYNAMEPARAM = 1 << 16 // parameter is by name
104-
final val CONTRAVARIANT = 1 << 17 // symbol is a contravariant type variable
105-
final val ABSOVERRIDE = 1 << 18 // combination of abstract & override
106-
final val LOCAL = 1 << 19 // symbol is local to current class (i.e. private[this] or protected[this]
98+
final val MUTABLE = 1L << 12 // symbol is a mutable variable.
99+
final val PARAM = 1L << 13 // symbol is a (value or type) parameter to a method
100+
final val MACRO = 1L << 15 // symbol is a macro definition
101+
102+
final val COVARIANT = 1L << 16 // symbol is a covariant type variable
103+
final val BYNAMEPARAM = 1L << 16 // parameter is by name
104+
final val CONTRAVARIANT = 1L << 17 // symbol is a contravariant type variable
105+
final val ABSOVERRIDE = 1L << 18 // combination of abstract & override
106+
final val LOCAL = 1L << 19 // symbol is local to current class (i.e. private[this] or protected[this]
107107
// pre: PRIVATE or PROTECTED are also set
108-
final val JAVA = 1 << 20 // symbol was defined by a Java class
109-
final val STATIC = 1 << 23 // static field, method or class
110-
final val CASEACCESSOR = 1 << 24 // symbol is a case parameter (or its accessor, or a GADT skolem)
111-
final val TRAIT = 1 << 25 // symbol is a trait
112-
final val DEFAULTPARAM = 1 << 25 // the parameter has a default value
113-
final val PARAMACCESSOR = 1 << 29 // for field definitions generated for primary constructor
108+
final val JAVA = 1L << 20 // symbol was defined by a Java class
109+
final val STATIC = 1L << 23 // static field, method or class
110+
final val CASEACCESSOR = 1L << 24 // symbol is a case parameter (or its accessor, or a GADT skolem)
111+
final val TRAIT = 1L << 25 // symbol is a trait
112+
final val DEFAULTPARAM = 1L << 25 // the parameter has a default value
113+
final val PARAMACCESSOR = 1L << 29 // for field definitions generated for primary constructor
114114
// parameters (no matter if it's a 'val' parameter or not)
115115
// for parameters of a primary constructor ('val' or not)
116116
// for the accessor methods generated for 'val' or 'var' parameters
@@ -134,22 +134,22 @@ object ModifierFlags extends ModifierFlags
134134

135135
/** All flags and associated operations */
136136
class Flags extends ModifierFlags {
137-
final val METHOD = 1 << 6 // a method
138-
final val MODULE = 1 << 8 // symbol is module or class implementing a module
139-
final val PACKAGE = 1 << 14 // symbol is a java package
140-
141-
final val CAPTURED = 1 << 16 // variable is accessed from nested function. Set by LambdaLift.
142-
final val LABEL = 1 << 17 // method symbol is a label. Set by TailCall
143-
final val INCONSTRUCTOR = 1 << 17 // class symbol is defined in this/superclass constructor.
144-
final val SYNTHETIC = 1 << 21 // symbol is compiler-generated (compare with ARTIFACT)
145-
final val STABLE = 1 << 22 // functions that are assumed to be stable
137+
final val METHOD = 1L << 6 // a method
138+
final val MODULE = 1L << 8 // symbol is module or class implementing a module
139+
final val PACKAGE = 1L << 14 // symbol is a java package
140+
141+
final val CAPTURED = 1L << 16 // variable is accessed from nested function. Set by LambdaLift.
142+
final val LABEL = 1L << 17 // method symbol is a label. Set by TailCall
143+
final val INCONSTRUCTOR = 1L << 17 // class symbol is defined in this/superclass constructor.
144+
final val SYNTHETIC = 1L << 21 // symbol is compiler-generated (compare with ARTIFACT)
145+
final val STABLE = 1L << 22 // functions that are assumed to be stable
146146
// (typically, access methods for valdefs)
147147
// or classes that do not contain abstract types.
148-
final val BRIDGE = 1 << 26 // function is a bridge method. Set by Erasure
149-
final val ACCESSOR = 1 << 27 // a value or variable accessor (getter or setter)
148+
final val BRIDGE = 1L << 26 // function is a bridge method. Set by Erasure
149+
final val ACCESSOR = 1L << 27 // a value or variable accessor (getter or setter)
150150

151-
final val SUPERACCESSOR = 1 << 28 // a super accessor
152-
final val MODULEVAR = 1 << 30 // for variables: is the variable caching a module value
151+
final val SUPERACCESSOR = 1L << 28 // a super accessor
152+
final val MODULEVAR = 1L << 30 // for variables: is the variable caching a module value
153153

154154
final val IS_ERROR = 1L << 32 // symbol is an error symbol
155155
final val OVERLOADED = 1L << 33 // symbol is overloaded
@@ -348,18 +348,18 @@ class Flags extends ModifierFlags {
348348
// The flags from 0x001 to 0x800 are different in the raw flags
349349
// and in the pickled format.
350350

351-
private final val IMPLICIT_PKL = (1 << 0)
352-
private final val FINAL_PKL = (1 << 1)
353-
private final val PRIVATE_PKL = (1 << 2)
354-
private final val PROTECTED_PKL = (1 << 3)
355-
private final val SEALED_PKL = (1 << 4)
356-
private final val OVERRIDE_PKL = (1 << 5)
357-
private final val CASE_PKL = (1 << 6)
358-
private final val ABSTRACT_PKL = (1 << 7)
359-
private final val DEFERRED_PKL = (1 << 8)
360-
private final val METHOD_PKL = (1 << 9)
361-
private final val MODULE_PKL = (1 << 10)
362-
private final val INTERFACE_PKL = (1 << 11)
351+
private final val IMPLICIT_PKL = (1L << 0)
352+
private final val FINAL_PKL = (1L << 1)
353+
private final val PRIVATE_PKL = (1L << 2)
354+
private final val PROTECTED_PKL = (1L << 3)
355+
private final val SEALED_PKL = (1L << 4)
356+
private final val OVERRIDE_PKL = (1L << 5)
357+
private final val CASE_PKL = (1L << 6)
358+
private final val ABSTRACT_PKL = (1L << 7)
359+
private final val DEFERRED_PKL = (1L << 8)
360+
private final val METHOD_PKL = (1L << 9)
361+
private final val MODULE_PKL = (1L << 10)
362+
private final val INTERFACE_PKL = (1L << 11)
363363

364364
private final val PKL_MASK = 0x00000FFF
365365

src/reflect/scala/reflect/internal/Symbols.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -740,8 +740,6 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
740740
/** Does symbol have ANY flag in `mask` set? */
741741
final def hasFlag(mask: Long): Boolean = getFlag(mask) != 0
742742

743-
def hasFlag(mask: Int): Boolean = hasFlag(mask.toLong)
744-
745743
/** Does symbol have ALL the flags in `mask` set? */
746744
final def hasAllFlags(mask: Long): Boolean = getFlag(mask) == mask
747745

src/reflect/scala/reflect/internal/Types.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -983,12 +983,12 @@ trait Types
983983
/** If this is a symbol loader type, load and assign a new type to `sym`. */
984984
def load(sym: Symbol): Unit = {}
985985

986-
private def findDecl(name: Name, excludedFlags: Int): Symbol = {
986+
private def findDecl(name: Name, excludedFlags: Long): Symbol = {
987987
var alts: List[Symbol] = List()
988988
var sym: Symbol = NoSymbol
989989
var e: ScopeEntry = decls.lookupEntry(name)
990990
while (e ne null) {
991-
if (!e.sym.hasFlag(excludedFlags.toLong)) {
991+
if (!e.sym.hasFlag(excludedFlags)) {
992992
if (sym == NoSymbol) sym = e.sym
993993
else {
994994
if (alts.isEmpty) alts = sym :: Nil

0 commit comments

Comments
 (0)