diff options
author | Martin Odersky <odersky@gmail.com> | 2016-06-29 20:00:59 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-07-11 13:35:02 +0200 |
commit | 60d81f81ddfc85719fd303e8d15d3891adbf4dfd (patch) | |
tree | 17e830e9e73157451c1a46ba2d716ca0d1037f97 /src/dotty/tools/dotc/core/tasty | |
parent | d1f809f14cad2c14c312767d71361c7f2e7d8244 (diff) | |
download | dotty-60d81f81ddfc85719fd303e8d15d3891adbf4dfd.tar.gz dotty-60d81f81ddfc85719fd303e8d15d3891adbf4dfd.tar.bz2 dotty-60d81f81ddfc85719fd303e8d15d3891adbf4dfd.zip |
Start new, direct HK scheme
- Re-introduce newHK option. Label some things that will be
removed with OLD.
Diffstat (limited to 'src/dotty/tools/dotc/core/tasty')
-rw-r--r-- | src/dotty/tools/dotc/core/tasty/TastyFormat.scala | 8 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/tasty/TreePickler.scala | 5 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala | 9 |
3 files changed, 21 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/core/tasty/TastyFormat.scala b/src/dotty/tools/dotc/core/tasty/TastyFormat.scala index 38d55e0e8..b23ee5aba 100644 --- a/src/dotty/tools/dotc/core/tasty/TastyFormat.scala +++ b/src/dotty/tools/dotc/core/tasty/TastyFormat.scala @@ -138,6 +138,7 @@ Standard-Section: "ASTs" TopLevelStat* BIND Length boundName_NameRef bounds_Type // for type-variables defined in a type pattern BYNAMEtype underlying_Type + LAMBDAtype Length result_Type NamesTypes // variance encoded in front of name: +/-/= POLYtype Length result_Type NamesTypes // needed for refinements METHODtype Length result_Type NamesTypes // needed for refinements PARAMtype Length binder_ASTref paramNum_Nat // needed for refinements @@ -326,7 +327,8 @@ object TastyFormat { final val ORtype = 172 final val METHODtype = 174 final val POLYtype = 175 - final val PARAMtype = 176 + final val LAMBDAtype = 176 + final val PARAMtype = 177 final val ANNOTATION = 178 final val firstSimpleTreeTag = UNITconst @@ -500,4 +502,8 @@ object TastyFormat { case TYPEBOUNDS => -2 case _ => 0 } + + /** Map between variances and name prefixes */ + val varianceToPrefix = Map(-1 -> '-', 0 -> '=', 1 -> '+') + val prefixToVariance = Map('-' -> -1, '=' -> 0, '+' -> 1) } diff --git a/src/dotty/tools/dotc/core/tasty/TreePickler.scala b/src/dotty/tools/dotc/core/tasty/TreePickler.scala index d6e6c4d6b..f604bff62 100644 --- a/src/dotty/tools/dotc/core/tasty/TreePickler.scala +++ b/src/dotty/tools/dotc/core/tasty/TreePickler.scala @@ -254,6 +254,11 @@ class TreePickler(pickler: TastyPickler) { case tpe: ExprType => writeByte(BYNAMEtype) pickleType(tpe.underlying) + case tpe: TypeLambda => + writeByte(LAMBDAtype) + val paramNames = tpe.typeParams.map(tparam => + varianceToPrefix(tparam.memberVariance) +: tparam.memberName) + pickleMethodic(tpe.resultType, paramNames, tpe.paramBounds) case tpe: MethodType if richTypes => writeByte(METHODtype) pickleMethodic(tpe.resultType, tpe.paramNames, tpe.paramTypes) diff --git a/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala b/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala index 2d230c630..6f0596ac0 100644 --- a/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala +++ b/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala @@ -287,6 +287,15 @@ class TreeUnpickler(reader: TastyReader, tastyName: TastyName.Table) { val sym = ctx.newSymbol(ctx.owner, readName().toTypeName, BindDefinedType, readType()) registerSym(start, sym) TypeRef.withFixedSym(NoPrefix, sym.name, sym) + case LAMBDAtype => + val (rawNames, paramReader) = readNamesSkipParams[TypeName] + val (variances, paramNames) = rawNames + .map(name => (prefixToVariance(name.head), name.tail.asTypeName)).unzip + val result = TypeLambda(paramNames, variances)( + pt => registeringType(pt, paramReader.readParamTypes[TypeBounds](end)), + pt => readType()) + goto(end) + result case POLYtype => val (names, paramReader) = readNamesSkipParams[TypeName] val result = PolyType(names)( |