aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/typer/Typer.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-07-14 12:35:16 +0200
committerMartin Odersky <odersky@gmail.com>2015-09-18 18:05:14 +0200
commit3eb114351520b16028f9fbcd7a2fcdd6c7e0f5c7 (patch)
tree82e0fec74f744b2712937f84ad5a42c812ec208e /src/dotty/tools/dotc/typer/Typer.scala
parent92fe081bcdf7f02cd65350463db2d3d4fa72f1eb (diff)
downloaddotty-3eb114351520b16028f9fbcd7a2fcdd6c7e0f5c7.tar.gz
dotty-3eb114351520b16028f9fbcd7a2fcdd6c7e0f5c7.tar.bz2
dotty-3eb114351520b16028f9fbcd7a2fcdd6c7e0f5c7.zip
Check argument lengths in typedAppliedTypeTree
With the hk-types schem changed, we need to make sure that actual and formal argument lists of parameterized types have the same length.
Diffstat (limited to 'src/dotty/tools/dotc/typer/Typer.scala')
-rw-r--r--src/dotty/tools/dotc/typer/Typer.scala14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala
index a2c49cdd9..58c017534 100644
--- a/src/dotty/tools/dotc/typer/Typer.scala
+++ b/src/dotty/tools/dotc/typer/Typer.scala
@@ -830,8 +830,18 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
val argPts =
if (ctx.mode is Mode.Pattern) tpt1.tpe.typeParams.map(_.info)
else tree.args.map(_ => WildcardType)
- val args1 = tree.args.zipWithConserve(argPts)(typed(_, _)).asInstanceOf[List[Tree]]
- // check that arguments conform to bounds is done in phase FirstTransform
+ val tparams = tpt1.tpe.typeParams
+ var args = tree.args
+ if (tparams.isEmpty) {
+ 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)
+ }
+ val args1 = args.zipWithConserve(argPts)(typed(_, _)).asInstanceOf[List[Tree]]
+ // check that arguments conform to bounds is done in phase PostTyper
assignType(cpy.AppliedTypeTree(tree)(tpt1, args1), tpt1, args1)
}