aboutsummaryrefslogtreecommitdiff
path: root/src/dotty
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-04-30 17:49:19 +0200
committerMartin Odersky <odersky@gmail.com>2013-04-30 17:49:19 +0200
commit273873d09c2e0e5080612a7f8a40cab138b41daa (patch)
tree28685f8659033ae5912374014fde0f3ae3ab626e /src/dotty
parent68021907ec042d2e0404e47303c2723bde375f16 (diff)
downloaddotty-273873d09c2e0e5080612a7f8a40cab138b41daa.tar.gz
dotty-273873d09c2e0e5080612a7f8a40cab138b41daa.tar.bz2
dotty-273873d09c2e0e5080612a7f8a40cab138b41daa.zip
Small fixes prompted by last week's code walkthrough.
Diffstat (limited to 'src/dotty')
-rw-r--r--src/dotty/tools/dotc/core/Printers.scala8
-rw-r--r--src/dotty/tools/dotc/core/SymDenotations.scala28
-rw-r--r--src/dotty/tools/dotc/core/Symbols.scala7
3 files changed, 29 insertions, 14 deletions
diff --git a/src/dotty/tools/dotc/core/Printers.scala b/src/dotty/tools/dotc/core/Printers.scala
index 2828ade46..15c2efa4c 100644
--- a/src/dotty/tools/dotc/core/Printers.scala
+++ b/src/dotty/tools/dotc/core/Printers.scala
@@ -303,7 +303,7 @@ object Printers {
/** String representation of symbol's kind. */
def kindString(sym: Symbol): String = {
- val flags = sym.unsafeFlags
+ val flags = sym.flagsUNSAFE
if (flags is PackageClass) "package class"
else if (flags is PackageVal) "package"
else if (sym.isPackageObject)
@@ -329,7 +329,7 @@ object Printers {
/** String representation of symbol's definition key word */
protected def keyString(sym: Symbol): String = {
- val flags = sym.unsafeFlags
+ val flags = sym.flagsUNSAFE
if (flags is JavaInterface) "interface"
else if ((flags is Trait) && !(flags is ImplClass)) "trait"
else if (sym.isClass) "class"
@@ -509,7 +509,7 @@ object Printers {
}
override def kindString(sym: Symbol) = {
- val flags = sym.unsafeFlags
+ val flags = sym.flagsUNSAFE
if (flags is Package) "package"
else if (sym.isPackageObject) "package object"
else if (flags is Module) "object"
@@ -519,7 +519,7 @@ object Printers {
}
override protected def keyString(sym: Symbol): String = {
- val flags = sym.unsafeFlags
+ val flags = sym.flagsUNSAFE
if (sym.isType && (flags is ExpandedTypeParam)) ""
else super.keyString(sym)
}
diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala
index b4cc9091c..bec55720f 100644
--- a/src/dotty/tools/dotc/core/SymDenotations.scala
+++ b/src/dotty/tools/dotc/core/SymDenotations.scala
@@ -84,8 +84,6 @@ object SymDenotations {
final def is(fs: FlagConjunction, butNot: FlagSet) =
(if (fs <= FromStartFlags && butNot <= FromStartFlags) _flags else flags) is (fs, butNot)
- final def unsafeFlags: FlagSet = _flags
-
/** The type info.
* The info is an instance of TypeType iff this is a type denotation
* Uncompleted denotations set _info to a LazyType.
@@ -419,6 +417,16 @@ object SymDenotations {
// ------ access to related symbols ---------------------------------
+ /* Modules and module classes are represented as follows:
+ *
+ * object X extends Y { def f() }
+ *
+ * <module> lazy val X: X$ = new X$
+ * <module> class X$ extends Y { this: X.type => def f() }
+ *
+ * During completion, references to moduleClass and sourceModules are stored in
+ * the completers.
+ */
/** The class implementing this module, NoSymbol if not applicable. */
final def moduleClass: Symbol = _info match {
case info: TypeRefBySym if this is ModuleVal => info.fixedSym
@@ -516,13 +524,18 @@ object SymDenotations {
* in the given class.
* @param inClass The class containing the symbol's definition
* @param site The base type from which member types are computed
+ *
+ * inClass <-- find denot.symbol class C { <-- symbol is here
+ *
+ * site: Subtype of both inClass and C
+ *
*/
final def matchingSymbol(inClass: Symbol, site: Type)(implicit ctx: Context): Symbol = {
var denot = inClass.info.nonPrivateDecl(name)
- if (denot.isTerm) {
+ if (denot.isTerm) { // types of the same name always match
val targetType = site.memberInfo(symbol)
if (denot.isOverloaded)
- denot = denot.atSignature(targetType.signature)
+ denot = denot.atSignature(targetType.signature) // seems we need two kinds of signatures here
if (!(site.memberInfo(denot.symbol) matches targetType))
denot = NoDenotation
}
@@ -531,8 +544,7 @@ object SymDenotations {
/** The symbol, in class `inClass`, that is overridden by this denotation. */
final def overriddenSymbol(inClass: ClassSymbol)(implicit ctx: Context): Symbol =
- if (owner isSubClass inClass) matchingSymbol(inClass, owner.thisType)
- else NoSymbol
+ matchingSymbol(inClass, owner.thisType)
/** All symbols overriden by this denotation. */
final def allOverriddenSymbols(implicit ctx: Context): Iterator[Symbol] =
@@ -648,6 +660,7 @@ object SymDenotations {
/** The info asserted to have type ClassInfo */
def classInfo(implicit ctx: Context): ClassInfo = super.info.asInstanceOf[ClassInfo]
+ /** TODO: Document why caches are supposedly safe to use */
private[this] var _typeParams: List[TypeSymbol] = _
/** The type parameters of this class */
@@ -850,7 +863,7 @@ object SymDenotations {
case _ =>
denots1
}
- case _ =>
+ case nil =>
denots
}
collect(ownDenots, classInfo.classParents)
@@ -862,6 +875,7 @@ object SymDenotations {
private[this] var baseTypeCache: java.util.HashMap[CachedType, Type] = null
private[this] var baseTypeValid: RunId = NoRunId
+ /** Compute tp.baseType(this) */
final def baseTypeOf(tp: Type)(implicit ctx: Context): Type = {
def foldGlb(bt: Type, ps: List[Type]): Type = ps match {
diff --git a/src/dotty/tools/dotc/core/Symbols.scala b/src/dotty/tools/dotc/core/Symbols.scala
index aa829b9e7..728a2b8cc 100644
--- a/src/dotty/tools/dotc/core/Symbols.scala
+++ b/src/dotty/tools/dotc/core/Symbols.scala
@@ -108,7 +108,7 @@ trait Symbols { this: Context =>
name: TermName,
modFlags: FlagSet,
clsFlags: FlagSet,
- infoFn: (TermSymbol, ClassSymbol) => Type,
+ infoFn: (TermSymbol, ClassSymbol) => Type, // typically a ModuleClassCompleterWithDecls
privateWithin: Symbol = NoSymbol,
coord: Coord = NoCoord,
assocFile: AbstractFile = null): TermSymbol
@@ -258,7 +258,7 @@ trait Symbols { this: Context =>
symbol = copy,
owner = treeMap.ownerMap(odenot.owner),
info = treeMap.typeMap(odenot.info),
- privateWithin = ownerMap(odenot.privateWithin),
+ privateWithin = ownerMap(odenot.privateWithin), // since this refers to outer symbols, need not include copies (from->to) in ownermap here.
annotations = odenot.annotations.mapConserve(treeMap.apply))
}
copies
@@ -281,7 +281,7 @@ trait Symbols { this: Context =>
object Symbols {
- var _nextId = 0 // !!! DEBUG
+ var _nextId = 0 // !!! DEBUG, use global counter instead
def nextId = { _nextId += 1; _nextId }
@@ -354,6 +354,7 @@ object Symbols {
/** The source or class file from which this class or
* the class containing this symbol was generated, null if not applicable.
+ * Overridden in ClassSymbol
*/
def associatedFile(implicit ctx: Context): AbstractFile =
denot.topLevelClass.symbol.associatedFile