diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/dotty/tools/dotc/core/pickling/UnPickler.scala | 48 |
1 files changed, 36 insertions, 12 deletions
diff --git a/src/dotty/tools/dotc/core/pickling/UnPickler.scala b/src/dotty/tools/dotc/core/pickling/UnPickler.scala index 60000441c..627500035 100644 --- a/src/dotty/tools/dotc/core/pickling/UnPickler.scala +++ b/src/dotty/tools/dotc/core/pickling/UnPickler.scala @@ -9,8 +9,9 @@ import java.lang.Double.longBitsToDouble import Contexts._, Symbols._, Types._, Scopes._, SymDenotations._, Names._, NameOps._ import StdNames._, Denotations._, NameOps._, Flags._, Constants._, Annotations._ +import dotty.tools.dotc.typer.ProtoTypes.{FunProtoTyped, FunProto} import util.Positions._ -import ast.Trees, ast.tpd._, ast.untpd +import dotty.tools.dotc.ast.{tpd, Trees, untpd}, ast.tpd._ import printing.Texts._ import printing.Printer import io.AbstractFile @@ -814,19 +815,42 @@ class UnPickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClassRoot: * readAnnotation, readSymbolAnnotation, or readAnnotInfoArg */ protected def readAnnotationContents(end: Int)(implicit ctx: Context): Tree = { - val atp = readTypeRef() - val args = new ListBuffer[Tree] - while (readIndex != end) { - val argref = readNat() - args += { - if (isNameEntry(argref)) { - val name = at(argref, readName) - val arg = readClassfileAnnotArg(readNat()) - NamedArg(name.asTermName, arg) - } else readAnnotArg(argref) + ctx.atPhase(ctx.typerPhase) { implicit ctx => // needed to enable implicit search + // and fix circullar dependency between annotation.currect invoking + // elimrepeated that reads the same annotation + + val atp = readTypeRef() + val args = { + val t = new ListBuffer[Tree] + + while (readIndex != end) { + val argref = readNat() + t += { + if (isNameEntry(argref)) { + val name = at(argref, readName) + val arg = readClassfileAnnotArg(readNat()) + NamedArg(name.asTermName, arg) + } else readAnnotArg(argref) + } + } + t.toList } + println(atp) + val typer = ctx.typer + val proto = new FunProtoTyped(args, atp, typer) + val alts = atp.member(nme.CONSTRUCTOR).alternatives.map(_.termRef) + + val constructors = ctx.typer.resolveOverloaded(alts, proto) + assert(constructors.size == 1) // this is parsed from bytecode tree. there's nothing user can do about it + + val constr = constructors.head + val targs = atp.argTypes + val fun = tpd.New(atp withoutArgs targs) + .select(TermRef.withSig(atp.normalizedPrefix, constr.termSymbol.asTerm)) + .appliedToTypes(targs) + val apply = untpd.Apply(fun, args) + new typer.ApplyToTyped(apply, fun, constr, args, atp).result // needed to handle varargs } - New(atp, args.toList) } /** Read an annotation and as a side effect store it into |