Skip to content

Commit 37a290b

Browse files
committed
HIDDEN => ARTIFACT
This test is necessary in the API to tell apart useful synthetic symbols (such as accessors) and low-level compilation artifacts (such as $outer). However `isHidden` (as it's currently named in the compiler) is too generic. Hence I renamed it along with the corresponding flag. Now the test says `isArtifact` and the flag is named ARTIFACT. Despite being an improvement over the first version, `isArtifact` is still a bit unlucky. The name I like is `isImplementationArtifact`, but that's a mouthful to be used in compiler hacking. Moreover, IMPLEMENTATION_ARTIFACT looks weird. For a discussion about related stuff see: http://groups.google.com/group/scala-internals/browse_thread/thread/d04e762127737968 #1114
1 parent 0e2080e commit 37a290b

File tree

10 files changed

+55
-49
lines changed

10 files changed

+55
-49
lines changed

src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters {
295295
if (finalFlag && !sym.hasAbstractFlag) ACC_FINAL else 0,
296296
if (sym.isStaticMember) ACC_STATIC else 0,
297297
if (sym.isBridge) ACC_BRIDGE | ACC_SYNTHETIC else 0,
298-
if (sym.isHidden) ACC_SYNTHETIC else 0,
298+
if (sym.isArtifact) ACC_SYNTHETIC else 0,
299299
if (sym.isClass && !sym.isInterface) ACC_SUPER else 0,
300300
if (sym.isVarargsMethod) ACC_VARARGS else 0,
301301
if (sym.hasFlag(Flags.SYNCHRONIZED)) ACC_SYNCHRONIZED else 0
@@ -851,7 +851,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters {
851851
// generic information could disappear as a consequence of a seemingly
852852
// unrelated change.
853853
settings.Ynogenericsig.value
854-
|| sym.isHidden
854+
|| sym.isArtifact
855855
|| sym.isLiftedMethod
856856
|| sym.isBridge
857857
|| (sym.ownerChain exists (_.isImplClass))

src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with
728728
// generic information could disappear as a consequence of a seemingly
729729
// unrelated change.
730730
settings.Ynogenericsig.value
731-
|| sym.isHidden
731+
|| sym.isArtifact
732732
|| sym.isLiftedMethod
733733
|| sym.isBridge
734734
|| (sym.ownerChain exists (_.isImplClass))
@@ -866,7 +866,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with
866866

867867
def genField(f: IField) {
868868
debuglog("Adding field: " + f.symbol.fullName)
869-
869+
870870
val jfield = jclass.addNewField(
871871
javaFieldFlags(f.symbol),
872872
javaName(f.symbol),
@@ -1021,7 +1021,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with
10211021

10221022
method = m
10231023
jmethod = clinitMethod
1024-
1024+
10251025
computeLocalVarsIndex(m)
10261026
genCode(m)
10271027
case None =>
@@ -1116,7 +1116,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with
11161116
linkedClass.info.members collect { case sym if sym.name.isTermName => sym.name } toSet
11171117
}
11181118
debuglog("Potentially conflicting names for forwarders: " + conflictingNames)
1119-
1119+
11201120
for (m <- moduleClass.info.membersBasedOnFlags(ExcludedForwarderFlags, Flags.METHOD)) {
11211121
if (m.isType || m.isDeferred || (m.owner eq ObjectClass) || m.isConstructor)
11221122
debuglog("No forwarder for '%s' from %s to '%s'".format(m, className, moduleClass))
@@ -1308,7 +1308,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with
13081308
jclass.getType())
13091309
}
13101310
}
1311-
1311+
13121312
style match {
13131313
case Static(true) => dbg("invokespecial"); jcode.emitINVOKESPECIAL(jowner, jname, jtype)
13141314
case Static(false) => dbg("invokestatic"); jcode.emitINVOKESTATIC(jowner, jname, jtype)
@@ -1889,7 +1889,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with
18891889
*/
18901890
def computeLocalVarsIndex(m: IMethod) {
18911891
var idx = if (m.symbol.isStaticMember) 0 else 1;
1892-
1892+
18931893
for (l <- m.params) {
18941894
debuglog("Index value for " + l + "{" + l.## + "}: " + idx)
18951895
l.index = idx
@@ -1977,7 +1977,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with
19771977
if (finalFlag && !sym.hasAbstractFlag) ACC_FINAL else 0,
19781978
if (sym.isStaticMember) ACC_STATIC else 0,
19791979
if (sym.isBridge) ACC_BRIDGE | ACC_SYNTHETIC else 0,
1980-
if (sym.isHidden) ACC_SYNTHETIC else 0,
1980+
if (sym.isArtifact) ACC_SYNTHETIC else 0,
19811981
if (sym.isClass && !sym.isInterface) ACC_SUPER else 0,
19821982
if (sym.isVarargsMethod) ACC_VARARGS else 0,
19831983
if (sym.hasFlag(Flags.SYNCHRONIZED)) JAVA_ACC_SYNCHRONIZED else 0

src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,7 @@ abstract class ClassfileParser {
869869
}
870870
else in.skip(attrLen)
871871
case tpnme.SyntheticATTR =>
872-
sym.setFlag(SYNTHETIC | HIDDEN)
872+
sym.setFlag(SYNTHETIC | ARTIFACT)
873873
in.skip(attrLen)
874874
case tpnme.BridgeATTR =>
875875
sym.setFlag(BRIDGE)

src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ abstract class ExplicitOuter extends InfoTransform
9595
else findOrElse(clazz.info.decls)(_.outerSource == clazz)(NoSymbol)
9696
}
9797
def newOuterAccessor(clazz: Symbol) = {
98-
val accFlags = SYNTHETIC | HIDDEN | METHOD | STABLE | ( if (clazz.isTrait) DEFERRED else 0 )
98+
val accFlags = SYNTHETIC | ARTIFACT | METHOD | STABLE | ( if (clazz.isTrait) DEFERRED else 0 )
9999
val sym = clazz.newMethod(nme.OUTER, clazz.pos, accFlags)
100100
val restpe = if (clazz.isTrait) clazz.outerClass.tpe else clazz.outerClass.thisType
101101

@@ -104,7 +104,7 @@ abstract class ExplicitOuter extends InfoTransform
104104
sym setInfo MethodType(Nil, restpe)
105105
}
106106
def newOuterField(clazz: Symbol) = {
107-
val accFlags = SYNTHETIC | HIDDEN | PARAMACCESSOR | ( if (clazz.isEffectivelyFinal) PrivateLocal else PROTECTED )
107+
val accFlags = SYNTHETIC | ARTIFACT | PARAMACCESSOR | ( if (clazz.isEffectivelyFinal) PrivateLocal else PROTECTED )
108108
val sym = clazz.newValue(nme.OUTER_LOCAL, clazz.pos, accFlags)
109109

110110
sym setInfo clazz.outerClass.thisType

src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
452452
def survivingParams(params: List[Symbol], env: TypeEnv) =
453453
params filter {
454454
p =>
455-
!p.isSpecialized ||
455+
!p.isSpecialized ||
456456
!env.contains(p) ||
457457
!isPrimitiveValueType(env(p))
458458
}
@@ -506,16 +506,16 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
506506
* was both already used for a map and mucho long. So "sClass" is the
507507
* specialized subclass of "clazz" throughout this file.
508508
*/
509-
509+
510510
// SI-5545: Eliminate classes with the same name loaded from the bytecode already present - all we need to do is
511511
// to force .info on them, as their lazy type will be evaluated and the symbols will be eliminated. Unfortunately
512512
// evaluating the info after creating the specialized class will mess the specialized class signature, so we'd
513-
// better evaluate it before creating the new class symbol
513+
// better evaluate it before creating the new class symbol
514514
val clazzName = specializedName(clazz, env0).toTypeName
515-
val bytecodeClazz = clazz.owner.info.decl(clazzName)
515+
val bytecodeClazz = clazz.owner.info.decl(clazzName)
516516
// debuglog("Specializing " + clazz + ", but found " + bytecodeClazz + " already there")
517517
bytecodeClazz.info
518-
518+
519519
val sClass = clazz.owner.newClass(clazzName, clazz.pos, (clazz.flags | SPECIALIZED) & ~CASE)
520520

521521
def cloneInSpecializedClass(member: Symbol, flagFn: Long => Long, newName: Name = null) =
@@ -762,7 +762,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
762762
}
763763
}
764764
}
765-
765+
766766
val subclasses = specializations(clazz.info.typeParams) filter satisfiable
767767
subclasses foreach {
768768
env =>
@@ -798,7 +798,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
798798
var specializingOn = specializedParams(sym)
799799
val unusedStvars = specializingOn filterNot specializedTypeVars(sym.info)
800800

801-
// I think the last condition should be !sym.isHidden, but that made the
801+
// I think the last condition should be !sym.isArtifact, but that made the
802802
// compiler start warning about Tuple1.scala and Tuple2.scala claiming
803803
// their type parameters are used in non-specializable positions. Why is
804804
// unusedStvars.nonEmpty for these classes???
@@ -1006,7 +1006,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
10061006
* Fails if such an environment cannot be found.
10071007
*
10081008
* If `strict` is true, a UnifyError is thrown if unification is impossible.
1009-
*
1009+
*
10101010
* If `tparams` is true, then the methods tries to unify over type params in polytypes as well.
10111011
*/
10121012
private def unify(tp1: Type, tp2: Type, env: TypeEnv, strict: Boolean, tparams: Boolean = false): TypeEnv = (tp1, tp2) match {
@@ -1185,7 +1185,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
11851185
|| specializedTypeVars(t1).nonEmpty
11861186
|| specializedTypeVars(t2).nonEmpty)
11871187
}
1188-
1188+
11891189
env forall { case (tvar, tpe) =>
11901190
matches(tvar.info.bounds.lo, tpe) && matches(tpe, tvar.info.bounds.hi) || {
11911191
if (warnings)
@@ -1201,7 +1201,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
12011201
}
12021202
}
12031203
}
1204-
1204+
12051205
def satisfiabilityConstraints(env: TypeEnv): Option[TypeEnv] = {
12061206
val noconstraints = Some(emptyEnv)
12071207
def matches(tpe1: Type, tpe2: Type): Option[TypeEnv] = {
@@ -1232,7 +1232,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
12321232
} with typechecker.Duplicators {
12331233
private val (castfrom, castto) = casts.unzip
12341234
private object CastMap extends SubstTypeMap(castfrom.toList, castto.toList)
1235-
1235+
12361236
class BodyDuplicator(_context: Context) extends super.BodyDuplicator(_context) {
12371237
override def castType(tree: Tree, pt: Type): Tree = {
12381238
// log(" expected type: " + pt)
@@ -1249,9 +1249,9 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
12491249
ntree
12501250
}
12511251
}
1252-
1252+
12531253
protected override def newBodyDuplicator(context: Context) = new BodyDuplicator(context)
1254-
1254+
12551255
}
12561256

12571257
/** A tree symbol substituter that substitutes on type skolems.
@@ -1359,7 +1359,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
13591359
}
13601360
}
13611361
}
1362-
1362+
13631363
def reportError[T](body: =>T)(handler: TypeError => T): T =
13641364
try body
13651365
catch {
@@ -1396,7 +1396,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
13961396
else None
13971397
} else None
13981398
}
1399-
1399+
14001400
curTree = tree
14011401
tree match {
14021402
case Apply(Select(New(tpt), nme.CONSTRUCTOR), args) =>
@@ -1570,7 +1570,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
15701570
})
15711571
debuglog("created special overload tree " + t)
15721572
debuglog("created " + t)
1573-
reportError {
1573+
reportError {
15741574
localTyper.typed(t)
15751575
} {
15761576
_ => super.transform(tree)
@@ -1629,9 +1629,9 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
16291629
super.transform(tree)
16301630
}
16311631
}
1632-
1632+
16331633
/** Duplicate the body of the given method `tree` to the new symbol `source`.
1634-
*
1634+
*
16351635
* Knowing that the method can be invoked only in the `castmap` type environment,
16361636
* this method will insert casts for all the expressions of types mappend in the
16371637
* `castmap`.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ package scala.tools.nsc
88
package typechecker
99

1010
import symtab._
11-
import Flags.{MUTABLE, METHOD, LABEL, SYNTHETIC, HIDDEN}
11+
import Flags.{MUTABLE, METHOD, LABEL, SYNTHETIC, ARTIFACT}
1212
import language.postfixOps
1313
import scala.tools.nsc.transform.TypingTransformers
1414
import scala.tools.nsc.transform.Transform
@@ -1083,7 +1083,7 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
10831083

10841084
// ExplicitOuter replaces `Select(q, outerSym) OBJ_EQ expectedPrefix` by `Select(q, outerAccessor(outerSym.owner)) OBJ_EQ expectedPrefix`
10851085
// if there's an outer accessor, otherwise the condition becomes `true` -- TODO: can we improve needsOuterTest so there's always an outerAccessor?
1086-
val outer = expectedTp.typeSymbol.newMethod(vpmName.outer) setInfo expectedTp.prefix setFlag SYNTHETIC | HIDDEN
1086+
val outer = expectedTp.typeSymbol.newMethod(vpmName.outer) setInfo expectedTp.prefix setFlag SYNTHETIC | ARTIFACT
10871087

10881088
(Select(codegen._asInstanceOf(testedBinder, expectedTp), outer)) OBJ_EQ expectedOuter
10891089
}

src/reflect/scala/reflect/api/Symbols.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ trait Symbols extends base.Symbols { self: Universe =>
6767
*/
6868
def isSynthetic: Boolean
6969

70+
/** Does this symbol represent an implementation artifact that isn't meant for public use?
71+
* Examples of such artifacts are erasure bridges and $outer fields.
72+
*/
73+
def isImplementationArtifact: Boolean
74+
7075
/** Does this symbol represent a local declaration or definition?
7176
*
7277
* If yes, either `isPrivate` or `isProtected` are guaranteed to be true.

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ class Flags extends ModifierFlags {
135135
final val CAPTURED = 1 << 16 // variable is accessed from nested function. Set by LambdaLift.
136136
final val LABEL = 1 << 17 // method symbol is a label. Set by TailCall
137137
final val INCONSTRUCTOR = 1 << 17 // class symbol is defined in this/superclass constructor.
138-
final val SYNTHETIC = 1 << 21 // symbol is compiler-generated (compare with HIDDEN)
138+
final val SYNTHETIC = 1 << 21 // symbol is compiler-generated (compare with ARTIFACT)
139139
final val STABLE = 1 << 22 // functions that are assumed to be stable
140140
// (typically, access methods for valdefs)
141141
// or classes that do not contain abstract types.
@@ -165,7 +165,7 @@ class Flags extends ModifierFlags {
165165
// A Java method's type is ``cooked'' by transforming raw types to existentials
166166

167167
final val SYNCHRONIZED = 1L << 45 // symbol is a method which should be marked ACC_SYNCHRONIZED
168-
final val HIDDEN = 1L << 46 // symbol should be ignored when typechecking; will be marked ACC_SYNTHETIC in bytecode
168+
final val ARTIFACT = 1L << 46 // symbol should be ignored when typechecking; will be marked ACC_SYNTHETIC in bytecode
169169

170170
// ------- shift definitions -------------------------------------------------------
171171

@@ -218,7 +218,7 @@ class Flags extends ModifierFlags {
218218
/** To be a little clearer to people who aren't habitual bit twiddlers.
219219
*/
220220
final val AllFlags = -1L
221-
221+
222222
/** These flags can be set when class or module symbol is first created.
223223
* They are the only flags to survive a call to resetFlags().
224224
*/
@@ -288,11 +288,11 @@ class Flags extends ModifierFlags {
288288

289289
/** These flags are not pickled */
290290
final val FlagsNotPickled = IS_ERROR | OVERLOADED | LIFTED | TRANS_FLAG | LOCKED | TRIEDCOOKING
291-
291+
292292
// A precaution against future additions to FlagsNotPickled turning out
293293
// to be overloaded flags thus not-pickling more than intended.
294294
assert((OverloadedFlagsMask & FlagsNotPickled) == 0, flagsToString(OverloadedFlagsMask & FlagsNotPickled))
295-
295+
296296
/** These flags are pickled */
297297
final val PickledFlags = InitialFlags & ~FlagsNotPickled
298298

@@ -339,13 +339,13 @@ class Flags extends ModifierFlags {
339339
(SEALED, SEALED_PKL),
340340
(ABSTRACT, ABSTRACT_PKL)
341341
)
342-
342+
343343
private val mappedRawFlags = rawPickledCorrespondence map (_._1)
344344
private val mappedPickledFlags = rawPickledCorrespondence map (_._2)
345-
345+
346346
private class MapFlags(from: Array[Long], to: Array[Long]) extends (Long => Long) {
347347
val fromSet = (0L /: from) (_ | _)
348-
348+
349349
def apply(flags: Long): Long = {
350350
var result = flags & ~fromSet
351351
var tobeMapped = flags & fromSet
@@ -360,7 +360,7 @@ class Flags extends ModifierFlags {
360360
result
361361
}
362362
}
363-
363+
364364
val rawToPickledFlags: Long => Long = new MapFlags(mappedRawFlags, mappedPickledFlags)
365365
val pickledToRawFlags: Long => Long = new MapFlags(mappedPickledFlags, mappedRawFlags)
366366

@@ -434,7 +434,7 @@ class Flags extends ModifierFlags {
434434
case 0x8000000000000000L => "" // (1L << 63)
435435
case _ => ""
436436
}
437-
437+
438438
private def accessString(flags: Long, privateWithin: String)= (
439439
if (privateWithin == "") {
440440
if ((flags & PrivateLocal) == PrivateLocal) "private[this]"
@@ -446,7 +446,7 @@ class Flags extends ModifierFlags {
446446
else if ((flags & PROTECTED) != 0) "protected[" + privateWithin + "]"
447447
else "private[" + privateWithin + "]"
448448
)
449-
449+
450450
@deprecated("Use flagString on the flag-carrying member", "2.10.0")
451451
def flagsToString(flags: Long, privateWithin: String): String = {
452452
val access = accessString(flags, privateWithin)

src/reflect/scala/reflect/internal/HasFlags.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ trait HasFlags {
6666
*/
6767
def flagString: String = flagString(flagMask)
6868
def flagString(mask: Long): String = calculateFlagString(flags & mask)
69-
69+
7070
/** The default mask determining which flags to display.
7171
*/
7272
def flagMask: Long = AllFlags
@@ -92,7 +92,7 @@ trait HasFlags {
9292
def isCaseAccessor = hasFlag(CASEACCESSOR)
9393
def isDeferred = hasFlag(DEFERRED)
9494
def isFinal = hasFlag(FINAL)
95-
def isHidden = hasFlag(HIDDEN)
95+
def isArtifact = hasFlag(ARTIFACT)
9696
def isImplicit = hasFlag(IMPLICIT)
9797
def isInterface = hasFlag(INTERFACE)
9898
def isJavaDefined = hasFlag(JAVA)
@@ -136,7 +136,7 @@ trait HasFlags {
136136

137137
def accessString: String = {
138138
val pw = if (hasAccessBoundary) privateWithin.toString else ""
139-
139+
140140
if (pw == "") {
141141
if (hasAllFlags(PrivateLocal)) "private[this]"
142142
else if (hasAllFlags(ProtectedLocal)) "protected[this]"
@@ -150,7 +150,7 @@ trait HasFlags {
150150
protected def calculateFlagString(basis: Long): String = {
151151
val access = accessString
152152
val nonAccess = flagBitsToString(basis & ~AccessFlags)
153-
153+
154154
if (access == "") nonAccess
155155
else if (nonAccess == "") access
156156
else nonAccess + " " + access

0 commit comments

Comments
 (0)