aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-07-14 19:54:18 +0200
committerMartin Odersky <odersky@gmail.com>2015-09-18 18:05:15 +0200
commitf19220307f25a08269ab5098de784f023cb6b02b (patch)
tree1e76a98bc2140827ba9e89a8889eef3977b38878 /src
parent5f7eadf3f4d4798dec7c87c92a86c882948ac3de (diff)
downloaddotty-f19220307f25a08269ab5098de784f023cb6b02b.tar.gz
dotty-f19220307f25a08269ab5098de784f023cb6b02b.tar.bz2
dotty-f19220307f25a08269ab5098de784f023cb6b02b.zip
Adapt arguments in all type applications
Previously, we did this only in applications in rhs of type definitions. Need to do it everywhere.
Diffstat (limited to 'src')
-rw-r--r--src/dotty/tools/dotc/typer/Applications.scala7
-rw-r--r--src/dotty/tools/dotc/typer/Typer.scala9
2 files changed, 8 insertions, 8 deletions
diff --git a/src/dotty/tools/dotc/typer/Applications.scala b/src/dotty/tools/dotc/typer/Applications.scala
index 40029c42b..8800c1a55 100644
--- a/src/dotty/tools/dotc/typer/Applications.scala
+++ b/src/dotty/tools/dotc/typer/Applications.scala
@@ -604,10 +604,6 @@ trait Applications extends Compatibility { self: Typer =>
val typedFn = typedExpr(tree.fun, PolyProto(typedArgs.tpes, pt))
typedFn.tpe.widen match {
case pt: PolyType =>
- def adaptTypeArg(tree: tpd.Tree, bound: Type): tpd.Tree =
- if (bound.isLambda && !tree.tpe.isLambda && tree.tpe.typeParams.nonEmpty)
- tree.withType(tree.tpe.EtaExpand)
- else tree
if (typedArgs.length <= pt.paramBounds.length)
typedArgs = typedArgs.zipWithConserve(pt.paramBounds)(adaptTypeArg)
checkBounds(typedArgs, pt)
@@ -616,6 +612,9 @@ trait Applications extends Compatibility { self: Typer =>
assignType(cpy.TypeApply(tree)(typedFn, typedArgs), typedFn, typedArgs)
}
+ def adaptTypeArg(tree: tpd.Tree, bound: Type)(implicit ctx: Context): tpd.Tree =
+ tree.withType(tree.tpe.EtaExpandIfLambda(bound))
+
/** Rewrite `new Array[T](....)` trees to calls of newXYZArray methods. */
def convertNewArray(tree: tpd.Tree)(implicit ctx: Context): tpd.Tree = tree match {
case Apply(TypeApply(tycon, targ :: Nil), args) if tycon.symbol == defn.ArrayConstructor =>
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala
index 58c017534..337737437 100644
--- a/src/dotty/tools/dotc/typer/Typer.scala
+++ b/src/dotty/tools/dotc/typer/Typer.scala
@@ -827,9 +827,6 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
def typedAppliedTypeTree(tree: untpd.AppliedTypeTree)(implicit ctx: Context): AppliedTypeTree = track("typedAppliedTypeTree") {
val tpt1 = typed(tree.tpt)
- val argPts =
- if (ctx.mode is Mode.Pattern) tpt1.tpe.typeParams.map(_.info)
- else tree.args.map(_ => WildcardType)
val tparams = tpt1.tpe.typeParams
var args = tree.args
if (tparams.isEmpty) {
@@ -840,7 +837,11 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
ctx.error(d"wrong number of type arguments for ${tpt1.tpe}, should be ${tparams.length}", tree.pos)
args = args.take(tparams.length)
}
- val args1 = args.zipWithConserve(argPts)(typed(_, _)).asInstanceOf[List[Tree]]
+ val argPts =
+ if (ctx.mode is Mode.Pattern) tpt1.tpe.typeParams.map(_.info)
+ else tree.args.map(_ => WildcardType)
+ def typedArg(arg: untpd.Tree, pt: Type) = adaptTypeArg(typed(arg, pt), pt)
+ val args1 = args.zipWithConserve(argPts)(typedArg(_, _)).asInstanceOf[List[Tree]]
// check that arguments conform to bounds is done in phase PostTyper
assignType(cpy.AppliedTypeTree(tree)(tpt1, args1), tpt1, args1)
}