aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/typer/Typer.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-07-19 13:09:05 +0200
committerMartin Odersky <odersky@gmail.com>2015-09-18 18:09:55 +0200
commit09ebc0f2b643c2be090c1aa0343880f063edc5be (patch)
treedcb83a158f32fefdf8ce321d1922b38431bf4928 /src/dotty/tools/dotc/typer/Typer.scala
parentc0918c69e578edad40320e0a5bac1603f5ce94fa (diff)
downloaddotty-09ebc0f2b643c2be090c1aa0343880f063edc5be.tar.gz
dotty-09ebc0f2b643c2be090c1aa0343880f063edc5be.tar.bz2
dotty-09ebc0f2b643c2be090c1aa0343880f063edc5be.zip
Adapt type arguments in typedAppliedTypeTree
Previously, only pattern bound arguments were adapated. This was an oversight. Also, change logix so that we survive empty type parameter lists. This was also an oversight before.
Diffstat (limited to 'src/dotty/tools/dotc/typer/Typer.scala')
-rw-r--r--src/dotty/tools/dotc/typer/Typer.scala24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala
index 337737437..7caec5135 100644
--- a/src/dotty/tools/dotc/typer/Typer.scala
+++ b/src/dotty/tools/dotc/typer/Typer.scala
@@ -825,7 +825,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
res
}
- def typedAppliedTypeTree(tree: untpd.AppliedTypeTree)(implicit ctx: Context): AppliedTypeTree = track("typedAppliedTypeTree") {
+ def typedAppliedTypeTree(tree: untpd.AppliedTypeTree)(implicit ctx: Context): Tree = track("typedAppliedTypeTree") {
val tpt1 = typed(tree.tpt)
val tparams = tpt1.tpe.typeParams
var args = tree.args
@@ -833,17 +833,19 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
ctx.error(d"${tpt1.tpe} does not take type parameters")
tpt1
}
- else if (args.length != tparams.length) {
- ctx.error(d"wrong number of type arguments for ${tpt1.tpe}, should be ${tparams.length}", tree.pos)
- args = args.take(tparams.length)
+ else {
+ if (args.length != tparams.length) {
+ ctx.error(d"wrong number of type arguments for ${tpt1.tpe}, should be ${tparams.length}", tree.pos)
+ args = args.take(tparams.length)
+ }
+ def typedArg(arg: untpd.Tree, tparam: Symbol) = {
+ val arg1 = typed(arg, if (ctx.mode is Mode.Pattern) tparam.info else WildcardType)
+ adaptTypeArg(arg1, if (tparam.isCompleted) tparam.info else WildcardType)
+ }
+ val args1 = args.zipWithConserve(tparams)(typedArg(_, _)).asInstanceOf[List[Tree]]
+ // check that arguments conform to bounds is done in phase PostTyper
+ assignType(cpy.AppliedTypeTree(tree)(tpt1, args1), tpt1, args1)
}
- 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)
}
def typedByNameTypeTree(tree: untpd.ByNameTypeTree)(implicit ctx: Context): ByNameTypeTree = track("typedByNameTypeTree") {