aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc
diff options
context:
space:
mode:
authorDmitry Petrashko <dmitry.petrashko@gmail.com>2014-10-30 15:50:57 +0100
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2014-11-22 20:10:19 +0100
commit998a5c8e6d6b0613c1e2c1f9f58d657f5332aad1 (patch)
tree326fc922e46a5f1eb844fd5671e172afe3603bfd /src/dotty/tools/dotc
parent3b0349bbf3986dc2e352a95f8eff898ea1714806 (diff)
downloaddotty-998a5c8e6d6b0613c1e2c1f9f58d657f5332aad1.tar.gz
dotty-998a5c8e6d6b0613c1e2c1f9f58d657f5332aad1.tar.bz2
dotty-998a5c8e6d6b0613c1e2c1f9f58d657f5332aad1.zip
readAnnotationContents that should be able to resolve overloaded constructors.
Diffstat (limited to 'src/dotty/tools/dotc')
-rw-r--r--src/dotty/tools/dotc/core/pickling/UnPickler.scala48
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