aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/tasty
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-06-29 19:04:03 +0200
committerMartin Odersky <odersky@gmail.com>2016-07-11 13:34:58 +0200
commit850dc6f2fb3b6228f2586ce0790621e80f664afe (patch)
tree3100de85088553b62f1652435049f4bb24f8f2fb /src/dotty/tools/dotc/core/tasty
parentcdb4a1cb986f25eddf411dfc45aeb20dd994f7d5 (diff)
downloaddotty-850dc6f2fb3b6228f2586ce0790621e80f664afe.tar.gz
dotty-850dc6f2fb3b6228f2586ce0790621e80f664afe.tar.bz2
dotty-850dc6f2fb3b6228f2586ce0790621e80f664afe.zip
Introduce recursive types
Map self-references in refinements to recursive types. This commit does this for refinement types appearing in source. We still have to do it for unpickled refinements. Test apply-equiv got moved to pending because it simulates the old higher-kinded type encoding in source, which relies on the old representation in terms of self-referential refinement types. The plan is not to adapt this encoding to the new representation, but to replace it with a different encoding that makes critical use of the added power of recursive types. Use recursive types also when unpickling from Scala 2.x. Add mapInfo method to Denotations.
Diffstat (limited to 'src/dotty/tools/dotc/core/tasty')
-rw-r--r--src/dotty/tools/dotc/core/tasty/TastyFormat.scala8
-rw-r--r--src/dotty/tools/dotc/core/tasty/TreePickler.scala8
-rw-r--r--src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala7
3 files changed, 20 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/core/tasty/TastyFormat.scala b/src/dotty/tools/dotc/core/tasty/TastyFormat.scala
index a42958e75..e9708961a 100644
--- a/src/dotty/tools/dotc/core/tasty/TastyFormat.scala
+++ b/src/dotty/tools/dotc/core/tasty/TastyFormat.scala
@@ -103,7 +103,7 @@ Standard-Section: "ASTs" TopLevelStat*
TERMREFpkg fullyQualified_NameRef
TERMREF possiblySigned_NameRef qual_Type
THIS clsRef_Type
- REFINEDthis refinedType_ASTRef
+ RECthis recType_ASTRef
SHARED path_ASTRef
Constant = UNITconst
@@ -126,6 +126,7 @@ Standard-Section: "ASTs" TopLevelStat*
TYPEREFsymbol sym_ASTRef qual_Type
TYPEREFpkg fullyQualified_NameRef
TYPEREF possiblySigned_NameRef qual_Type
+ RECtype parent_Type
SUPERtype Length this_Type underlying_Type
REFINEDtype Length underlying_Type refinement_NameRef info_Type
APPLIEDtype Length tycon_Type arg_Type*
@@ -259,6 +260,7 @@ object TastyFormat {
final val TERMREFpkg = 67
final val TYPEREFpkg = 68
final val REFINEDthis = 69
+ final val RECthis = REFINEDthis // !!!
final val BYTEconst = 70
final val SHORTconst = 71
final val CHARconst = 72
@@ -277,6 +279,7 @@ object TastyFormat {
final val IMPLICITarg = 101
final val PRIVATEqualified = 102
final val PROTECTEDqualified = 103
+ final val RECtype = 104
final val IDENT = 112
final val SELECT = 113
@@ -417,7 +420,7 @@ object TastyFormat {
case TYPEREFdirect => "TYPEREFdirect"
case TERMREFpkg => "TERMREFpkg"
case TYPEREFpkg => "TYPEREFpkg"
- case REFINEDthis => "REFINEDthis"
+ case RECthis => "RECthis"
case BYTEconst => "BYTEconst"
case SHORTconst => "SHORTconst"
case CHARconst => "CHARconst"
@@ -426,6 +429,7 @@ object TastyFormat {
case FLOATconst => "FLOATconst"
case DOUBLEconst => "DOUBLEconst"
case STRINGconst => "STRINGconst"
+ case RECtype => "RECtype"
case IDENT => "IDENT"
case SELECT => "SELECT"
diff --git a/src/dotty/tools/dotc/core/tasty/TreePickler.scala b/src/dotty/tools/dotc/core/tasty/TreePickler.scala
index 0cc08f2d9..9f703b5af 100644
--- a/src/dotty/tools/dotc/core/tasty/TreePickler.scala
+++ b/src/dotty/tools/dotc/core/tasty/TreePickler.scala
@@ -212,6 +212,11 @@ class TreePickler(pickler: TastyPickler) {
val binderAddr = pickledTypes.get(tpe.binder)
assert(binderAddr != null, tpe.binder)
writeRef(binderAddr.asInstanceOf[Addr])
+ case tpe: RecThis =>
+ writeByte(RECthis)
+ val binderAddr = pickledTypes.get(tpe.binder)
+ assert(binderAddr != null, tpe.binder)
+ writeRef(binderAddr.asInstanceOf[Addr])
case tpe: SkolemType =>
pickleType(tpe.info)
case tpe: RefinedType =>
@@ -221,6 +226,9 @@ class TreePickler(pickler: TastyPickler) {
pickleType(tpe.parent)
pickleType(tpe.refinedInfo, richTypes = true)
}
+ case tpe: RecType =>
+ writeByte(RECtype)
+ pickleType(tpe.parent)
case tpe: TypeAlias =>
writeByte(TYPEALIAS)
withLength {
diff --git a/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala b/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala
index 2b8e5f019..1b4e7845a 100644
--- a/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala
+++ b/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala
@@ -335,8 +335,13 @@ class TreeUnpickler(reader: TastyReader, tastyName: TastyName.Table) {
}
case THIS =>
ThisType.raw(readType().asInstanceOf[TypeRef])
+ case RECtype =>
+ RecType(rt => registeringType(rt, readType()))
case REFINEDthis =>
- RefinedThis(readTypeRef().asInstanceOf[RefinedType])
+ readTypeRef() match {
+ case t: RefinedType => RefinedThis(t)
+ case t: RecType => RecThis(t)
+ }
case SHARED =>
val ref = readAddr()
typeAtAddr.getOrElseUpdate(ref, forkAt(ref).readType())