package scala.tools.nsc
package symtab
import scala.collection.{ mutable, immutable }
import scala.collection.mutable.ListBuffer
import io.AbstractFile
import util.{ Position, NoPosition, BatchSourceFile }
import util.Statistics._
import Flags._
trait Symbols extends reflect.generic.Symbols { self: SymbolTable =>
import definitions._
private var ids = 0
def symbolCount = ids
val emptySymbolArray = new Array[Symbol](0)
private var recursionTable = immutable.Map.empty[Symbol, Int]
private var nextexid = 0
private def freshExistentialName(suffix: String) = {
nextexid += 1
newTypeName("_" + nextexid + suffix)
}
val originalOwner = mutable.HashMap[Symbol, Symbol]()
abstract class Symbol(initOwner: Symbol, initPos: Position, initName: Name) extends AbsSymbol {
var rawowner = initOwner
var rawname = initName
var rawflags = 0L
private var rawpos = initPos
val id = { ids += 1; ids }
var validTo: Period = NoPeriod
def pos = rawpos
def setPos(pos: Position): this.type = { this.rawpos = pos; this }
private var rawannots: List[AnnotationInfoBase] = Nil
def rawAnnotations = rawannots
def hasAssignedAnnotations = rawannots.nonEmpty
def annotations: List[AnnotationInfo] = {
val annots1 = initialize.rawannots map {
case x: LazyAnnotationInfo => x.annot()
case x: AnnotationInfo => x
} filterNot (_.atp.isError)
rawannots = annots1
annots1
}
def setAnnotations(annots: List[AnnotationInfoBase]): this.type = {
this.rawannots = annots
this
}
override def addAnnotation(annot: AnnotationInfo) {
setAnnotations(annot :: this.rawannots)
}
def hasAnnotation(cls: Symbol) =
getAnnotation(cls).isDefined
def getAnnotation(cls: Symbol): Option[AnnotationInfo] =
annotations find (_.atp.typeSymbol == cls)
def removeAnnotation(cls: Symbol): Unit =
setAnnotations(annotations filterNot (_.atp.typeSymbol == cls))
private[this] var _privateWithin: Symbol = _
def privateWithin = _privateWithin
override def privateWithin_=(sym: Symbol) { _privateWithin = sym }
final def newValue(pos: Position, name: TermName) =
new TermSymbol(this, pos, name)
final def newValue(name: TermName, pos: Position = NoPosition) =
new TermSymbol(this, pos, name)
final def newVariable(pos: Position, name: TermName) =
newValue(pos, name).setFlag(MUTABLE)
final def newValueParameter(pos: Position, name: TermName) =
newValue(pos, name).setFlag(PARAM)
final def newLocalDummy(pos: Position) =
newValue(pos, nme.localDummyName(this)).setInfo(NoType)
final def newMethod(pos: Position, name: TermName) =
new MethodSymbol(this, pos, name).setFlag(METHOD)
final def newMethod(name: TermName, pos: Position = NoPosition) =
new MethodSymbol(this, pos, name).setFlag(METHOD)
final def newLabel(pos: Position, name: TermName) =
newMethod(pos, name).setFlag(LABEL)
final def newConstructor(pos: Position) =
newMethod(pos, nme.CONSTRUCTOR)
final def newModule(pos: Position, name: TermName, clazz: ClassSymbol) =
new ModuleSymbol(this, pos, name).setFlag(MODULE | FINAL)
.setModuleClass(clazz)
final def newModule(name: TermName, clazz: Symbol, pos: Position = NoPosition) =
new ModuleSymbol(this, pos, name).setFlag(MODULE | FINAL)
.setModuleClass(clazz.asInstanceOf[ClassSymbol])
final def newModule(pos: Position, name: TermName) = {
val m = new ModuleSymbol(this, pos, name).setFlag(MODULE | FINAL)
m.setModuleClass(new ModuleClassSymbol(m))
}
final def newPackage(pos: Position, name: TermName) = {
assert(name == nme.ROOT || isPackageClass)
val m = newModule(pos, name).setFlag(JAVA | PACKAGE)
m.moduleClass.setFlag(JAVA | PACKAGE)
m
}
final def newThisSym(pos: Position) =
newValue(pos, nme.this_).setFlag(SYNTHETIC)
final def newImport(pos: Position) =
newValue(pos, nme.IMPORT)
final def newOverloaded(pre: Type, alternatives: List[Symbol]): Symbol =
newValue(alternatives.head.pos, alternatives.head.name.toTermName)
.setFlag(OVERLOADED)
.setInfo(OverloadedType(pre, alternatives))
final def newOuterAccessor(pos: Position) = {
val sym = newMethod(pos, nme.OUTER)
sym setFlag (STABLE | SYNTHETIC)
if (isTrait) sym setFlag DEFERRED
sym.expandName(this)
sym.referenced = this
sym
}
final def newErrorValue(name: TermName) =
newValue(pos, name).setFlag(SYNTHETIC | IS_ERROR).setInfo(ErrorType)
final def newAliasType(pos: Position, name: TypeName) =
new TypeSymbol(this, pos, name)
final def newAliasType(name: TypeName, pos: Position = NoPosition) =
new TypeSymbol(this, pos, name)
final def newAbstractType(pos: Position, name: TypeName) =
new TypeSymbol(this, pos, name).setFlag(DEFERRED)
final def newAbstractType(name: TypeName, pos: Position = NoPosition) =
new TypeSymbol(this, pos, name).setFlag(DEFERRED)
final def newTypeParameter(pos: Position, name: TypeName) =
newAbstractType(pos, name).setFlag(PARAM)
final def newSyntheticValueParamss(argtypess: List[List[Type]]): List[List[Symbol]] = {
var cnt = 0
def freshName() = { cnt += 1; newTermName("x$" + cnt) }
def param(tp: Type) =
newValueParameter(owner.pos.focus, freshName()).setFlag(SYNTHETIC).setInfo(tp)
argtypess map (_.map(param))
}
final def newExistential(pos: Position, name: TypeName): Symbol =
newAbstractType(pos, name).setFlag(EXISTENTIAL)
final def freshExistential(suffix: String): Symbol =
newExistential(pos, freshExistentialName(suffix))
final def newSyntheticValueParams(argtypes: List[Type]): List[Symbol] =
newSyntheticValueParamss(List(argtypes)).head
final def newSyntheticValueParam(argtype: Type): Symbol =
newSyntheticValueParams(List(argtype)).head
final def newTypeSkolem: Symbol =
new TypeSkolem(owner, pos, name.toTypeName, this)
.setFlag(flags)
final def newClass(pos: Position, name: TypeName) =
new ClassSymbol(this, pos, name)
final def newClass(name: TypeName, pos: Position = NoPosition) =
new ClassSymbol(this, pos, name)
final def newModuleClass(pos: Position, name: TypeName) =
new ModuleClassSymbol(this, pos, name)
final def newModuleClass(name: TypeName, pos: Position = NoPosition) =
new ModuleClassSymbol(this, pos, name)
final def newAnonymousClass(pos: Position) =
newClass(pos, tpnme.ANON_CLASS_NAME)
final def newAnonymousFunctionClass(pos: Position) =
newClass(pos, tpnme.ANON_FUN_NAME)
final def newRefinementClass(pos: Position) =
newClass(pos, tpnme.REFINE_CLASS_NAME)
final def newGetter: Symbol = {
val getter = owner.newMethod(pos.focus, nme.getterName(name)).setFlag(getterFlags(flags))
getter.privateWithin = privateWithin
getter.setInfo(MethodType(List(), tpe))
}
final def newErrorClass(name: TypeName) = {
val clazz = newClass(pos, name).setFlag(SYNTHETIC | IS_ERROR)
clazz.setInfo(ClassInfoType(List(), new ErrorScope(this), clazz))
clazz
}
final def newErrorSymbol(name: Name): Symbol = name match {
case x: TypeName => newErrorClass(x)
case x: TermName => newErrorValue(x)
}
def lockOK: Boolean = {
((rawflags & LOCKED) == 0L) ||
((settings.Yrecursion.value != 0) &&
(recursionTable get this match {
case Some(n) => (n <= settings.Yrecursion.value)
case None => true }))
}
def lock(handler: => Unit) = {
if ((rawflags & LOCKED) != 0L) {
if (settings.Yrecursion.value != 0) {
recursionTable get this match {
case Some(n) =>
if (n > settings.Yrecursion.value) {
handler
} else {
recursionTable += (this -> (n + 1))
}
case None =>
recursionTable += (this -> 1)
}
} else { handler }
} else {
rawflags |= LOCKED
}
}
def unlock() = {
if ((rawflags & LOCKED) != 0L) {
rawflags = rawflags & ~LOCKED
if (settings.Yrecursion.value != 0)
recursionTable -= this
}
}
def isNonClassType = false
final def isValue = isTerm && !(isModule && hasFlag(PACKAGE | JAVA))
final def isVariable = isTerm && isMutable && !isMethod
final def isCapturedVariable = isVariable && hasFlag(CAPTURED)
final def isGetter = isTerm && hasAccessorFlag && !nme.isSetterName(name)
final def isSetter = isTerm && hasAccessorFlag && nme.isSetterName(name)
def isSetterParameter = isValueParameter && owner.isSetter
final def hasGetter = isTerm && nme.isLocalName(name)
final def isValueParameter = isTerm && hasFlag(PARAM)
final def isLocalDummy = isTerm && nme.isLocalDummyName(name)
final def isInitializedToDefault = !isType && hasAllFlags(DEFAULTINIT | ACCESSOR)
final def isClassConstructor = isTerm && (name == nme.CONSTRUCTOR)
final def isMixinConstructor = isTerm && (name == nme.MIXIN_CONSTRUCTOR)
final def isConstructor = isTerm && nme.isConstructorName(name)
final def isStaticModule = isModule && isStatic && !isMethod
final def isThisSym = isTerm && owner.thisSym == this
final def isError = hasFlag(IS_ERROR)
final def isErroneous = isError || isInitialized && tpe.isErroneous
override final def isTrait: Boolean = isClass && hasFlag(TRAIT | notDEFERRED)
final def isTypeParameterOrSkolem = isType && hasFlag(PARAM)
final def isHigherOrderTypeParameter = owner.isTypeParameterOrSkolem
final def isTypeSkolem = isSkolem && hasFlag(PARAM)
final def isExistentialSkolem = isExistentiallyBound && isSkolem
final def isExistentialQuantified = isExistentiallyBound && !isSkolem
final def isClassLocalToConstructor = isClass && hasFlag(INCONSTRUCTOR)
final def isAnonymousClass = isClass && (name containsName tpnme.ANON_CLASS_NAME)
final def isAnonymousFunction = isSynthetic && (name containsName tpnme.ANON_FUN_NAME)
final def isAnonOrRefinementClass = isAnonymousClass || isRefinementClass
final def isPackageObject = isModule && name == nme.PACKAGEkw && owner.isPackageClass
final def isPackageObjectClass = isModuleClass && name.toTermName == nme.PACKAGEkw && owner.isPackageClass
final def definedInPackage = owner.isPackageClass || owner.isPackageObjectClass
final def isJavaInterface = isJavaDefined && isTrait
final def needsFlatClasses: Boolean = phase.flatClasses && rawowner != NoSymbol && !rawowner.isPackageClass
final def isPredefModule = this == PredefModule
final def isScalaPackage = (this == ScalaPackage) || (isPackageObject && owner == ScalaPackageClass)
final def isScalaPackageClass = skipPackageObject == ScalaPackageClass
final def skipPackageObject: Symbol = if (isPackageObjectClass) owner else this
final def skipConstructor: Symbol = if (isConstructor) owner else this
final def printWithoutPrefix = !settings.debug.value && (
isScalaPackageClass || isPredefModule || isEffectiveRoot || isAnonOrRefinementClass || isInterpreterWrapper
)
final def isMonomorphicType =
isType && {
var is = infos
(is eq null) || {
while (is.prev ne null) { is = is.prev }
is.info.isComplete && !is.info.isHigherKinded
}
}
def isStrictFP = hasAnnotation(ScalaStrictFPAttr) || (enclClass hasAnnotation ScalaStrictFPAttr)
def isSerializable = info.baseClasses.exists(p => p == SerializableClass || p == JavaSerializableClass) || hasAnnotation(SerializableAttr)
def isDeprecated = hasAnnotation(DeprecatedAttr)
def hasBridgeAnnotation = hasAnnotation(BridgeClass)
def deprecationMessage = getAnnotation(DeprecatedAttr) flatMap (_ stringArg 0)
def deprecationVersion = getAnnotation(DeprecatedAttr) flatMap (_ stringArg 1)
def migrationMessage = getAnnotation(MigrationAnnotationClass) flatMap { _.stringArg(2) }
def elisionLevel = getAnnotation(ElidableMethodClass) flatMap { _.intArg(0) }
def implicitNotFoundMsg = getAnnotation(ImplicitNotFoundClass) flatMap { _.stringArg(0) }
final def isInterpreterWrapper = (
(isModule || isModuleClass)
&& owner.isPackageClass
&& (name containsName nme.INTERPRETER_IMPORT_WRAPPER)
)
final def isOuterAccessor = {
hasFlag(STABLE | SYNTHETIC) &&
originalName == nme.OUTER
}
final def isOuterField = {
hasFlag(SYNTHETIC) &&
originalName == nme.OUTER_LOCAL
}
final def isStable =
isTerm &&
!isMutable &&
(!hasFlag(METHOD | BYNAMEPARAM) || hasFlag(STABLE)) &&
!(tpe.isVolatile && !hasAnnotation(uncheckedStableClass))
def isVirtualClass =
hasFlag(DEFERRED) && isClass
def isVirtualTrait =
hasFlag(DEFERRED) && isTrait
def isLiftedMethod = isMethod && hasFlag(LIFTED)
def isCaseClass = isClass && isCase
final def isPrimaryConstructor =
isConstructor && owner.primaryConstructor == this
final def isAuxiliaryConstructor =
isConstructor && !isPrimaryConstructor
final def isCaseApplyOrUnapply =
isMethod && isCase && isSynthetic
final def needsImplClass: Boolean =
isTrait && (!isInterface || hasFlag(lateINTERFACE)) && !isImplClass
final def isImplOnly: Boolean =
hasFlag(PRIVATE) ||
(owner.isImplClass || owner.isTrait) &&
((hasFlag(notPRIVATE | LIFTED) && !hasFlag(ACCESSOR | SUPERACCESSOR | MODULE) || isConstructor) ||
(hasFlag(LIFTED) && isModule && isMethod))
final def isModuleVar = hasFlag(MODULEVAR)
final def isStatic: Boolean =
hasFlag(STATIC) || isRoot || owner.isStaticOwner
final def isStaticConstructor: Boolean =
isStaticMember && isClassConstructor
final def isStaticMember: Boolean =
hasFlag(STATIC) || owner.isImplClass
final def isStaticOwner: Boolean =
isPackageClass || isModuleClass && isStatic
final def isEffectivelyFinal: Boolean = isFinal || isTerm && (
hasFlag(PRIVATE) || isLocal || owner.isClass && owner.hasFlag(FINAL | MODULE))
final def isLocal: Boolean = owner.isTerm
final def isConstant: Boolean = isStable && isConstantType(tpe.resultType)
final def isNestedClass: Boolean =
isClass && !isRoot && !owner.isPackageClass
final def isLocalClass: Boolean =
isClass && (isAnonOrRefinementClass || isLocal ||
!owner.isPackageClass && owner.isLocalClass)
final def isStructuralRefinement: Boolean =
(isClass || isType || isModule) && info.normalize.isStructuralRefinement
def isMemberOf(clazz: Symbol) =
clazz.info.member(name).alternatives contains this
final def isIncompleteIn(base: Symbol): Boolean =
this.isDeferred ||
(this hasFlag ABSOVERRIDE) && {
val supersym = superSymbol(base)
supersym == NoSymbol || supersym.isIncompleteIn(base)
}
final def exists: Boolean =
this != NoSymbol && (!owner.isPackageClass || { rawInfo.load(this); rawInfo != NoType })
final def isInitialized: Boolean =
validTo != NoPeriod
final def isStableClass: Boolean = {
def hasNoAbstractTypeMember(clazz: Symbol): Boolean =
(clazz hasFlag STABLE) || {
var e = clazz.info.decls.elems
while ((e ne null) && !(e.sym.isAbstractType && info.member(e.sym.name) == e.sym))
e = e.next
e == null
}
def checkStable() =
(info.baseClasses forall hasNoAbstractTypeMember) && { setFlag(STABLE); true }
isClass && (hasFlag(STABLE) || checkStable())
}
final def variance: Int =
if (isCovariant) 1
else if (isContravariant) -1
else 0
def owner: Symbol = rawowner
override final def owner_=(owner: Symbol) {
if (originalOwner contains this) ()
else originalOwner(this) = rawowner
rawowner = owner
}
private[Symbols] def flattenName(): Name = {
assert(rawowner.isClass, "fatal: %s has non-class owner %s after flatten.".format(rawname + idString, rawowner))
nme.flattenedName(rawowner.name, rawname)
}
def ownerChain: List[Symbol] = this :: owner.ownerChain
def enclClassChain: List[Symbol] = {
if (this eq NoSymbol) Nil
else if (isClass && !isPackageClass) this :: owner.enclClassChain
else owner.enclClassChain
}
def ownersIterator: Iterator[Symbol] = new Iterator[Symbol] {
private var current = Symbol.this
def hasNext = current ne NoSymbol
def next = { val r = current; current = current.owner; r }
}
def hasTransOwner(sym: Symbol): Boolean = {
var o = this
while ((o ne sym) && (o ne NoSymbol)) o = o.owner
(o eq sym) ||
isRefinementClass && (info.parents exists (_.typeSymbol.hasTransOwner(sym)))
}
def name: Name = rawname
final def name_=(name: Name) {
if (name != rawname) {
if (owner.isClass) {
var ifs = owner.infos
while (ifs != null) {
ifs.info.decls.rehash(this, name)
ifs = ifs.prev
}
}
rawname = name
}
}
def originalName = nme.originalName(name)
final def flags: Long = {
val fs = rawflags & phase.flagMask
(fs | ((fs & LateFlags) >>> LateShift)) & ~(fs >>> AntiShift)
}
override final def flags_=(fs: Long) = rawflags = fs
final def setFlag(mask: Long): this.type = { rawflags = rawflags | mask; this }
final def resetFlag(mask: Long): this.type = { rawflags = rawflags & ~mask; this }
final def getFlag(mask: Long): Long = flags & mask
final def resetFlags() { rawflags = rawflags & TopLevelCreationFlags }
def accessBoundary(base: Symbol): Symbol = {
if (hasFlag(PRIVATE) || isLocal) owner
else if (hasAccessBoundary && !phase.erasedTypes) privateWithin
else if (hasFlag(PROTECTED)) base
else RootClass
}
def isLessAccessibleThan(other: Symbol): Boolean = {
val tb = this.accessBoundary(owner)
val ob1 = other.accessBoundary(owner)
val ob2 = ob1.linkedClassOfClass
var o = tb
while (o != NoSymbol && o != ob1 && o != ob2) {
o = o.owner
}
o != NoSymbol && o != tb
}
private[Symbols] var infos: TypeHistory = null
override def tpe: Type = info
def tpeHK: Type = tpe
override def info: Type = try {
var cnt = 0
while (validTo == NoPeriod) {
assert(infos ne null, this.name)
assert(infos.prev eq null, this.name)
val tp = infos.info
if ((rawflags & LOCKED) != 0L) {
lock {
setInfo(ErrorType)
throw CyclicReference(this, tp)
}
} else {
rawflags |= LOCKED
}
val current = phase
try {
phase = phaseOf(infos.validFrom)
tp.complete(this)
} finally {
unlock()
phase = current
}
cnt += 1
if (cnt == 3) abort("no progress in completing " + this + ":" + tp)
}
val result = rawInfo
result
} catch {
case ex: CyclicReference =>
if (settings.debug.value) println("... trying to complete "+this)
throw ex
}
override def info_=(info: Type) {
assert(info ne null)
infos = TypeHistory(currentPeriod, info, null)
unlock()
validTo = if (info.isComplete) currentPeriod else NoPeriod
}
def setInfo(info: Type): this.type = { info_=(info); this }
def setInfoOwnerAdjusted(info: Type): this.type = setInfo(info.atOwner(this))
final def updateInfo(info: Type): Symbol = {
assert(phaseId(infos.validFrom) <= phase.id)
if (phaseId(infos.validFrom) == phase.id) infos = infos.prev
infos = TypeHistory(currentPeriod, info, infos)
validTo = if (info.isComplete) currentPeriod else NoPeriod
this
}
def hasRawInfo: Boolean = infos ne null
def rawInfo: Type = {
var infos = this.infos
assert(infos != null)
val curPeriod = currentPeriod
val curPid = phaseId(curPeriod)
if (validTo != NoPeriod) {
while (curPid < phaseId(infos.validFrom) && infos.prev != null)
infos = infos.prev
if (validTo < curPeriod) {
val current = phase
try {
infos = adaptInfos(infos)
if (validTo < curPeriod) {
var itr = infoTransformers.nextFrom(phaseId(validTo))
infoTransformers = itr;
while (itr.pid != NoPhase.id && itr.pid < current.id) {
phase = phaseWithId(itr.pid)
val info1 = itr.transform(this, infos.info)
if (info1 ne infos.info) {
infos = TypeHistory(currentPeriod + 1, info1, infos)
this.infos = infos
}
validTo = currentPeriod + 1
itr = itr.next
}
validTo = if (itr.pid == NoPhase.id) curPeriod
else period(currentRunId, itr.pid)
}
} finally {
phase = current
}
}
}
infos.info
}
private def adaptInfos(infos: TypeHistory): TypeHistory =
if (infos == null || runId(infos.validFrom) == currentRunId) {
infos
} else {
val prev1 = adaptInfos(infos.prev)
if (prev1 ne infos.prev) prev1
else {
def adaptToNewRun(info: Type): Type =
if (isPackageClass) info else adaptToNewRunMap(info)
val pid = phaseId(infos.validFrom)
validTo = period(currentRunId, pid)
phase = phaseWithId(pid)
val info1 = adaptToNewRun(infos.info)
if (info1 eq infos.info) {
infos.validFrom = validTo
infos
} else {
this.infos = TypeHistory(validTo, info1, prev1)
this.infos
}
}
}
final def initialize: this.type = {
if (!isInitialized) info
this
}
final def isUpdatedAt(pid: Phase#Id): Boolean = {
var infos = this.infos
while ((infos ne null) && phaseId(infos.validFrom) != pid + 1) infos = infos.prev
infos ne null
}
final def hasTypeAt(pid: Phase#Id): Boolean = {
var infos = this.infos
while ((infos ne null) && phaseId(infos.validFrom) > pid) infos = infos.prev
infos ne null
}
final def cookJavaRawInfo() {
if (hasFlag(TRIEDCOOKING)) return else setFlag(TRIEDCOOKING)
val oldInfo = info
doCookJavaRawInfo()
}
protected def doCookJavaRawInfo(): Unit
def typeConstructor: Type =
abort("typeConstructor inapplicable for " + this)
def unsafeTypeParams: List[Symbol] =
if (isMonomorphicType) List()
else {
val current = phase
try {
while ((phase.prev ne NoPhase) && phase.prev.keepsTypeParams) phase = phase.prev
if (phase ne current) phase = phase.next
if (settings.debug.value && settings.verbose.value && (phase ne current))
log("checking unsafeTypeParams(" + this + ") at: " + current + " reading at: " + phase)
rawInfo.typeParams
} finally {
phase = current
}
}
def typeParams: List[Symbol] =
if (isMonomorphicType)
List()
else {
if (validTo == NoPeriod) {
val current = phase
try {
phase = phaseOf(infos.validFrom)
rawInfo.load(this)
} finally {
phase = current
}
}
rawInfo.typeParams
}
def paramss: List[List[Symbol]] = info.paramss
def hasParamWhich(cond: Symbol => Boolean) = paramss exists (_ exists cond)
def classBound: Type = {
val tp = refinedType(info.parents, owner)
val thistp = tp.typeSymbol.thisType
val oldsymbuf = new ListBuffer[Symbol]
val newsymbuf = new ListBuffer[Symbol]
for (sym <- info.decls.toList) {
if (sym.isPublic && !sym.isConstructor) {
oldsymbuf += sym
newsymbuf += (
if (sym.isClass)
tp.typeSymbol.newAbstractType(sym.pos, sym.name.toTypeName).setInfo(sym.existentialBound)
else
sym.cloneSymbol(tp.typeSymbol))
}
}
val oldsyms = oldsymbuf.toList
val newsyms = newsymbuf.toList
for (sym <- newsyms) {
addMember(thistp, tp, sym.setInfo(sym.info.substThis(this, thistp).substSym(oldsyms, newsyms)))
}
tp
}
def existentialBound: Type =
if (this.isClass)
polyType(this.typeParams, TypeBounds.upper(this.classBound))
else if (this.isAbstractType)
this.info
else if (this.isTerm)
TypeBounds.upper(intersectionType(List(this.tpe, SingletonClass.tpe)))
else
abort("unexpected alias type: "+this)
def reset(completer: Type) {
resetFlags
infos = null
validTo = NoPeriod
setInfo(completer)
}
def makeSerializable() {
info match {
case ci @ ClassInfoType(_, _, _) =>
updateInfo(ci.copy(parents = ci.parents ::: List(SerializableClass.tpe)))
case i =>
abort("Only ClassInfoTypes can be made serializable: "+ i)
}
}
final def isLess(that: Symbol): Boolean = {
def baseTypeSeqLength(sym: Symbol) =
if (sym.isAbstractType) 1 + sym.info.bounds.hi.baseTypeSeq.length
else sym.info.baseTypeSeq.length
if (this.isType)
(that.isType &&
{ val diff = baseTypeSeqLength(this) - baseTypeSeqLength(that)
diff > 0 || diff == 0 && this.id < that.id })
else
that.isType || this.id < that.id
}
final def isNestedIn(that: Symbol): Boolean =
owner == that || owner != NoSymbol && (owner isNestedIn that)
final def isNonBottomSubClass(that: Symbol): Boolean =
this == that || this.isError || that.isError ||
info.baseTypeIndex(that) >= 0
final def isSubClass(that: Symbol): Boolean = (
isNonBottomSubClass(that) ||
this == NothingClass ||
this == NullClass &&
(that == AnyClass ||
that != NothingClass && (that isSubClass ObjectClass))
)
final def isNumericSubClass(that: Symbol): Boolean =
definitions.isNumericSubClass(this, that)
def alternatives: List[Symbol] =
if (hasFlag(OVERLOADED)) info.asInstanceOf[OverloadedType].alternatives
else List(this)
def filter(cond: Symbol => Boolean): Symbol =
if (hasFlag(OVERLOADED)) {
val alts = alternatives
val alts1 = alts filter cond
if (alts1 eq alts) this
else if (alts1.isEmpty) NoSymbol
else if (alts1.tail.isEmpty) alts1.head
else owner.newOverloaded(info.prefix, alts1)
} else if (this == NoSymbol || cond(this)) {
this
} else NoSymbol
def suchThat(cond: Symbol => Boolean): Symbol = {
val result = filter(cond)
assert(!(result hasFlag OVERLOADED), result.alternatives)
result
}
final def cloneSymbol: Symbol =
cloneSymbol(owner)
final def cloneSymbol(owner: Symbol): Symbol = {
val newSym = cloneSymbolImpl(owner)
newSym.privateWithin = privateWithin
newSym.setInfo(info.cloneInfo(newSym))
.setFlag(this.rawflags).setAnnotations(this.annotations)
}
def cloneSymbolImpl(owner: Symbol): Symbol
def primaryConstructor: Symbol = {
var c = info.decl(
if (isTrait || isImplClass) nme.MIXIN_CONSTRUCTOR
else nme.CONSTRUCTOR)
c = if (c hasFlag OVERLOADED) c.alternatives.head else c
c
}
def thisSym: Symbol = this
def typeOfThis = thisSym.tpe
def thisType: Type = NoPrefix
final def caseFieldAccessors: List[Symbol] = {
val allWithFlag = info.decls.toList filter (_.isCaseAccessor)
val (accessors, fields) = allWithFlag partition (_.isMethod)
def findAccessor(field: Symbol): Symbol = {
val getterName = nme.getterName(field.originalName)
def origGetter = accessors find (_.originalName == getterName)
def renamedGetter = accessors find (_.originalName startsWith (getterName + "$"))
val accessorName = origGetter orElse renamedGetter
accessorName getOrElse NoSymbol
}
fields map findAccessor
}
final def constrParamAccessors: List[Symbol] =
info.decls.toList filter (sym => !sym.isMethod && sym.isParamAccessor)
final def accessed: Symbol = accessed(owner.info)
final def accessed(ownerTp: Type): Symbol = {
assert(hasAccessorFlag)
ownerTp.decl(nme.getterToLocal(if (isSetter) nme.setterToGetter(name) else name))
}
final def implClass: Symbol = owner.info.decl(nme.implClassName(name))
final def outerClass: Symbol =
if (owner.isClass) owner
else if (isClassLocalToConstructor) owner.enclClass.outerClass
else owner.outerClass
def alias: Symbol = NoSymbol
def lazyAccessor: Symbol = NoSymbol
def lazyAccessorOrSelf: Symbol = if (isLazy) lazyAccessor else this
def outerSource: Symbol = NoSymbol
def superClass: Symbol = if (info.parents.isEmpty) NoSymbol else info.parents.head.typeSymbol
def mixinClasses: List[Symbol] = {
val sc = superClass
ancestors takeWhile (sc ne)
}
def ancestors: List[Symbol] = info.baseClasses drop 1
def enclosingPackageClass: Symbol =
if (this == NoSymbol) this else {
var packSym = this.owner
while (packSym != NoSymbol && !packSym.isPackageClass)
packSym = packSym.owner
packSym
}
def enclosingPackage: Symbol = {
val packSym = enclosingPackageClass
if (packSym != NoSymbol) packSym.companionModule
else packSym
}
def originalEnclosingMethod: Symbol = {
if (isMethod) this
else {
val owner = originalOwner.getOrElse(this, rawowner)
if (isLocalDummy) owner.enclClass.primaryConstructor
else owner.originalEnclosingMethod
}
}
def logicallyEnclosingMember: Symbol =
if (isLocalDummy) enclClass.primaryConstructor
else if (isMethod || isClass) this
else owner.logicallyEnclosingMember
def toplevelClass: Symbol =
if (owner.isPackageClass) {
if (isClass) this else moduleClass
} else owner.toplevelClass
def isCoDefinedWith(that: Symbol) = (
(this.rawInfo ne NoType) &&
(this.owner == that.owner) && {
!this.owner.isPackageClass ||
(this.sourceFile eq null) ||
(that.sourceFile eq null) ||
(this.sourceFile == that.sourceFile) || {
if (this.sourceFile.path != that.sourceFile.path)
throw InvalidCompanions(this, that)
false
}
}
)
final def companionClass: Symbol = {
if (this != NoSymbol)
flatOwnerInfo.decl(name.toTypeName).suchThat(_ isCoDefinedWith this)
else NoSymbol
}
private final def companionModule0: Symbol =
flatOwnerInfo.decl(name.toTermName).suchThat(
sym => sym.hasFlag(MODULE) && (sym isCoDefinedWith this) && !sym.isMethod)
final def companionModule: Symbol =
if (isClass && !isRefinementClass) companionModule0
else NoSymbol
final def companionSymbol: Symbol =
if (isTerm) companionClass
else if (isClass) companionModule0
else NoSymbol
final def linkedClassOfClass: Symbol =
if (isModuleClass) companionClass else companionModule.moduleClass
private final def flatOwnerInfo: Type = {
if (needsFlatClasses)
info
owner.rawInfo
}
final def toInterface: Symbol =
if (isImplClass) {
val result =
if (phase.next.erasedTypes) {
assert(!tpe.parents.isEmpty, this)
tpe.parents.last.typeSymbol
} else {
owner.info.decl(nme.interfaceName(name))
}
assert(result != NoSymbol, this)
result
} else this
def moduleClass: Symbol = NoSymbol
final def matchingSymbol(ofclazz: Symbol, site: Type): Symbol =
ofclazz.info.nonPrivateDecl(name).filter(sym =>
!sym.isTerm || (site.memberType(this) matches site.memberType(sym)))
final def matchingSymbol(site: Type, admit: Long = 0L): Symbol =
site.nonPrivateMemberAdmitting(name, admit).filter(sym =>
!sym.isTerm || (site.memberType(this) matches site.memberType(sym)))
final def overriddenSymbol(ofclazz: Symbol): Symbol =
if (isClassConstructor) NoSymbol else matchingSymbol(ofclazz, owner.thisType)
final def overridingSymbol(ofclazz: Symbol): Symbol =
if (isClassConstructor) NoSymbol else matchingSymbol(ofclazz, ofclazz.thisType)
final def allOverriddenSymbols: List[Symbol] =
if (!owner.isClass) Nil
else owner.ancestors map overriddenSymbol filter (_ != NoSymbol)
final def extendedOverriddenSymbols: List[Symbol] =
if (!owner.isClass) Nil
else owner.thisSym.ancestors map overriddenSymbol filter (_ != NoSymbol)
final def superSymbol(base: Symbol): Symbol = {
var bcs = base.info.baseClasses.dropWhile(owner !=).tail
var sym: Symbol = NoSymbol
while (!bcs.isEmpty && sym == NoSymbol) {
if (!bcs.head.isImplClass)
sym = matchingSymbol(bcs.head, base.thisType).suchThat(!_.isDeferred)
bcs = bcs.tail
}
sym
}
final def getter(base: Symbol): Symbol = {
val getterName = if (isSetter) nme.setterToGetter(name) else nme.getterName(name)
base.info.decl(getterName) filter (_.hasAccessorFlag)
}
final def setter(base: Symbol): Symbol = setter(base, false)
final def setter(base: Symbol, hasExpandedName: Boolean): Symbol = {
var sname = nme.getterToSetter(nme.getterName(name))
if (hasExpandedName) sname = nme.expandedSetterName(sname, base)
base.info.decl(sname) filter (_.hasAccessorFlag)
}
final def caseModule: Symbol = {
var modname = name.toTermName
if (privateWithin.isClass && !privateWithin.isModuleClass && !hasFlag(EXPANDEDNAME))
modname = nme.expandedName(modname, privateWithin)
initialize.owner.info.decl(modname).suchThat(_.isModule)
}
def deSkolemize: Symbol = this
def unpackLocation: AnyRef = null
final def makeNotPrivate(base: Symbol) {
if (this hasFlag PRIVATE) {
setFlag(notPRIVATE)
if (isMethod && !isDeferred) setFlag(lateFINAL)
if (!isStaticModule && !isClassConstructor) {
expandName(base)
if (isModule) moduleClass.makeNotPrivate(base)
}
}
}
def expandName(base: Symbol) {
if (this.isTerm && this != NoSymbol && !hasFlag(EXPANDEDNAME)) {
setFlag(EXPANDEDNAME)
if (hasAccessorFlag && !isDeferred) {
accessed.expandName(base)
} else if (hasGetter) {
getter(owner).expandName(base)
setter(owner).expandName(base)
}
name = nme.expandedName(name, base)
if (isType) name = name
}
}
def sourceFile: AbstractFile =
if (isModule) moduleClass.sourceFile
else toplevelClass.sourceFile
def sourceFile_=(f: AbstractFile) {
abort("sourceFile_= inapplicable for " + this)
}
def children: List[Symbol] = Nil
def sealedDescendants: List[Symbol] = {
val kids = children flatMap (_.sealedDescendants)
val all = if (isAbstractClass && !isValueClass(this)) kids else this :: kids
all.distinct sortBy (_.sealedSortName)
}
final def tag = fullName.##
final def simpleName: Name = name
final def sealedSortName = initName + "#" + id
final def keyString: String =
if (isJavaInterface) "interface"
else if (isTrait) "trait"
else if (isClass) "class"
else if (isType && !isParameter) "type"
else if (isVariable) "var"
else if (isPackage) "package"
else if (isModule) "object"
else if (isSourceMethod) "def"
else if (isTerm && (!isParameter || isParamAccessor)) "val"
else ""
final def accurateKindString: String =
if (isPackage) "package"
else if (isPackageClass) "package class"
else if (isPackageObject) "package object"
else if (isPackageObjectClass) "package object class"
else if (isRefinementClass) "refinement class"
else if (isModule) "module"
else if (isModuleClass) "module class"
else sanitizedKindString
private def sanitizedKindString: String =
if (isPackage || isPackageClass) "package"
else if (isModule || isModuleClass) "object"
else if (isAnonymousClass) "anonymous class"
else if (isRefinementClass) ""
else if (isTrait) "trait"
else if (isClass) "class"
else if (isType) "type"
else if (isTerm && isLazy) "lazy value"
else if (isVariable) "variable"
else if (isClassConstructor) "constructor"
else if (isSourceMethod) "method"
else if (isTerm) "value"
else ""
final def kindString: String =
if (settings.debug.value) accurateKindString
else sanitizedKindString
def hasMeaninglessName = (
isSetterParameter
|| isClassConstructor
|| isPackageObject
|| isPackageObjectClass
|| isRefinementClass
)
def nameString = decodedName + idString
final def idString = if (settings.uniqid.value) "#"+id else ""
override def toString = compose(
kindString,
if (hasMeaninglessName) owner.nameString else nameString
)
def ownsString = {
val owns = owner.skipPackageObject
if (owns.isClass && !owns.printWithoutPrefix && !isScalaPackageClass) "" + owns
else ""
}
def locationString = ownsString match {
case "" => ""
case s => " in " + s
}
def fullLocationString = toString + locationString
final def infoString(tp: Type): String = {
def typeParamsString: String = tp match {
case PolyType(tparams, _) if tparams.nonEmpty =>
(tparams map (_.defString)).mkString("[", ",", "]")
case _ =>
""
}
if (isClass)
typeParamsString + " extends " + tp.resultType
else if (isAliasType)
typeParamsString + " = " + tp.resultType
else if (isAbstractType)
typeParamsString + {
tp.resultType match {
case TypeBounds(lo, hi) =>
(if (lo.typeSymbol == NothingClass) "" else " >: " + lo) +
(if (hi.typeSymbol == AnyClass) "" else " <: " + hi)
case rtp =>
"<: " + rtp
}
}
else if (isModule)
moduleClass.infoString(tp)
else
tp match {
case PolyType(tparams, res) =>
typeParamsString + infoString(res)
case NullaryMethodType(res) =>
infoString(res)
case MethodType(params, res) =>
params.map(_.defString).mkString("(", ",", ")") + infoString(res)
case _ =>
": " + tp
}
}
def infosString = infos.toString()
def hasFlagsToString(mask: Long): String = flagsToString(
flags & mask,
if (hasAccessBoundary) privateWithin.toString else ""
)
def varianceString: String =
if (variance == 1) "+"
else if (variance == -1) "-"
else ""
def defaultFlagMask =
if (settings.debug.value) -1L
else if (owner.isRefinementClass) ExplicitFlags & ~OVERRIDE
else ExplicitFlags
def defaultFlagString = hasFlagsToString(defaultFlagMask)
def defString = compose(
defaultFlagString,
keyString,
varianceString + nameString + (
if (hasRawInfo) infoString(rawInfo) else "<_>"
)
)
private def compose(ss: String*) = ss filter (_ != "") mkString " "
def isSingletonExistential =
nme.isSingletonName(name) && (info.bounds.hi.typeSymbol isSubClass SingletonClass)
def existentialToString =
if (isSingletonExistential && !settings.debug.value)
"val " + nme.dropSingletonName(name) + ": " + dropSingletonType(info.bounds.hi)
else defString
}
class TermSymbol(initOwner: Symbol, initPos: Position, initName: TermName)
extends Symbol(initOwner, initPos, initName) {
final override def isTerm = true
override def name: TermName = super.name
privateWithin = NoSymbol
var referenced: Symbol = NoSymbol
def cloneSymbolImpl(owner: Symbol): Symbol =
new TermSymbol(owner, pos, name).copyAttrsFrom(this)
def copyAttrsFrom(original: TermSymbol): this.type = {
referenced = original.referenced
this
}
private val validAliasFlags = SUPERACCESSOR | PARAMACCESSOR | MIXEDIN | SPECIALIZED
override def alias: Symbol =
if (hasFlag(validAliasFlags)) initialize.referenced
else NoSymbol
def setAlias(alias: Symbol): TermSymbol = {
assert(alias != NoSymbol, this)
assert(!alias.isOverloaded, alias)
assert(hasFlag(validAliasFlags), this)
referenced = alias
this
}
override def outerSource: Symbol =
if (name endsWith nme.OUTER) initialize.referenced
else NoSymbol
override def moduleClass: Symbol =
if (hasFlag(MODULE)) referenced else NoSymbol
def setModuleClass(clazz: Symbol): TermSymbol = {
assert(hasFlag(MODULE))
referenced = clazz
this
}
def setLazyAccessor(sym: Symbol): TermSymbol = {
assert(isLazy && (referenced == NoSymbol || referenced == sym), this)
referenced = sym
this
}
override def lazyAccessor: Symbol = {
assert(isLazy, this)
referenced
}
protected def doCookJavaRawInfo() {
def cook(sym: Symbol) {
require(sym hasFlag JAVA)
val tpe1 = rawToExistential(sym.tpe)
if (tpe1 ne sym.tpe) {
sym.setInfo(tpe1)
}
}
if (isJavaDefined)
cook(this)
else if (hasFlag(OVERLOADED))
for (sym2 <- alternatives)
if (sym2 hasFlag JAVA)
cook(sym2)
}
}
class ModuleSymbol(initOwner: Symbol, initPos: Position, initName: TermName)
extends TermSymbol(initOwner, initPos, initName) {
private var flatname: TermName = null
private def isFlatAdjusted = !isMethod && needsFlatClasses
override def owner: Symbol =
if (isFlatAdjusted) rawowner.owner
else rawowner
override def name: TermName =
if (isFlatAdjusted) {
if (flatname == null)
flatname = flattenName().toTermName
flatname
} else rawname
override def cloneSymbolImpl(owner: Symbol): Symbol =
new ModuleSymbol(owner, pos, name).copyAttrsFrom(this)
}
class MethodSymbol(initOwner: Symbol, initPos: Position, initName: TermName)
extends TermSymbol(initOwner, initPos, initName) {
private var mtpePeriod = NoPeriod
private var mtpePre: Type = _
private var mtpeResult: Type = _
private var mtpeInfo: Type = _
override def cloneSymbolImpl(owner: Symbol): Symbol =
new MethodSymbol(owner, pos, name).copyAttrsFrom(this)
def typeAsMemberOf(pre: Type): Type = {
if (mtpePeriod == currentPeriod) {
if ((mtpePre eq pre) && (mtpeInfo eq info)) return mtpeResult
} else if (isValid(mtpePeriod)) {
mtpePeriod = currentPeriod
if ((mtpePre eq pre) && (mtpeInfo eq info)) return mtpeResult
}
val res = pre.computeMemberType(this)
mtpePeriod = currentPeriod
mtpePre = pre
mtpeInfo = info
mtpeResult = res
res
}
}
class TypeSymbol(initOwner: Symbol, initPos: Position, initName: TypeName)
extends Symbol(initOwner, initPos, initName) {
privateWithin = NoSymbol
private var tyconCache: Type = null
private var tyconRunId = NoRunId
private var tpeCache: Type = _
private var tpePeriod = NoPeriod
override def name: TypeName = super.name.asInstanceOf[TypeName]
final override def isType = true
override def isNonClassType = true
override def isAbstractType = isDeferred
override def isAliasType = !isDeferred
private def newTypeRef(targs: List[Type]) = {
val pre = if (hasFlag(PARAM | EXISTENTIAL)) NoPrefix else owner.thisType
typeRef(pre, this, targs)
}
override def tpe: Type = {
if (tpeCache eq NoType) throw CyclicReference(this, typeConstructor)
if (tpePeriod != currentPeriod) {
if (isValid(tpePeriod)) {
tpePeriod = currentPeriod
} else {
if (isInitialized) tpePeriod = currentPeriod
tpeCache = NoType
val targs =
if (phase.erasedTypes && this != ArrayClass) List()
else unsafeTypeParams map (_.typeConstructor)
tpeCache = newTypeRef(targs)
}
}
assert(tpeCache ne null)
tpeCache
}
override def tpeHK = typeConstructor
override def typeConstructor: Type = {
if ((tyconCache eq null) || tyconRunId != currentRunId) {
tyconCache = newTypeRef(Nil)
tyconRunId = currentRunId
}
assert(tyconCache ne null)
tyconCache
}
override def info_=(tp: Type) {
tpePeriod = NoPeriod
tyconCache = null
super.info_=(tp)
}
override def reset(completer: Type) {
super.reset(completer)
tpePeriod = NoPeriod
tyconRunId = NoRunId
}
protected def doCookJavaRawInfo() {
if (isJavaDefined || owner.isJavaDefined) {
val tpe1 = rawToExistential(info)
if (tpe1 ne info) {
setInfo(tpe1)
}
}
}
def cloneSymbolImpl(owner: Symbol): Symbol =
new TypeSymbol(owner, pos, name)
incCounter(typeSymbolCount)
}
class TypeSkolem(initOwner: Symbol, initPos: Position, initName: TypeName, origin: AnyRef)
extends TypeSymbol(initOwner, initPos, initName) {
val level = skolemizationLevel
final override def isSkolem = true
override def deSkolemize = origin match {
case s: Symbol => s
case _ => this
}
override def unpackLocation = origin
override def typeParams = info.typeParams
override def cloneSymbolImpl(owner: Symbol): Symbol =
new TypeSkolem(owner, pos, name, origin)
override def nameString: String =
if (settings.debug.value) (super.nameString + "&" + level)
else super.nameString
}
class ClassSymbol(initOwner: Symbol, initPos: Position, initName: TypeName)
extends TypeSymbol(initOwner, initPos, initName) {
private var source: AbstractFile = null
private var thissym: Symbol = this
final override def isClass = true
final override def isNonClassType = false
final override def isAbstractType = false
final override def isAliasType = false
override def sourceFile =
if (owner.isPackageClass) source
else super.sourceFile
override def sourceFile_=(f: AbstractFile) { source = f }
override def reset(completer: Type) {
super.reset(completer)
thissym = this
}
private var flatname: TypeName = null
override def owner: Symbol =
if (needsFlatClasses) rawowner.owner
else rawowner
override def name: TypeName =
if (needsFlatClasses) {
if (flatname == null)
flatname = flattenName().toTypeName
flatname
}
else rawname.asInstanceOf[TypeName]
private var thisTypeCache: Type = _
private var thisTypePeriod = NoPeriod
private var typeOfThisCache: Type = _
private var typeOfThisPeriod = NoPeriod
override def thisType: Type = {
val period = thisTypePeriod
if (period != currentPeriod) {
thisTypePeriod = currentPeriod
if (!isValid(period)) thisTypeCache = ThisType(this)
}
thisTypeCache
}
override def thisSym: Symbol = thissym
override def typeOfThis: Type = {
if (getFlag(MODULE | IMPLCLASS) == MODULE.toLong && owner != NoSymbol) {
val period = typeOfThisPeriod
if (period != currentPeriod) {
typeOfThisPeriod = currentPeriod
if (!isValid(period))
typeOfThisCache = singleType(owner.thisType, sourceModule)
}
typeOfThisCache
}
else thissym.tpe
}
override def typeOfThis_=(tp: Type) {
thissym = newThisSym(pos).setInfo(tp)
}
override def cloneSymbolImpl(owner: Symbol): Symbol = {
val clone = new ClassSymbol(owner, pos, name)
if (thisSym != this) {
clone.typeOfThis = typeOfThis
clone.thisSym.name = thisSym.name
}
clone
}
override def sourceModule =
if (isModuleClass) companionModule else NoSymbol
private var childSet: Set[Symbol] = Set()
override def children: List[Symbol] = childSet.toList sortBy (_.sealedSortName)
override def addChild(sym: Symbol) { childSet = childSet + sym }
incCounter(classSymbolCount)
}
class ModuleClassSymbol(owner: Symbol, pos: Position, name: TypeName)
extends ClassSymbol(owner, pos, name) {
private var module: Symbol = null
def this(module: TermSymbol) = {
this(module.owner, module.pos, module.name.toTypeName)
setFlag(module.getFlag(ModuleToClassFlags) | MODULE | FINAL)
sourceModule = module
}
override def sourceModule = module
private var implicitMembersCacheValue: List[Symbol] = List()
private var implicitMembersCacheKey: Type = NoType
def implicitMembers: List[Symbol] = {
val tp = info
if (implicitMembersCacheKey ne tp) {
implicitMembersCacheKey = tp
implicitMembersCacheValue = tp.implicitMembers
}
implicitMembersCacheValue
}
override def sourceModule_=(module: Symbol) { this.module = module }
}
object NoSymbol extends Symbol(null, NoPosition, nme.NO_NAME) {
setInfo(NoType)
privateWithin = this
override def info_=(info: Type) {
infos = TypeHistory(1, NoType, null)
unlock()
validTo = currentPeriod
}
override def defString: String = toString
override def locationString: String = ""
override def enclClass: Symbol = this
override def toplevelClass: Symbol = this
override def enclMethod: Symbol = this
override def owner: Symbol = abort("no-symbol does not have owner")
override def sourceFile: AbstractFile = null
override def ownerChain: List[Symbol] = List()
override def ownersIterator: Iterator[Symbol] = Iterator.empty
override def alternatives: List[Symbol] = List()
override def reset(completer: Type) {}
override def info: Type = NoType
override def rawInfo: Type = NoType
protected def doCookJavaRawInfo() {}
override def accessBoundary(base: Symbol): Symbol = RootClass
def cloneSymbolImpl(owner: Symbol): Symbol = abort()
override def originalEnclosingMethod = this
}
def cloneSymbols[T <: Symbol](syms: List[T]): List[T] = {
val syms1 = syms map (_.cloneSymbol.asInstanceOf[T])
for (sym1 <- syms1) sym1.setInfo(sym1.info.substSym(syms, syms1))
syms1
}
def cloneSymbols[T <: Symbol](syms: List[T], owner: Symbol): List[T] = {
val syms1 = syms map (_.cloneSymbol(owner).asInstanceOf[T])
for (sym1 <- syms1) sym1.setInfo(sym1.info.substSym(syms, syms1))
syms1
}
case class CyclicReference(sym: Symbol, info: Type)
extends TypeError("illegal cyclic reference involving " + sym) {
}
case class InvalidCompanions(sym1: Symbol, sym2: Symbol)
extends Throwable("Companions '" + sym1 + "' and '" + sym2 + "' must be defined in same file") {
override def toString = getMessage
}
private sealed case class TypeHistory(var validFrom: Period, info: Type, prev: TypeHistory) {
assert((prev eq null) || phaseId(validFrom) > phaseId(prev.validFrom), this)
assert(validFrom != NoPeriod)
override def toString() =
"TypeHistory(" + phaseOf(validFrom)+":"+runId(validFrom) + "," + info + "," + prev + ")"
}
}
<iframe src="https://xuwei-k.github.io/scala-compiler-sxr/scala-compiler-2.9.1/scala/tools/nsc/symtab/Symbols.scala.html" width="1280" height="720" frameborder="0"> </iframe>