aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dotty/tools/dotc/ast/tpd.scala8
-rw-r--r--src/dotty/tools/dotc/typer/EtaExpansion.scala7
-rw-r--r--src/dotty/tools/dotc/typer/Typer.scala11
-rw-r--r--tests/pos/t3252.scala (renamed from tests/pending/pos/t3252.scala)0
4 files changed, 20 insertions, 6 deletions
diff --git a/src/dotty/tools/dotc/ast/tpd.scala b/src/dotty/tools/dotc/ast/tpd.scala
index 8fdc4a9db..77c607ca7 100644
--- a/src/dotty/tools/dotc/ast/tpd.scala
+++ b/src/dotty/tools/dotc/ast/tpd.scala
@@ -759,6 +759,14 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
Ident(defn.ScalaRuntimeModule.requiredMethod(name).termRef).appliedToArgs(args)
}
+ /** An extractor that pulls out type arguments */
+ object MaybePoly {
+ def unapply(tree: Tree): Option[(Tree, List[Tree])] = tree match {
+ case TypeApply(tree, targs) => Some(tree, targs)
+ case _ => Some(tree, Nil)
+ }
+ }
+
/** A traverser that passes the enlcosing class or method as an argumenr
* to the traverse method.
*/
diff --git a/src/dotty/tools/dotc/typer/EtaExpansion.scala b/src/dotty/tools/dotc/typer/EtaExpansion.scala
index 6ecd90c08..b59748247 100644
--- a/src/dotty/tools/dotc/typer/EtaExpansion.scala
+++ b/src/dotty/tools/dotc/typer/EtaExpansion.scala
@@ -34,8 +34,11 @@ object EtaExpansion {
* lhs += expr
*/
def liftAssigned(defs: mutable.ListBuffer[Tree], tree: Tree)(implicit ctx: Context): Tree = tree match {
- case Apply(fn @ Select(pre, name), args) =>
- cpy.Apply(tree)(cpy.Select(fn)(lift(defs, pre), name), liftArgs(defs, fn.tpe, args))
+ case Apply(MaybePoly(fn @ Select(pre, name), targs), args) =>
+ cpy.Apply(tree)(
+ cpy.Select(fn)(
+ lift(defs, pre), name).appliedToTypeTrees(targs),
+ liftArgs(defs, fn.tpe, args))
case Select(pre, name) =>
cpy.Select(tree)(lift(defs, pre), name)
case _ =>
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala
index ce07ba74c..59aba4723 100644
--- a/src/dotty/tools/dotc/typer/Typer.scala
+++ b/src/dotty/tools/dotc/typer/Typer.scala
@@ -400,10 +400,13 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
tree.lhs match {
case lhs @ Apply(fn, args) =>
typed(cpy.Apply(lhs)(untpd.Select(fn, nme.update), args :+ tree.rhs), pt)
- case untpd.TypedSplice(Apply(Select(fn, app), args)) if app == nme.apply =>
- typed(cpy.Apply(fn)(
- untpd.Select(untpd.TypedSplice(fn), nme.update),
- (args map untpd.TypedSplice) :+ tree.rhs), pt)
+ case untpd.TypedSplice(Apply(MaybePoly(Select(fn, app), targs), args)) if app == nme.apply =>
+ val rawUpdate: untpd.Tree = untpd.Select(untpd.TypedSplice(fn), nme.update)
+ val wrappedUpdate =
+ if (targs.isEmpty) rawUpdate
+ else untpd.TypeApply(rawUpdate, targs map untpd.TypedSplice)
+ val appliedUpdate = cpy.Apply(fn)(wrappedUpdate, (args map untpd.TypedSplice) :+ tree.rhs)
+ typed(appliedUpdate, pt)
case lhs =>
val lhsCore = typedUnadapted(lhs)
def lhs1 = typed(untpd.TypedSplice(lhsCore))
diff --git a/tests/pending/pos/t3252.scala b/tests/pos/t3252.scala
index 3ecc1e7ce..3ecc1e7ce 100644
--- a/tests/pending/pos/t3252.scala
+++ b/tests/pos/t3252.scala