From 3eb114351520b16028f9fbcd7a2fcdd6c7e0f5c7 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Tue, 14 Jul 2015 12:35:16 +0200 Subject: 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. --- src/dotty/tools/dotc/typer/Typer.scala | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/dotty/tools/dotc/typer/Typer.scala') 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) } -- cgit v1.2.3