aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-08-19 20:59:21 +0200
committerMartin Odersky <odersky@gmail.com>2013-08-19 21:02:09 +0200
commit9113c243875cd7f6c8ae6774834ea9a0a468acbc (patch)
treee1019b248a9c45c19015c186a24b03820e8b0ba8 /src/dotty/tools/dotc
parent36de1429027f635fe7035cf217b944bfc67dcc2c (diff)
downloaddotty-9113c243875cd7f6c8ae6774834ea9a0a468acbc.tar.gz
dotty-9113c243875cd7f6c8ae6774834ea9a0a468acbc.tar.bz2
dotty-9113c243875cd7f6c8ae6774834ea9a0a468acbc.zip
Some additions to module completion
… more to come. Plus some bugfixes.
Diffstat (limited to 'src/dotty/tools/dotc')
-rw-r--r--src/dotty/tools/dotc/Driver.scala3
-rw-r--r--src/dotty/tools/dotc/ast/Desugar.scala2
-rw-r--r--src/dotty/tools/dotc/core/SymDenotations.scala24
-rw-r--r--src/dotty/tools/dotc/core/SymbolLoaders.scala2
-rw-r--r--src/dotty/tools/dotc/core/Symbols.scala9
-rw-r--r--src/dotty/tools/dotc/core/pickling/UnPickler.scala4
-rw-r--r--src/dotty/tools/dotc/typer/Typer.scala1
7 files changed, 25 insertions, 20 deletions
diff --git a/src/dotty/tools/dotc/Driver.scala b/src/dotty/tools/dotc/Driver.scala
index a175b8bc4..687cad2f2 100644
--- a/src/dotty/tools/dotc/Driver.scala
+++ b/src/dotty/tools/dotc/Driver.scala
@@ -28,9 +28,8 @@ abstract class Driver extends DotClass {
!ctx.reporter.hasErrors
} catch {
case ex: Throwable =>
- ctx.error(ex.getMessage)
ex match {
- case ex: FatalError => false // signals that we should fail compilation.
+ case ex: FatalError => ctx.error(ex.getMessage); false // signals that we should fail compilation.
case _ => throw ex // unexpected error, tell the outside world.
}
}
diff --git a/src/dotty/tools/dotc/ast/Desugar.scala b/src/dotty/tools/dotc/ast/Desugar.scala
index 9f1fbe446..047a60814 100644
--- a/src/dotty/tools/dotc/ast/Desugar.scala
+++ b/src/dotty/tools/dotc/ast/Desugar.scala
@@ -225,7 +225,7 @@ object desugar {
val modul = ValDef(mods | ModuleCreationFlags, name, clsRef, New(clsRef, Nil)) withPos mdef.pos
val ValDef(selfMods, selfName, selfTpt, selfRhs) = self
if (!selfTpt.isEmpty) ctx.error("object definition may not have a self type", self.pos)
- val clsSelf = ValDef(selfMods, selfName, SingletonTypeTree(clsRef), selfRhs)
+ val clsSelf = ValDef(selfMods, selfName, SingletonTypeTree(Ident(name)), selfRhs)
.withPos(self.pos orElse tmpl.pos.startPos)
val clsTmpl = cpy.Template(tmpl, constr, parents, clsSelf, body)
val cls = TypeDef(mods.toTypeFlags & AccessFlags | ModuleClassCreationFlags, clsName, clsTmpl)
diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala
index 16dab0df8..789f320bb 100644
--- a/src/dotty/tools/dotc/core/SymDenotations.scala
+++ b/src/dotty/tools/dotc/core/SymDenotations.scala
@@ -453,16 +453,19 @@ object SymDenotations {
myInfo match {
case info: TypeRefBySym => info.fixedSym
case ExprType(info: TypeRefBySym) => info.fixedSym // needed after uncurry, when module terms might be accessor defs
- case info: ModuleCompleter => info.mclass
- case _ => NoSymbol
+ case info: LazyTypeOfModule => info.moduleClass
+ case _ => println(s"missing module class for $name: $myInfo"); NoSymbol
}
- else NoSymbol
+ else {
+ println(s"missing module class for non-module $name");
+ NoSymbol
+ }
/** The module implemented by this module class, NoSymbol if not applicable. */
final def sourceModule: Symbol = myInfo match {
case ClassInfo(_, _, _, _, selfType: TermRefBySym) if this is ModuleClass =>
selfType.fixedSym
- case info: ModuleClassCompleter =>
+ case info: LazyTypeOfModuleClass =>
info.sourceModule
case _ =>
NoSymbol
@@ -1057,10 +1060,14 @@ object SymDenotations {
}
/** A base type for completers of module classes that knows about `sourceModule` */
- trait ModuleClassCompleter extends LazyType {
+ trait LazyTypeOfModuleClass extends LazyType {
def sourceModule: Symbol
}
+ trait LazyTypeOfModule extends LazyType {
+ def moduleClass: Symbol
+ }
+
/** A lazy type for completing a class that already has a scope with all
* declarations in the class.
*/
@@ -1073,7 +1080,7 @@ object SymDenotations {
* declarations in the class.
*/
class ModuleClassCompleterWithDecls(module: Symbol, decls: Scope, underlying: LazyType = NoCompleter)
- extends ClassCompleterWithDecls(decls, underlying) with ModuleClassCompleter {
+ extends ClassCompleterWithDecls(decls, underlying) with LazyTypeOfModuleClass {
override def sourceModule = module
}
@@ -1087,7 +1094,8 @@ object SymDenotations {
* Completion of modules is always completion of the underlying
* module class, followed by copying the relevant fields to the module.
*/
- class ModuleCompleter(val mclass: ClassSymbol)(implicit cctx: CondensedContext) extends LazyType {
+ class ModuleCompleter(override val moduleClass: ClassSymbol)(implicit cctx: CondensedContext)
+ extends LazyTypeOfModule {
def complete(denot: SymDenotation): Unit = {
val from = denot.moduleClass.denot.asClass
denot.setFlag(from.flags.toTermFlags & RetainedModuleValFlags)
@@ -1096,7 +1104,7 @@ object SymDenotations {
// only apply to the module but not to the module class. The right solution
// is to have the module class completer set the annotations of both the
// class and the module.
- denot.info = mclass.symTypeRef
+ denot.info = moduleClass.symTypeRef
denot.privateWithin = from.privateWithin
}
}
diff --git a/src/dotty/tools/dotc/core/SymbolLoaders.scala b/src/dotty/tools/dotc/core/SymbolLoaders.scala
index 2fbe147c7..791501ad5 100644
--- a/src/dotty/tools/dotc/core/SymbolLoaders.scala
+++ b/src/dotty/tools/dotc/core/SymbolLoaders.scala
@@ -142,7 +142,7 @@ class SymbolLoaders {
/** Load contents of a package
*/
class PackageLoader(override val sourceModule: TermSymbol, classpath: ClassPath)(implicit val cctx: CondensedContext)
- extends SymbolLoader with ModuleClassCompleter {
+ extends SymbolLoader with LazyTypeOfModuleClass {
def description = "package loader " + classpath.name
private[core] val preDecls: MutableScope = newScope
diff --git a/src/dotty/tools/dotc/core/Symbols.scala b/src/dotty/tools/dotc/core/Symbols.scala
index f7b079a69..ac13381e6 100644
--- a/src/dotty/tools/dotc/core/Symbols.scala
+++ b/src/dotty/tools/dotc/core/Symbols.scala
@@ -297,10 +297,8 @@ object Symbols {
type ThisName <: Name
- private[this] var _id: Int = {
- //assert(id != 144972)
- nextId
- }
+ private[this] var _id: Int = nextId
+ //assert(_id != 5859)
/** The unique id of this symbol */
def id = _id
@@ -366,8 +364,9 @@ object Symbols {
* the class containing this symbol was generated, null if not applicable.
* Overridden in ClassSymbol
*/
- def associatedFile(implicit ctx: Context): AbstractFile =
+ def associatedFile(implicit ctx: Context): AbstractFile = ctx.traceIndented(s"assocFile($this)") {
denot.topLevelClass.symbol.associatedFile
+ }
/** The class file from which this class was generated, null if not applicable. */
final def binaryFile(implicit ctx: Context): AbstractFile =
diff --git a/src/dotty/tools/dotc/core/pickling/UnPickler.scala b/src/dotty/tools/dotc/core/pickling/UnPickler.scala
index 2b18e2263..65b140edd 100644
--- a/src/dotty/tools/dotc/core/pickling/UnPickler.scala
+++ b/src/dotty/tools/dotc/core/pickling/UnPickler.scala
@@ -454,7 +454,7 @@ class UnPickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClassRoot:
else {
def completer(cls: Symbol) =
if (flags is ModuleClass)
- new LocalClassUnpickler(cls) with ModuleClassCompleter {
+ new LocalClassUnpickler(cls) with LazyTypeOfModuleClass {
override def sourceModule =
cls.owner.decls.lookup(cls.name.stripModuleClassSuffix.toTermName)
.suchThat(_ is Module).symbol
@@ -531,7 +531,7 @@ class UnPickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClassRoot:
def rootClassUnpickler(start: Coord, cls: Symbol, module: Symbol) =
new ClassCompleterWithDecls(symScope(cls), new AtStartUnpickler(start))
- with ModuleClassCompleter
+ with LazyTypeOfModuleClass
with SymbolLoaders.SecondCompleter {
override def sourceModule = module
}
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala
index 435e4014a..d003b8a09 100644
--- a/src/dotty/tools/dotc/typer/Typer.scala
+++ b/src/dotty/tools/dotc/typer/Typer.scala
@@ -46,7 +46,6 @@ object Typer {
implicit class TreeDecorator(tree: Tree) {
def qualifierType(implicit ctx: Context): Type = tree.tpe match {
case tpe: TermRef if !tpe.symbol.isStable => tpe.info
- case tpe: TypeRef => tpe.info
case tpe => tpe
}
}