diff options
author | Martin Odersky <odersky@gmail.com> | 2015-07-14 17:37:52 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2015-09-18 18:05:15 +0200 |
commit | fdf8f867fa1a1d2493052b19bd50907f1b5d75e8 (patch) | |
tree | b4b6126e16a705000fc569a505b9c579314a7f5b | |
parent | 0d95c76466012f9a7e6535ebba0620df4042f179 (diff) | |
download | dotty-fdf8f867fa1a1d2493052b19bd50907f1b5d75e8.tar.gz dotty-fdf8f867fa1a1d2493052b19bd50907f1b5d75e8.tar.bz2 dotty-fdf8f867fa1a1d2493052b19bd50907f1b5d75e8.zip |
Fix argument eta expansion
... and move to TypeApplications. isLambda test
was the wrong way before.
-rw-r--r-- | src/dotty/tools/dotc/core/TypeApplications.scala | 3 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/Namer.scala | 5 |
2 files changed, 4 insertions, 4 deletions
diff --git a/src/dotty/tools/dotc/core/TypeApplications.scala b/src/dotty/tools/dotc/core/TypeApplications.scala index f4f14101d..6d3b7ac47 100644 --- a/src/dotty/tools/dotc/core/TypeApplications.scala +++ b/src/dotty/tools/dotc/core/TypeApplications.scala @@ -540,6 +540,9 @@ class TypeApplications(val self: Type) extends AnyVal { self.appliedTo(tparams map (_.typeRef)).LambdaAbstract(tparams) } + def EtaExpandIfLambda(bound: Type)(implicit ctx: Context): Type = + if (bound.isLambda && self.typeSymbol.isClass && !isLambda) EtaExpand else self + /** Test whether this type has a base type of the form `B[T1, ..., Bn]` where * the type parameters of `B` match one-by-one the variances of `tparams`, * and where the lambda abstracted type diff --git a/src/dotty/tools/dotc/typer/Namer.scala b/src/dotty/tools/dotc/typer/Namer.scala index 8b204debb..eef0ce8b0 100644 --- a/src/dotty/tools/dotc/typer/Namer.scala +++ b/src/dotty/tools/dotc/typer/Namer.scala @@ -811,9 +811,6 @@ class Namer { typer: Typer => * type parameter to type lambdas, e.g. [HK0] => C[HK0] */ def etaExpandArgs(implicit ctx: Context) = new TypeMap { - def etaExpandArg(tp: Type, tparam: Symbol): Type = - if (tparam.info.isLambda && tp.typeSymbol.isClass && tp.isLambda) tp.EtaExpand - else tp def apply(tp: Type): Type = { tp match { case tp: RefinedType => @@ -822,7 +819,7 @@ class Namer { typer: Typer => 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) + val args1 = args.zipWithConserve(tparams)((arg, tparam) => arg.EtaExpandIfLambda(tparam.info)) if (args1 ne args) return this(tycon).appliedTo(args1) } } |