aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/pickling/UnPickler.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-03-18 22:05:26 +0100
committerMartin Odersky <odersky@gmail.com>2013-03-18 22:05:26 +0100
commiteb2b6bf420b24ac0307e17fc9fec38e91012d1af (patch)
treea49d5b4f45f78ec96006b18816b69ed30c8a745e /src/dotty/tools/dotc/core/pickling/UnPickler.scala
parent830e511b6b620716d3f550a199d0a5c52c95423a (diff)
downloaddotty-eb2b6bf420b24ac0307e17fc9fec38e91012d1af.tar.gz
dotty-eb2b6bf420b24ac0307e17fc9fec38e91012d1af.tar.bz2
dotty-eb2b6bf420b24ac0307e17fc9fec38e91012d1af.zip
More changes for higher-kinded types emulation.
Diffstat (limited to 'src/dotty/tools/dotc/core/pickling/UnPickler.scala')
-rw-r--r--src/dotty/tools/dotc/core/pickling/UnPickler.scala30
1 files changed, 22 insertions, 8 deletions
diff --git a/src/dotty/tools/dotc/core/pickling/UnPickler.scala b/src/dotty/tools/dotc/core/pickling/UnPickler.scala
index ddbc4b8e2..00c304196 100644
--- a/src/dotty/tools/dotc/core/pickling/UnPickler.scala
+++ b/src/dotty/tools/dotc/core/pickling/UnPickler.scala
@@ -34,11 +34,11 @@ object UnPickler {
* If `forSym` is not an abstract type, this simply returns an equivalent `PolyType`.
* If `forSym` is an abstract type, it converts a
*
- * TempPolyType(List(T_1, ..., T_n), lo..hi)
+ * TempPolyType(List(v_1 T_1, ..., v_n T_n), lo .. hi)
*
* to
*
- * Bottom..HigherKinded[lo_1, ..., lo_N, hi_1, ..., hi_N] & (lo..hi)
+ * lo .. HigherKinded_n[v_1Between[lo_1, hi_1],..., v_nBetween[lo_n, hi_n]] & hi
*
* where lo_i, hi_i are the lower/upper bounds of the type parameters T_i.
* This works only as long as none of the type parameters T_i appears in any
@@ -48,13 +48,21 @@ object UnPickler {
def depoly(tp: Type, forSym: SymDenotation)(implicit ctx: Context): Type = tp match {
case TempPolyType(tparams, restpe) =>
if (forSym.isAbstractType) {
- val typeArgs = (tparams map (_.info.bounds.lo)) ++ (tparams map (_.info.bounds.hi))
+ val typeArgs = for (tparam <- tparams) yield {
+ val TypeBounds(lo, hi) = tparam.info
+ defn.hkBoundsClass(tparam.variance).typeConstructor
+ .appliedTo(List(lo, hi))
+ }
val elimTparams: Type => Type = _.subst(tparams, tparams map (_ => defn.AnyType))
val correctedArgs = typeArgs.mapConserve(elimTparams)
val correctedRes = elimTparams(restpe)
- assert(correctedRes.isInstanceOf[TypeBounds])
- val hk = defn.hkTrait(tparams.length)
- val result = TypeBounds.upper(hk.typeConstructor.appliedTo(correctedArgs)) & correctedRes
+ val hkBound = defn.hkTrait(tparams.length).typeConstructor
+ .appliedTo(correctedArgs)
+ val result = correctedRes match {
+ case TypeBounds(lo, hi) =>
+ val hi1 = if (hi == defn.AnyType) hkBound else AndType(hkBound, hi)
+ TypeBounds(lo, hi1) //note: using & instead would be too eager
+ }
if ((typeArgs ne correctedArgs) || (restpe ne correctedRes))
ctx.warning(s"""failure to import F-bounded higher-kinded type
|original type definition: ${forSym.show}${tp.show}
@@ -551,8 +559,14 @@ class UnPickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClassRoot:
val pre = readTypeRef()
val sym = readSymbolRef()
val tycon =
- if (isLocal(sym)) TypeRef(pre, sym.asType)
- else TypeRef(pre, sym.name.asTypeName)
+ if (isLocal(sym)) {
+ TypeRef(
+ if ((pre eq NoPrefix) && (sym is TypeParam))
+ sym.owner.thisType
+ else
+ pre,
+ sym.asType)
+ } else TypeRef(pre, sym.name.asTypeName)
val args = until(end, readTypeRef)
if (args.nonEmpty) println(s"reading app type $tycon ${tycon.typeSymbol.debugString} $args, owner = ${tycon.typeSymbol.owner.debugString}") // !!! DEBUG
tycon.appliedTo(args)