aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Petrashko <dmitry.petrashko@gmail.com>2014-10-30 16:20:57 +0100
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2014-11-22 20:10:20 +0100
commit11449db93f426a3fc64eded180852661d889804e (patch)
tree0add44f1650789ceac91906a7447c61d3b1828c3
parent68dfe2a7619edfb9829876643c9177723a40bb84 (diff)
downloaddotty-11449db93f426a3fc64eded180852661d889804e.tar.gz
dotty-11449db93f426a3fc64eded180852661d889804e.tar.bz2
dotty-11449db93f426a3fc64eded180852661d889804e.zip
Infer if overloading resolution should trigger implicit search.
This doesn't require additional argument. Decision can be made solely from the phaseId.
-rw-r--r--src/dotty/tools/dotc/core/pickling/UnPickler.scala61
-rw-r--r--src/dotty/tools/dotc/typer/Applications.scala4
2 files changed, 30 insertions, 35 deletions
diff --git a/src/dotty/tools/dotc/core/pickling/UnPickler.scala b/src/dotty/tools/dotc/core/pickling/UnPickler.scala
index b165f91fa..aa277d6b0 100644
--- a/src/dotty/tools/dotc/core/pickling/UnPickler.scala
+++ b/src/dotty/tools/dotc/core/pickling/UnPickler.scala
@@ -815,42 +815,37 @@ class UnPickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClassRoot:
* readAnnotation, readSymbolAnnotation, or readAnnotInfoArg
*/
protected def readAnnotationContents(end: Int)(implicit ctx: Context): Tree = {
- 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)
- }
+ 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, Nil, false)
- 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
+ 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, Nil)
+ 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
}
/** Read an annotation and as a side effect store it into
diff --git a/src/dotty/tools/dotc/typer/Applications.scala b/src/dotty/tools/dotc/typer/Applications.scala
index 3fd56640e..9b2e64f35 100644
--- a/src/dotty/tools/dotc/typer/Applications.scala
+++ b/src/dotty/tools/dotc/typer/Applications.scala
@@ -902,7 +902,7 @@ trait Applications extends Compatibility { self: Typer =>
* to form the method type.
* todo: use techniques like for implicits to pick candidates quickly?
*/
- def resolveOverloaded(alts: List[TermRef], pt: Type, targs: List[Type] = Nil, resolveImplicits: Boolean = true)(implicit ctx: Context): List[TermRef] = track("resolveOverloaded") {
+ def resolveOverloaded(alts: List[TermRef], pt: Type, targs: List[Type] = Nil)(implicit ctx: Context): List[TermRef] = track("resolveOverloaded") {
def isDetermined(alts: List[TermRef]) = alts.isEmpty || alts.tail.isEmpty
@@ -965,7 +965,7 @@ trait Applications extends Compatibility { self: Typer =>
def narrowByTrees(alts: List[TermRef], args: List[Tree], resultType: Type): List[TermRef] =
alts filter ( alt =>
- if (resolveImplicits) isApplicable(alt, targs, args, resultType)
+ if (!ctx.isAfterTyper) isApplicable(alt, targs, args, resultType)
else isDirectlyApplicable(alt, targs, args, resultType)
)