diff options
author | Martin Odersky <odersky@gmail.com> | 2016-06-02 18:59:42 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-07-11 13:35:00 +0200 |
commit | a7d61c0ffc99c52109937c899c789ad9ea5d6a5b (patch) | |
tree | 9f66a72a4852dd3031a8136bb061d16a0f204336 /src/dotty | |
parent | e61b80ae4db8d2fdd7ed43a834f0de86d1edda15 (diff) | |
download | dotty-a7d61c0ffc99c52109937c899c789ad9ea5d6a5b.tar.gz dotty-a7d61c0ffc99c52109937c899c789ad9ea5d6a5b.tar.bz2 dotty-a7d61c0ffc99c52109937c899c789ad9ea5d6a5b.zip |
Make etaExpandIfHk work for non-symbol type params
Fixes a crasher in t2994.scala
Diffstat (limited to 'src/dotty')
-rw-r--r-- | src/dotty/tools/dotc/core/TypeApplications.scala | 12 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/Namer.scala | 2 |
2 files changed, 10 insertions, 4 deletions
diff --git a/src/dotty/tools/dotc/core/TypeApplications.scala b/src/dotty/tools/dotc/core/TypeApplications.scala index dfd1caf62..c270288b2 100644 --- a/src/dotty/tools/dotc/core/TypeApplications.scala +++ b/src/dotty/tools/dotc/core/TypeApplications.scala @@ -236,9 +236,15 @@ object TypeApplications { /** Adapt all arguments to possible higher-kinded type parameters using etaExpandIfHK */ - def etaExpandIfHK(tparams: List[Symbol], args: List[Type])(implicit ctx: Context): List[Type] = + def etaExpandIfHK(tparams: List[MemberBinding], args: List[Type])(implicit ctx: Context): List[Type] = if (tparams.isEmpty) args - else args.zipWithConserve(tparams)((arg, tparam) => arg.etaExpandIfHK(tparam.infoOrCompleter)) + else { + def bounds(tparam: MemberBinding) = tparam match { + case tparam: Symbol => tparam.infoOrCompleter + case tparam: RefinedType => tparam.memberBounds + } + args.zipWithConserve(tparams)((arg, tparam) => arg.etaExpandIfHK(bounds(tparam))) + } /** The references `<rt>.this.$hk0, ..., <rt>.this.$hk<n-1>`. */ def argRefs(rt: RefinedType, n: Int)(implicit ctx: Context) = @@ -374,7 +380,7 @@ class TypeApplications(val self: Type) extends AnyVal { final def typeParamSymbols(implicit ctx: Context): List[TypeSymbol] = { val tparams = typeParams - assert(tparams.isEmpty || tparams.head.isInstanceOf[Symbol]) + assert(tparams.isEmpty || tparams.head.isInstanceOf[Symbol], self) tparams.asInstanceOf[List[TypeSymbol]] } diff --git a/src/dotty/tools/dotc/typer/Namer.scala b/src/dotty/tools/dotc/typer/Namer.scala index 8437b651c..a8f3b8918 100644 --- a/src/dotty/tools/dotc/typer/Namer.scala +++ b/src/dotty/tools/dotc/typer/Namer.scala @@ -989,7 +989,7 @@ class Namer { typer: Typer => if (args.nonEmpty) { val tycon = tp.withoutArgs(args) val tycon1 = this(tycon) - val tparams = tycon.typeParamSymbols + val tparams = tycon.typeParams val args1 = if (args.length == tparams.length) etaExpandIfHK(tparams, args) else args if ((tycon1 eq tycon) && (args1 eq args)) tp else tycon1.appliedTo(args1) } else mapOver(tp) |