diff options
author | Martin Odersky <odersky@gmail.com> | 2013-01-24 14:59:45 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2013-01-24 15:18:41 +0100 |
commit | 6ed74c3a2f38aadfb0bf2110cae00309b9050708 (patch) | |
tree | a779c0b79a144ba4df8b284f21defd17972f8f42 /src/dotty/tools/dotc/core/Types.scala | |
parent | 41c884462cb017398573a19412e987991f15a232 (diff) | |
download | dotty-6ed74c3a2f38aadfb0bf2110cae00309b9050708.tar.gz dotty-6ed74c3a2f38aadfb0bf2110cae00309b9050708.tar.bz2 dotty-6ed74c3a2f38aadfb0bf2110cae00309b9050708.zip |
Allows for NoType in AplliedType argument lists, as well as argument lists that are shorter than type parameter lists.
Diffstat (limited to 'src/dotty/tools/dotc/core/Types.scala')
-rw-r--r-- | src/dotty/tools/dotc/core/Types.scala | 14 |
1 files changed, 13 insertions, 1 deletions
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 |