aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-07-14 12:50:39 +0200
committerMartin Odersky <odersky@gmail.com>2015-09-18 18:05:15 +0200
commit0d95c76466012f9a7e6535ebba0620df4042f179 (patch)
tree657b5298c6d7cb4bfa3be20172edea811bf48ddd /src
parent0bdee32e8b35b6c994248def87cb8f6f874572dd (diff)
downloaddotty-0d95c76466012f9a7e6535ebba0620df4042f179.tar.gz
dotty-0d95c76466012f9a7e6535ebba0620df4042f179.tar.bz2
dotty-0d95c76466012f9a7e6535ebba0620df4042f179.zip
Turn assertion into a test in etaExpandArgs.
Erreneous programs could have a difference in lengths between type parameters and type args, but this is tested anyway in Typer.
Diffstat (limited to 'src')
-rw-r--r--src/dotty/tools/dotc/typer/Namer.scala28
1 files changed, 15 insertions, 13 deletions
diff --git a/src/dotty/tools/dotc/typer/Namer.scala b/src/dotty/tools/dotc/typer/Namer.scala
index 9df928f12..8b204debb 100644
--- a/src/dotty/tools/dotc/typer/Namer.scala
+++ b/src/dotty/tools/dotc/typer/Namer.scala
@@ -814,19 +814,21 @@ class Namer { typer: Typer =>
def etaExpandArg(tp: Type, tparam: Symbol): Type =
if (tparam.info.isLambda && tp.typeSymbol.isClass && tp.isLambda) tp.EtaExpand
else tp
- def apply(tp: Type) = tp match {
- case tp: RefinedType =>
- val args = tp.argInfos(interpolate = false).mapconserve(this)
- if (args.nonEmpty) {
- val tycon = tp.withoutArgs(args)
- val tparams = tycon.typeParams
- assert(args.length == tparams.length,
- i"lengths differ in $tp: args = $args%, %, type params of $tycon = $tparams%, %")
- this(tycon).appliedTo(args.zipWithConserve(tparams)(etaExpandArg))
- }
- else mapOver(tp)
- case _ =>
- mapOver(tp)
+ def apply(tp: Type): Type = {
+ tp match {
+ case tp: RefinedType =>
+ val args = tp.argInfos(interpolate = false).mapconserve(this)
+ if (args.nonEmpty) {
+ val tycon = tp.withoutArgs(args)
+ val tparams = tycon.typeParams
+ if (args.length == tparams.length) { // if lengths differ, problem is caught in typedTypeApply
+ val args1 = args.zipWithConserve(tparams)(etaExpandArg)
+ if (args1 ne args) return this(tycon).appliedTo(args1)
+ }
+ }
+ case _ =>
+ }
+ mapOver(tp)
}
}
}