From 6ed74c3a2f38aadfb0bf2110cae00309b9050708 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Thu, 24 Jan 2013 14:59:45 +0100 Subject: Allows for NoType in AplliedType argument lists, as well as argument lists that are shorter than type parameter lists. --- src/dotty/tools/dotc/core/Types.scala | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/dotty/tools/dotc/core/Types.scala') diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index 460265e3d..dc8c7c9f1 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -409,7 +409,15 @@ object Types { */ final def typeParams(implicit ctx: Context): List[TypeSymbol] = this match { case tp: AppliedType => - tp.tycon.typeParams drop tp.targs.length + def loop(tparams: List[TypeSymbol], targs: List[Type]): List[TypeSymbol] = tparams match { + case tparam :: tparams1 => + if (targs.isEmpty) tparams + else if (targs.head eq NoType) loop(tparams1, targs.tail) + else tparam :: loop(tparams1, targs.tail) + case _ => + Nil + } + loop(tp.tycon.typeParams, tp.targs) case tp: TypeProxy => tp.underlying.typeParams case tp: ClassInfo => @@ -701,6 +709,10 @@ object Types { // --- AppliedType ----------------------------------------------------------------- + /** An applied type of the form tycon[..targs]. + * ..targs must match the length to tycon.typeParams. + * Missing type arguments are represented by NoType. + */ abstract case class AppliedType(tycon: Type, targs: List[Type]) extends CachedProxyType { override def underlying(implicit ctx: Context) = tycon -- cgit v1.2.3