aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-01-28 15:55:33 +0100
committerMartin Odersky <odersky@gmail.com>2013-01-28 15:55:33 +0100
commit0aac7396c3eda56375c15568b81f48262d47d35b (patch)
tree765f19657ff4d2113d93e6b8553dc95605b23af0 /src/dotty/tools/dotc
parent9a8a439d059b52d37b317059e66d04ccced1d05c (diff)
downloaddotty-0aac7396c3eda56375c15568b81f48262d47d35b.tar.gz
dotty-0aac7396c3eda56375c15568b81f48262d47d35b.tar.bz2
dotty-0aac7396c3eda56375c15568b81f48262d47d35b.zip
Consolidation of Symbols
Diffstat (limited to 'src/dotty/tools/dotc')
-rw-r--r--src/dotty/tools/dotc/core/Denotations.scala2
-rw-r--r--src/dotty/tools/dotc/core/Flags.scala2
-rw-r--r--src/dotty/tools/dotc/core/SymDenotations.scala95
-rw-r--r--src/dotty/tools/dotc/core/Symbols.scala140
-rw-r--r--src/dotty/tools/dotc/core/TypeComparers.scala2
-rw-r--r--src/dotty/tools/dotc/core/TypeOps.scala4
-rw-r--r--src/dotty/tools/dotc/core/Types.scala44
7 files changed, 194 insertions, 95 deletions
diff --git a/src/dotty/tools/dotc/core/Denotations.scala b/src/dotty/tools/dotc/core/Denotations.scala
index 12b522427..461ef2f17 100644
--- a/src/dotty/tools/dotc/core/Denotations.scala
+++ b/src/dotty/tools/dotc/core/Denotations.scala
@@ -175,7 +175,7 @@ object Denotations {
else if (denot1.signature == denot2.signature) {
def isEligible(sym1: Symbol, sym2: Symbol) =
if (sym1.isType) !sym1.isClass
- else sym1.isConcrete || sym2.isDeferred || !sym2.exists
+ else !(sym1 is Deferred) || (sym2 is Deferred) || !sym2.exists
def normalize(info: Type) =
if (isType) info.bounds else info
val sym1 = denot1.symbol
diff --git a/src/dotty/tools/dotc/core/Flags.scala b/src/dotty/tools/dotc/core/Flags.scala
index 0e995f756..5f400a3c8 100644
--- a/src/dotty/tools/dotc/core/Flags.scala
+++ b/src/dotty/tools/dotc/core/Flags.scala
@@ -167,6 +167,8 @@ object Flags {
/** A declared, but not defined member */
final val Deferred = commonFlag(5, "<deferred>")
+ final val DeferredTerm = Deferred.toTermFlags
+ final val DeferredType = Deferred.toTypeFlags
/** Labeled with `final` modifier */
final val Final = commonFlag(6, "final")
diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala
index fd8f686b4..7600ff0e4 100644
--- a/src/dotty/tools/dotc/core/SymDenotations.scala
+++ b/src/dotty/tools/dotc/core/SymDenotations.scala
@@ -103,14 +103,14 @@ object SymDenotations {
(o eq sym)
}
- def withType(tp: Type): SymDenotation = ???
+// def withType(tp: Type): SymDenotation = ???
override protected def copy(s: Symbol, i: Type): SingleDenotation = new UniqueRefDenotation(s, i, validFor)
def moduleClass(implicit ctx: Context): Symbol =
if (this.isModuleObj) info.typeSymbol else NoSymbol
- /** Desire to re-use the field in ClassSymbol which stores the source
+ /** Desire to re-use the field in ClassSymbol which stores the source
* file to also store the classfile, but without changing the behavior
* of sourceFile (which is expected at least in the IDE only to
* return actual source code.) So sourceFile has classfiles filtered out.
@@ -140,6 +140,11 @@ object SymDenotations {
info.isVolatile && !hasAnnotation(defn.uncheckedStableClass)
)
+ def isStatic(implicit ctx: Context) = (this is Static) || owner.isStaticOwner
+
+ final def isStaticOwner(implicit ctx: Context): Boolean =
+ (this is PackageClass) || (this is ModuleClass) && isStatic
+
final def matchingSymbol(inClass: Symbol, site: Type)(implicit ctx: Context): Symbol = {
var denot = inClass.info.nonPrivateDecl(name)
if (denot.isTerm) {
@@ -159,8 +164,7 @@ object SymDenotations {
final def allOverriddenSymbols(implicit ctx: Context): Iterator[Symbol] =
info.baseClasses.tail.iterator map overriddenSymbol filter (_.exists)
- /** Is this symbol defined in the same scope and compilation unit as `that` symbol? */
- private def isCoDefinedWith(that: Symbol)(implicit ctx: Context) =
+ def isCoDefinedWith(that: Symbol)(implicit ctx: Context) =
(this.owner == that.owner) &&
( !(this.owner.isPackageClass)
|| (this.sourceFile == null)
@@ -169,11 +173,16 @@ object SymDenotations {
|| (this.sourceFile.canonicalPath == that.sourceFile.canonicalPath)
)
- def companionModule(implicit ctx: Context): Symbol =
- owner.info.decl(name.toTermName).filter(_.isModule).symbol
+ def companionModule(implicit ctx: Context): Symbol = {
+ owner.info.decl(name.toTermName)
+ .filter(sym => sym.isModule && sym.isCoDefinedWith(symbol))
+ .symbol
+ }
def companionClass(implicit ctx: Context): Symbol =
- owner.info.decl(name.toTypeName).filter(_.isClass).symbol
+ owner.info.decl(name.toTypeName)
+ .filter(sym => sym.isClass && sym.isCoDefinedWith(symbol))
+ .symbol
def linkedClass(implicit ctx: Context): Symbol =
if (this.isModuleClass) companionClass
@@ -239,7 +248,7 @@ object SymDenotations {
cls.isModuleClass &&
pre.widen.typeSymbol.isSubClassOrCompanion(cls.linkedClass)))
fail(() =>
- s"""Access to protected $show not permitted because
+ s"""Access to protected ${symbol.show} not permitted because
|prefix type ${pre.widen.show} does not conform to
|${cls.showLocated} where the access takes place""".stripMargin)
else true
@@ -249,7 +258,7 @@ object SymDenotations {
val boundary = accessBoundary(owner)
( (boundary.isTerm
- || (boundary eq defn.RootClass))
+ || (boundary.isRoot))
|| (accessWithin(boundary) || accessWithinLinked(boundary)) &&
( !(this is Local)
|| (owner is ImplClass) // allow private local accesses to impl class members
@@ -268,8 +277,27 @@ object SymDenotations {
def isNonValueClass(implicit ctx: Context): Boolean =
isClass && !isSubClass(defn.AnyValClass)
- def show(implicit ctx: Context): String = ???
- def showLocated(implicit ctx: Context): String = ???
+ def typeParams: List[TypeSymbol] = unsupported("typeParams")
+
+ def thisType(implicit ctx: Context): Type = unsupported("thisType")
+
+ def typeConstructor(implicit ctx: Context): Type =
+ TypeRef(owner.thisType, name.asTypeName)
+
+ def variance: Int =
+ if (this is Covariant) 1
+ else if (this is Contravariant) -1
+ else 0
+
+ def isRoot: Boolean = !owner.exists // !!! && name == tpnme.Root
+
+ def copy(
+ sym: Symbol,
+ owner: Symbol = this.owner,
+ name: Name = this.name,
+ initFlags: FlagSet = this.flags,
+ info: Type = this.info) =
+ new CompleteSymDenotation(sym, owner, name, initFlags, info)
}
trait isComplete extends SymDenotation {
@@ -334,6 +362,8 @@ object SymDenotations {
def parents: List[TypeRef]
+ def selfType: Type
+
def decls: Scope
val info = ClassInfo(owner.thisType, this)
@@ -342,7 +372,7 @@ object SymDenotations {
private[this] var _typeParams: List[TypeSymbol] = _
- final def typeParams: List[TypeSymbol] = {
+ override final def typeParams: List[TypeSymbol] = {
val tparams = _typeParams
if (tparams != null) tparams else computeTypeParams
}
@@ -359,20 +389,25 @@ object SymDenotations {
memberCacheVar
}
- private[this] var thisTypeCache: ThisType = null
+ private[this] var _thisType: Type = null
- def thisType(implicit ctx: Context): Type = {
- if (thisTypeCache == null)
- thisTypeCache = ThisType(symbol)
- thisTypeCache
+ override def thisType(implicit ctx: Context): Type = {
+ if (_thisType == null) _thisType = computeThisType
+ _thisType
}
- private[this] var typeConstructorCache: Type = null
+ // todo: apply same scheme to static objects/all objects?
+ private def computeThisType: Type =
+ if ((this is PackageClass) && !isRoot)
+ TermRef(owner.thisType, name.toTermName)
+ else
+ ThisType(symbol)
- def typeConstructor(implicit ctx: Context): Type = {
- if (typeConstructorCache == null)
- typeConstructorCache = NamedType(thisType, symbol.name)
- typeConstructorCache
+ private[this] var _typeConstructor: Type = null
+
+ override def typeConstructor(implicit ctx: Context): Type = {
+ if (_typeConstructor == null) _typeConstructor = super.typeConstructor
+ _typeConstructor
}
/*
@@ -538,7 +573,7 @@ object SymDenotations {
else reduce(NoType, classd.parents).substThis(classd.symbol, tp.prefix)
}
- if (symbol.isStaticMono) symbol.typeConstructor
+ if (symbol.isStatic) symbol.typeConstructor
else tp match {
case tp: CachedType =>
if (baseTypeValid != ctx.runId) {
@@ -573,6 +608,17 @@ object SymDenotations {
memberNamesCache += (keepOnly -> names)
names
}
+
+ def copyClass(
+ sym: ClassSymbol,
+ owner: Symbol = this.owner,
+ name: Name = this.name,
+ initFlags: FlagSet = this.flags,
+ parents: List[TypeRef] = this.parents,
+ selfType: Type = this.selfType,
+ decls: Scope = this.decls,
+ assocFile: AbstractFile = this.assocFile) =
+ new CompleteClassDenotation(sym, owner, name, initFlags, parents, selfType, decls, assocFile)
}
class CompleteClassDenotation(
@@ -581,6 +627,7 @@ object SymDenotations {
val name: Name,
initFlags: FlagSet,
val parents: List[TypeRef],
+ val selfType: Type,
val decls: Scope,
assocFile: AbstractFile = null
)(implicit ctx: Context) extends ClassDenotation(initFlags, assocFile) with isComplete {
@@ -596,9 +643,11 @@ object SymDenotations {
)(implicit ctx: Context) extends ClassDenotation(initFlags, assocFile) with isLazy {
protected var _parents: List[TypeRef] = null
+ protected var _selfType: Type = null
protected var _decls: Scope = null
final def parents: List[TypeRef] = { ensureCompleted(); _parents }
+ final def selfType: Type = { ensureCompleted(); _selfType }
final def decls: Scope = { ensureCompleted(); _decls }
final def preCompleteDecls = {ensureLoaded(); _decls }
}
diff --git a/src/dotty/tools/dotc/core/Symbols.scala b/src/dotty/tools/dotc/core/Symbols.scala
index 84ffc53a7..fc971b686 100644
--- a/src/dotty/tools/dotc/core/Symbols.scala
+++ b/src/dotty/tools/dotc/core/Symbols.scala
@@ -20,7 +20,9 @@ object Symbols {
/** A Symbol represents a Scala definition/declaration or a package.
*/
- abstract class Symbol(denotf: Symbol => SymDenotation) {
+ abstract class Symbol(denotf: Symbol => SymDenotation) extends DotClass {
+
+ type Name <: Names.Name
/** Is symbol different from NoSymbol? */
def exists = true
@@ -33,16 +35,30 @@ object Symbols {
/** The last denotation of this symbol */
private[this] var lastDenot: SymDenotation = denotf(this)
+ /** The current denotation of this symbol */
final def denot(implicit ctx: Context): SymDenotation = {
var denot = lastDenot
if (!(denot.validFor contains ctx.period)) denot = denot.current.asInstanceOf[SymDenotation]
denot
}
+ /** Subclass tests and casts */
def isType: Boolean = false
def isTerm: Boolean = false
def isClass: Boolean = false
+ def asTerm: TermSymbol = asInstanceOf[TermSymbol]
+ def asType: TypeSymbol = asInstanceOf[TypeSymbol]
+ def asClass: ClassSymbol = asInstanceOf[ClassSymbol]
+
+ /** A unique, densely packed integer tag for each class symbol, -1
+ * for all other symbols. To save memory, this method
+ * should be called only if class is a super class of some other class.
+ */
+ def superId: Int = -1
+
+// --------- Forwarders for sym methods --------------------------
+
/** Special case tests for flags that are known a-priori and do not need loading
* flags.
*/
@@ -53,19 +69,11 @@ object Symbols {
def isPackageObj(implicit ctx: Context) = denot.isPackageObj
def isPackageClass(implicit ctx: Context) = denot.isPackageClass
- /** A unique, densely packed integer tag for each class symbol, -1
- * for all other symbols. To save memory, this method
- * should be called only if class is a super class of some other class.
- */
- def superId: Int = -1
-
-// --------- Forwarders for sym methods --------------------------
-
/** The current owner of this symbol */
final def owner(implicit ctx: Context): Symbol = denot.owner
/** The current name of this symbol */
- final def name(implicit ctx: Context): Name = denot.name
+ final def name(implicit ctx: Context): Name = denot.name.asInstanceOf[Name]
/** The current type info of this symbol */
final def info(implicit ctx: Context): Type = denot.info
@@ -96,14 +104,34 @@ object Symbols {
/** The package containing this symbol */
def enclosingPackage(implicit ctx: Context): Symbol = denot.enclosingPackage
+ /** The source or class file from which this symbol was generated, null if not applicable. */
final def associatedFile(implicit ctx: Context): AbstractFile = denot.associatedFile
+
+ /** The class file from which this symbol was generated, null if not applicable. */
final def binaryFile(implicit ctx: Context): AbstractFile = denot.binaryFile
+
+ /** The source or class file from which this symbol was generated, null if not applicable. */
final def sourceFile(implicit ctx: Context): AbstractFile = denot.sourceFile
+ /** Is this symbol defined in the same compilation unit as that symbol? */
+ final def isCoDefinedWith(that: Symbol)(implicit ctx: Context): Boolean = denot.isCoDefinedWith(that)
+
+ /** The class with the same (type-) name as this module or module class,
+ * which is the defined in the same compilation unit.
+ * NoSymbol if this class does not exist.
+ */
final def companionClass(implicit ctx: Context): Symbol = denot.companionClass
+ /** The module object with the same (term-) name as this class or module class,
+ * which is the defined in the same compilation unit.
+ * NoSymbol if this class does not exist.
+ */
final def companionModule(implicit ctx: Context): Symbol = denot.companionModule
+ /** If this is a class, the module class of its companion object.
+ * If this is a module class, its companion class.
+ * NoSymbol otherwise.
+ */
final def linkedClass(implicit ctx: Context): Symbol = denot.linkedClass
/** Is this symbol a subclass of the given class? */
@@ -168,66 +196,84 @@ object Symbols {
def showLocated(implicit ctx: Context): String = ctx.printer.showLocated(this)
def showDef(implicit ctx: Context): String = ctx.printer.showDef(this)
- def typeParams: List[TypeSymbol] = ???
- def unsafeTypeParams: List[TypeSymbol] = ???
- def thisType: Type = ???
- def isStaticMono = isStatic && typeParams.isEmpty
- def isRoot: Boolean = ???
- def moduleClass: Symbol = ???
- def cloneSymbol: Symbol = ???
- def hasAnnotation(ann: Annotation): Boolean = ???
- def hasAnnotation(ann: ClassSymbol): Boolean = ???
-
- def asTerm: TermSymbol = ???
- def asType: TypeSymbol = ???
- def asClass: ClassSymbol = ???
- def isStatic: Boolean = ???
- def isTypeParameter: Boolean = ???
- def isOverridable: Boolean = ???
- def isCovariant: Boolean = ???
- def isContravariant: Boolean = ???
- def isSkolem: Boolean = ???
- def isDeferred: Boolean = ???
- def isConcrete = !isDeferred
- def isJava: Boolean = ???
-
- def isAbstractType: Boolean = ???
- def newAbstractType(name: TypeName, info: TypeBounds): TypeSymbol = ???
- def newAbstractTerm(name: TermName, tpe: Type): TypeSymbol = ???
+ /** The type parameters of a class symbol, Nil for all other symbols */
+ def typeParams(implicit ctx: Context): List[TypeSymbol] = denot.typeParams
- //def isMethod(implicit ctx: Context): Boolean = denot.isMethod
+ /** The type This(cls), where cls is this class symbol */
+ def thisType(implicit ctx: Context): Type = denot.thisType
+ /** Is this symbol the root class or its companion object? */
+ def isRoot(implicit ctx: Context): Boolean = denot.isRoot
+
+ /** If this is a module symbol, the class defining its template, otherwise NoSymbol. */
+ def moduleClass(implicit ctx: Context): Symbol = denot.moduleClass
+
+ /** A copy of this symbol with the same denotation */
+ def copy(implicit ctx: Context): Symbol = unsupported("copy")
+
+ /** A copy of this symbol with the same denotation but a new owner */
+ def copy(owner: Symbol)(implicit ctx: Context): Symbol = unsupported("copy")
+
+ /** Can a term with this symbol be a stable value? */
def isStable(implicit ctx: Context): Boolean = denot.isStable
+ /** Is this symbol static (i.e. with no outer instance)? */
+ def isStatic(implicit ctx: Context): Boolean = denot.isStatic
+
+ /** Does this symbol denote a class that defines static symbols? */
+ final def isStaticOwner(implicit ctx: Context): Boolean = denot.isStaticOwner
+
+// def isOverridable: Boolean = !!! need to enforce that classes cannot be redefined
+
+// def isSkolem: Boolean = ???
+
+// def isAbstractType: Boolean = ???
+// def newAbstractType(name: TypeName, info: TypeBounds): TypeSymbol = ???
+// def newAbstractTerm(name: TermName, tpe: Type): TypeSymbol = ???
+
+ //def isMethod(implicit ctx: Context): Boolean = denot.isMethod
+
+
}
- abstract class TermSymbol(denotf: Symbol => SymDenotation) extends Symbol(denotf) {
- def name: TermName
+ class TermSymbol(denotf: Symbol => SymDenotation) extends Symbol(denotf) {
+ type Name = TermName
override def isTerm = true
+ override def copy(implicit ctx: Context): TermSymbol = copy(owner)
+ override def copy(owner: Symbol)(implicit ctx: Context): TermSymbol = new TermSymbol(denot.copy(_, owner))
}
- abstract class TypeSymbol(denotf: Symbol => SymDenotation) extends Symbol(denotf) {
- def name: TypeName
+ class TypeSymbol(denotf: Symbol => SymDenotation) extends Symbol(denotf) {
+ type Name = TypeName
override def isType = true
+ override def copy(implicit ctx: Context): TypeSymbol = copy(owner)
+ override def copy(owner: Symbol)(implicit ctx: Context): TypeSymbol = new TypeSymbol(denot.copy(_, owner))
- def variance: Int = ???
+ /** The type representing the type constructor for this type symbol */
+ def typeConstructor(implicit ctx: Context): Type = denot.typeConstructor
- def typeConstructor(implicit ctx: Context): Type = ???
- def typeTemplate(implicit ctx: Context): Type = ???
+ /** The variance of this type parameter as an Int, with
+ * +1 = Covariant, -1 = Contravariant, 0 = Nonvariant
+ */
+ def variance(implicit ctx: Context): Int = denot.variance
}
- abstract class ClassSymbol(denotf: Symbol => ClassDenotation) extends TypeSymbol(denotf) {
+ class ClassSymbol(denotf: ClassSymbol => ClassDenotation) extends TypeSymbol(s => denotf(s.asClass)) {
override def isClass = true
+ override def copy(implicit ctx: Context): ClassSymbol = copy(owner)
+ override def copy(owner: Symbol)(implicit ctx: Context): ClassSymbol = new ClassSymbol(classDenot.copyClass(_, owner))
private var superIdHint: Int = -1
final def classDenot(implicit ctx: Context): ClassDenotation =
denot.asInstanceOf[ClassDenotation]
- def typeOfThis(implicit ctx: Context): Type = ???
+ def selfType(implicit ctx: Context): Type = classDenot.selfType
+ /** The base classes of this class in linearization order,
+ * with the class itself as first element.x
+ */
def baseClasses(implicit ctx: Context): List[ClassSymbol] = classDenot.baseClasses
- override def typeConstructor(implicit ctx: Context): Type = classDenot.typeConstructor
// override def typeTemplate(implicit ctx: Context): Type = classDenot.typeTemplate
def superId(implicit ctx: Context): Int = {
diff --git a/src/dotty/tools/dotc/core/TypeComparers.scala b/src/dotty/tools/dotc/core/TypeComparers.scala
index be4c0b99c..5c32432d7 100644
--- a/src/dotty/tools/dotc/core/TypeComparers.scala
+++ b/src/dotty/tools/dotc/core/TypeComparers.scala
@@ -77,7 +77,7 @@ object TypeComparers {
||
tp1.name == tp2.name &&
isSubType(pre1, pre2) &&
- (sym2.isAbstractType || isSubType(pre2, pre1)) // ???
+ (sym2.info.isRealTypeBounds || isSubType(pre2, pre1)) // ???
||
(sym2.isClass) && {
val base = tp1.baseType(sym2)
diff --git a/src/dotty/tools/dotc/core/TypeOps.scala b/src/dotty/tools/dotc/core/TypeOps.scala
index 25c8625ec..5e25ab4a9 100644
--- a/src/dotty/tools/dotc/core/TypeOps.scala
+++ b/src/dotty/tools/dotc/core/TypeOps.scala
@@ -1,6 +1,6 @@
package dotty.tools.dotc.core
-import Contexts._, Types._, Symbols._, Names._
+import Contexts._, Types._, Symbols._, Names._, Flags._
trait TypeOps { this: Context =>
@@ -31,7 +31,7 @@ trait TypeOps { this: Context =>
if (pre1 eq pre0) tp
else {
val tp1 = NamedType(pre1, tp.name)
- if (sym.isTypeParameter) {
+ if (sym is TypeParam) {
// short-circuit instantiated type parameters
// by replacing pre.tp with its alias, if it has one.
val tp2 = tp1.info
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala
index ee9e881ad..dcef49d0d 100644
--- a/src/dotty/tools/dotc/core/Types.scala
+++ b/src/dotty/tools/dotc/core/Types.scala
@@ -198,9 +198,9 @@ object Types {
final def subst(from: BindingType, to: BindingType)(implicit ctx: Context): Type =
ctx.subst(this, from, to, null)
- /** Substitute all occurrences of `This(clazz)` by `tp` */
- final def substThis(clazz: ClassSymbol, tp: Type)(implicit ctx: Context): Type =
- ctx.substThis(this, clazz, tp, null)
+ /** Substitute all occurrences of `This(cls)` by `tp` */
+ final def substThis(cls: ClassSymbol, tp: Type)(implicit ctx: Context): Type =
+ ctx.substThis(this, cls, tp, null)
/** Substitute all occurrences of `RefinedThis(rt)` by `tp` */
final def substThis(rt: RefinedType, tp: Type)(implicit ctx: Context): Type =
@@ -378,9 +378,9 @@ object Types {
//def resultType: Type = ???
- /** The base classes of this type as determined by ClassDenotation.
- * Inherited by all type proxies.
- * `Nil` for all other types.
+ /** The base classes of this type as determined by ClassDenotation
+ * in linearization order, with the class itself as first element.
+ * Inherited by all type proxies. `Nil` for all other types.
*/
final def baseClasses(implicit ctx: Context): List[ClassSymbol] = this match {
case tp: TypeProxy =>
@@ -390,11 +390,11 @@ object Types {
case _ => Nil
}
- final def asSeenFrom(pre: Type, clazz: Symbol)(implicit ctx: Context): Type =
- if (clazz.isStaticMono ||
- ctx.erasedTypes && clazz != defn.ArrayClass ||
- (pre eq clazz.thisType)) this
- else ctx.asSeenFrom(this, pre, clazz, null)
+ final def asSeenFrom(pre: Type, cls: Symbol)(implicit ctx: Context): Type =
+ if ((cls is PackageClass) ||
+ ctx.erasedTypes && cls != defn.ArrayClass ||
+ (pre eq cls.thisType)) this
+ else ctx.asSeenFrom(this, pre, cls, null)
/** The signature of this type. This is by default NullSignature,
* but is overridden for PolyTypes, MethodTypes, and TermRefWithSignature types.
@@ -564,8 +564,8 @@ object Types {
private[this] var lastDenotation: Denotation = null
- private def checkPrefix(sym: Symbol) =
- sym.isAbstractType || sym.isClass
+ private def checkPrefix(denot: Denotation) =
+ denot.info.isRealTypeBounds || denot.symbol.isClass
/** The denotation currently denoted by this type */
def denot(implicit ctx: Context): Denotation = {
@@ -579,7 +579,7 @@ object Types {
} else {
val d = loadDenot
if (d.exists || ctx.phaseId == FirstPhaseId) {
- if (checkPrefix(d.symbol) && !prefix.isLegalPrefix)
+ if (checkPrefix(d) && !prefix.isLegalPrefix)
throw new MalformedType(prefix, d.symbol)
d
} else {// name has changed; try load in earlier phase and make current
@@ -661,16 +661,18 @@ object Types {
// --- Other SingletonTypes: ThisType/SuperType/ConstantType ---------------------------
- abstract case class ThisType(clazz: ClassSymbol) extends CachedProxyType with SingletonType {
- override def underlying(implicit ctx: Context) = clazz.typeOfThis
- override def computeHash = doHash(clazz)
+ abstract case class ThisType(cls: ClassSymbol) extends CachedProxyType with SingletonType {
+ override def underlying(implicit ctx: Context) = cls.selfType
+ override def computeHash = doHash(cls)
}
- final class CachedThisType(clazz: ClassSymbol) extends ThisType(clazz)
+ final class CachedThisType(cls: ClassSymbol) extends ThisType(cls)
object ThisType {
- def apply(clazz: ClassSymbol)(implicit ctx: Context) =
- unique(new CachedThisType(clazz))
+ def apply(cls: ClassSymbol)(implicit ctx: Context) = {
+ assert(!(cls is PackageClass) || cls.isRoot)
+ unique(new CachedThisType(cls))
+ }
}
abstract case class SuperType(thistpe: Type, supertpe: Type) extends CachedProxyType with SingletonType {
@@ -1116,7 +1118,7 @@ object Types {
/** A filter for names of deferred term definitions of a given type */
object abstractTermNameFilter extends NameFilter {
def apply(pre: Type, name: Name)(implicit ctx: Context): Boolean =
- name.isTermName && (pre member name).symbol.isDeferred
+ name.isTermName && ((pre member name).symbol is Deferred)
}
// ----- Exceptions -------------------------------------------------------------