aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/pickling/UnPickler.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/pickling/UnPickler.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/pickling/UnPickler.scala')
-rw-r--r--src/dotty/tools/dotc/core/pickling/UnPickler.scala29
1 files changed, 16 insertions, 13 deletions
diff --git a/src/dotty/tools/dotc/core/pickling/UnPickler.scala b/src/dotty/tools/dotc/core/pickling/UnPickler.scala
index 23fb79f8f..2b18e2263 100644
--- a/src/dotty/tools/dotc/core/pickling/UnPickler.scala
+++ b/src/dotty/tools/dotc/core/pickling/UnPickler.scala
@@ -84,7 +84,7 @@ object UnPickler {
tp.derivedPolyType(paramNames, tp.paramBounds, arrayToRepeated(tp.resultType))
}
- def setClassInfo(denot: ClassDenotation, info: Type, optSelfType: Type = NoType)(implicit ctx: Context): Unit = {
+ def setClassInfo(denot: ClassDenotation, info: Type, selfInfo: Type = NoType)(implicit ctx: Context): Unit = {
val cls = denot.classSymbol
val (tparams, TempClassInfoType(parents, decls, clazz)) = info match {
case TempPolyType(tps, cinfo) => (tps, cinfo)
@@ -97,9 +97,9 @@ object UnPickler {
else denot.enter(tparam, decls)
}
val ost =
- if ((optSelfType eq NoType) && (denot is ModuleClass))
+ if ((selfInfo eq NoType) && (denot is ModuleClass))
TermRef.withSym(denot.owner.thisType, denot.sourceModule.asTerm)
- else optSelfType
+ else selfInfo
denot.info = ClassInfo(denot.owner.thisType, denot.classSymbol, parentRefs, decls, ost)
}
}
@@ -452,13 +452,14 @@ class UnPickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClassRoot:
// create a type alias instead
cctx.newSymbol(owner, name, flags, localMemberUnpickler, coord = start)
else {
- def completer(cls: Symbol) = new LocalClassUnpickler(cls) {
- override def sourceModule =
- if (flags is ModuleClass)
- cls.owner.decls.lookup(cls.name.stripModuleClassSuffix.toTermName)
- .suchThat(_ is Module).symbol
- else NoSymbol
- }
+ def completer(cls: Symbol) =
+ if (flags is ModuleClass)
+ new LocalClassUnpickler(cls) with ModuleClassCompleter {
+ override def sourceModule =
+ cls.owner.decls.lookup(cls.name.stripModuleClassSuffix.toTermName)
+ .suchThat(_ is Module).symbol
+ }
+ else new LocalClassUnpickler(cls)
cctx.newClassSymbol(owner, name.asTypeName, flags, completer, coord = start)
}
case MODULEsym | VALsym =>
@@ -491,8 +492,8 @@ class UnPickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClassRoot:
val tp = at(inforef, readType)
denot match {
case denot: ClassDenotation =>
- val optSelfType = if (atEnd) NoType else readTypeRef()
- setClassInfo(denot, tp, optSelfType)
+ val selfInfo = if (atEnd) NoType else readTypeRef()
+ setClassInfo(denot, tp, selfInfo)
case denot =>
val tp1 = depoly(tp, denot)
denot.info = if (tag == ALIASsym) TypeAlias(tp1) else tp1
@@ -529,7 +530,9 @@ class UnPickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClassRoot:
extends ClassCompleterWithDecls(symScope(cls), localMemberUnpickler)
def rootClassUnpickler(start: Coord, cls: Symbol, module: Symbol) =
- new ClassCompleterWithDecls(symScope(cls), new AtStartUnpickler(start)) with SymbolLoaders.SecondCompleter {
+ new ClassCompleterWithDecls(symScope(cls), new AtStartUnpickler(start))
+ with ModuleClassCompleter
+ with SymbolLoaders.SecondCompleter {
override def sourceModule = module
}