aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-03-25 21:45:20 +0100
committerMartin Odersky <odersky@gmail.com>2013-03-25 21:45:20 +0100
commit5a039031c165fd9116749f28e9d9e6a0b6d5b0e6 (patch)
tree0a0b956ad7d384cf31a8d2b7835fe716c33d2834 /src/dotty/tools/dotc/core
parent27a508c50482f4053591ed740f09ecced5bf749b (diff)
downloaddotty-5a039031c165fd9116749f28e9d9e6a0b6d5b0e6.tar.gz
dotty-5a039031c165fd9116749f28e9d9e6a0b6d5b0e6.tar.bz2
dotty-5a039031c165fd9116749f28e9d9e6a0b6d5b0e6.zip
More fixes to classfile reading.
Can now read entire contents of scala distribution.
Diffstat (limited to 'src/dotty/tools/dotc/core')
-rw-r--r--src/dotty/tools/dotc/core/Printers.scala4
-rw-r--r--src/dotty/tools/dotc/core/SymDenotations.scala2
-rw-r--r--src/dotty/tools/dotc/core/Types.scala21
-rw-r--r--src/dotty/tools/dotc/core/pickling/ClassfileParser.scala2
-rw-r--r--src/dotty/tools/dotc/core/pickling/UnPickler.scala16
-rw-r--r--src/dotty/tools/dotc/core/transform/Erasure.scala8
6 files changed, 41 insertions, 12 deletions
diff --git a/src/dotty/tools/dotc/core/Printers.scala b/src/dotty/tools/dotc/core/Printers.scala
index de9677a3a..e789e7db1 100644
--- a/src/dotty/tools/dotc/core/Printers.scala
+++ b/src/dotty/tools/dotc/core/Printers.scala
@@ -89,7 +89,7 @@ object Printers {
}
class PlainPrinter(_ctx: Context) extends Printer {
- protected[this] implicit val ctx = _ctx
+ protected[this] implicit val ctx = _ctx.fresh.withCheckPrefix(false)
def controlled(op: => Text): Text =
if (ctx.toTextRecursions < maxToTextRecursions)
@@ -98,7 +98,7 @@ object Printers {
op
} catch {
case ex: CyclicReference =>
- "<cycle involving ${ex.denot}>"
+ s"<cycle involving ${ex.denot}>"
} finally {
ctx.toTextRecursions -= 1
}
diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala
index dc2502092..fc702b85e 100644
--- a/src/dotty/tools/dotc/core/SymDenotations.scala
+++ b/src/dotty/tools/dotc/core/SymDenotations.scala
@@ -570,7 +570,7 @@ object SymDenotations {
*/
def typeConstructor(implicit ctx: Context): TypeRef =
if ((this is PackageClass) || owner.isTerm) symbolicRef
- else TypeRef(owner.thisType, name.asTypeName)
+ else TypeRef(owner.thisType, name.asTypeName).withDenot(this)
/** The symbolic typeref representing the type constructor for this type.
* @throws ClassCastException is this is not a type
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala
index c349bc7ba..35225e8e7 100644
--- a/src/dotty/tools/dotc/core/Types.scala
+++ b/src/dotty/tools/dotc/core/Types.scala
@@ -257,6 +257,20 @@ object Types {
pdenot & new JointRefDenotation(NoSymbol, tp.refinedInfo.substThis(tp, pre), Period.allInRun(ctx.runId))
else
pdenot
+ case tp: ThisType =>
+ val d = tp.underlying.findMember(name, pre, excluded)
+ if (d.exists) d
+ else
+ // There is a special case to handle:
+ // trait Super { this: Sub => private class Inner {} println(this.Inner) }
+ // class Sub extends Super
+ // When resolving Super.this.Inner, the normal logic goes to the self type and
+ // looks for Inner from there. But this fails because Inner is private.
+ // We fix the problem by having the following fallback case, which links up the
+ // member in Super instead of Sub.
+ // As an example of this in the wild, see
+ // loadClassWithPrivateInnerAndSubSelf in ShowClassTests
+ tp.cls.symbolicRef.findMember(name, pre, excluded)
case tp: TypeProxy =>
tp.underlying.findMember(name, pre, excluded)
case tp: ClassInfo =>
@@ -868,6 +882,11 @@ object Types {
lastDenotation
}
+ private[core] final def withDenot(denot: Denotation): this.type = {
+ lastDenotation = denot
+ this
+ }
+
protected def loadDenot(implicit ctx: Context) = prefix.member(name)
def isType = name.isTypeName
@@ -1659,7 +1678,7 @@ object Types {
class FatalTypeError(msg: String) extends TypeError(msg)
class MalformedType(pre: Type, denot: Denotation)
extends FatalTypeError(s"malformed type: $pre is not a legal prefix for $denot")
- class CyclicReference(denot: SymDenotation)
+ class CyclicReference(val denot: SymDenotation)
extends FatalTypeError(s"cyclic reference involving $denot")
// ----- Misc utilities ---------------------------------------------------------
diff --git a/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala b/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala
index 6b7721213..4981a6f4e 100644
--- a/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala
+++ b/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala
@@ -229,7 +229,7 @@ class ClassfileParser(
case 'L' =>
def processInner(tp: Type): Type = tp match {
case tp @ TypeRef(pre, name) if !(tp.symbol.owner is Flags.ModuleClass) =>
- TypeRef(pre.widen, name)
+ TypeRef(processInner(pre.widen), name)
case _ =>
tp
}
diff --git a/src/dotty/tools/dotc/core/pickling/UnPickler.scala b/src/dotty/tools/dotc/core/pickling/UnPickler.scala
index e34209aa1..161034bde 100644
--- a/src/dotty/tools/dotc/core/pickling/UnPickler.scala
+++ b/src/dotty/tools/dotc/core/pickling/UnPickler.scala
@@ -364,14 +364,16 @@ class UnPickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClassRoot:
// return NoSymbol
if (tag == EXTMODCLASSref) {
- unimplementedTree(s"nested objects")
- /*
+ val module = owner.info.decl(name.toTermName).suchThat(_ is Module)
+ module.info // force it, as completer does not yet point to module class.
+ module.symbol.moduleClass
+
+ /* was:
val moduleVar = owner.info.decl(name.toTermName.moduleVarName).symbol
if (moduleVar.isLazyAccessor)
return moduleVar.lazyAccessor.lazyAccessor
-*/
- }
- NoSymbol
+ */
+ } else NoSymbol
}
// println(s"read ext symbol $name from ${owner.denot.debugString} in ${classRoot.debugString}") // !!! DEBUG
@@ -562,7 +564,9 @@ class UnPickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClassRoot:
val tp1 = elim(tp)
val isBound = (tp: Type) => boundSyms contains tp.typeSymbol
if (tp1 existsPart isBound) {
- val tp2 = tp1.subst(boundSyms, boundSyms map (_ => defn.AnyType))
+ val anyTypes = boundSyms map (_ => defn.AnyType)
+ val boundBounds = boundSyms map (_.info.bounds.hi)
+ val tp2 = tp1.subst(boundSyms, boundBounds).subst(boundSyms, anyTypes)
cctx.warning(s"""failure to eliminate existential
|original type : $tp forSome {${cctx.dclsText(boundSyms, "; ").show}
|reduces to : $tp1
diff --git a/src/dotty/tools/dotc/core/transform/Erasure.scala b/src/dotty/tools/dotc/core/transform/Erasure.scala
index d10415829..330442408 100644
--- a/src/dotty/tools/dotc/core/transform/Erasure.scala
+++ b/src/dotty/tools/dotc/core/transform/Erasure.scala
@@ -109,7 +109,13 @@ object Erasure {
else paramSignature(sym.info)
case tp: RefinedType =>
val parent = tp.parent
- if (parent.dealias.typeSymbol == defn.ArrayClass) paramSignature(eraseArray(tp))
+ if (parent.dealias.typeSymbol == defn.ArrayClass)
+ eraseArray(tp) match {
+ case tp1: RefinedType if tp1.parent.dealias.typeSymbol == defn.ArrayClass =>
+ paramSignature(tp1.parent) ++ "[]"
+ case tp1 =>
+ paramSignature(tp1)
+ }
else paramSignature(parent)
case tp: TypeProxy =>
paramSignature(tp.underlying)