aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/SymDenotations.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-08-19 16:19:03 +0200
committerMartin Odersky <odersky@gmail.com>2013-08-19 16:19:03 +0200
commit62131749d08657a0103c922c626a0b918cf385b5 (patch)
treee8c49a9bb6eb41f3f5d4e3ca7e75a431a25c33b9 /src/dotty/tools/dotc/core/SymDenotations.scala
parentedb9facac55f61540e0f9af8d06ac9390830fcb8 (diff)
downloaddotty-62131749d08657a0103c922c626a0b918cf385b5.tar.gz
dotty-62131749d08657a0103c922c626a0b918cf385b5.tar.bz2
dotty-62131749d08657a0103c922c626a0b918cf385b5.zip
Several fixes and refactorings for typechecking
1) Refactoring of package loaders that ensures that a package is always loaded before new members are entered. This led to a refactoring of sourceModule in completers into its own trait 2) Refactoring of optSelfType ot selfInfo. Class Infos may now have a reference to a symbol in their selfInfo field, instead of always a type, as it was before. This allows to introduce laziness for self type evaluation. Laziness is needed so that modules can be desugared and the desugared version be compiled without special tricks. 3) <init> and $init members are no longer inherited. 4) Refactoring of createSymbol and enterSym, so that creating symbols and entering them in a scope is decoupled. Renamed the driver operation form `enterSym(s)` to `index`.
Diffstat (limited to 'src/dotty/tools/dotc/core/SymDenotations.scala')
-rw-r--r--src/dotty/tools/dotc/core/SymDenotations.scala26
1 files changed, 21 insertions, 5 deletions
diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala
index 91f157e2c..16dab0df8 100644
--- a/src/dotty/tools/dotc/core/SymDenotations.scala
+++ b/src/dotty/tools/dotc/core/SymDenotations.scala
@@ -106,7 +106,7 @@ object SymDenotations {
if ((this is ModuleClass) && !(this is PackageClass))
tp match {
case ClassInfo(_, _, _, _, ost) =>
- assert(ost.isInstanceOf[TermRef], tp)
+ assert(ost.isInstanceOf[TermRef] || ost.isInstanceOf[TermSymbol], tp)
case _ =>
}
myInfo = tp
@@ -162,6 +162,17 @@ object SymDenotations {
case _ => info.decls
}
+ /** If this is a package class, the symbols entered in it
+ * before it is completed. (this is needed to eagerly enter synthetic
+ * aliases such as AnyRef into a package class without forcing it.
+ * Right now, I believe the only usage is for the three synthetic aliases
+ * in Definitions.
+ */
+ final def preDecls(implicit ctx: Context): MutableScope = myInfo match {
+ case pinfo: SymbolLoaders # PackageLoader => pinfo.preDecls
+ case _ => decls.asInstanceOf[MutableScope]
+ }
+
// ------ Names ----------------------------------------------
/** The name with which the denoting symbol was created */
@@ -451,7 +462,7 @@ object SymDenotations {
final def sourceModule: Symbol = myInfo match {
case ClassInfo(_, _, _, _, selfType: TermRefBySym) if this is ModuleClass =>
selfType.fixedSym
- case info: ClassCompleterWithDecls =>
+ case info: ModuleClassCompleter =>
info.sourceModule
case _ =>
NoSymbol
@@ -909,7 +920,8 @@ object SymDenotations {
case nil =>
denots
}
- collect(ownDenots, classParents)
+ if (name.isConstructorName) ownDenots
+ else collect(ownDenots, classParents)
} else NoDenotation
override final def findMember(name: Name, pre: Type, excluded: FlagSet)(implicit ctx: Context): Denotation =
@@ -1044,20 +1056,24 @@ object SymDenotations {
def apply(module: TermSymbol, modcls: ClassSymbol) = this
}
+ /** A base type for completers of module classes that knows about `sourceModule` */
+ trait ModuleClassCompleter extends LazyType {
+ def sourceModule: Symbol
+ }
+
/** A lazy type for completing a class that already has a scope with all
* declarations in the class.
*/
class ClassCompleterWithDecls(val decls: Scope, underlying: LazyType = NoCompleter)
extends LazyType {
def complete(denot: SymDenotation): Unit = underlying.complete(denot)
- def sourceModule: Symbol = NoSymbol
}
/** A lazy type for completing a class that already has a scope with all
* declarations in the class.
*/
class ModuleClassCompleterWithDecls(module: Symbol, decls: Scope, underlying: LazyType = NoCompleter)
- extends ClassCompleterWithDecls(decls, underlying) {
+ extends ClassCompleterWithDecls(decls, underlying) with ModuleClassCompleter {
override def sourceModule = module
}