diff options
author | Martin Odersky <odersky@gmail.com> | 2015-12-02 16:00:07 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2015-12-06 16:09:21 +0100 |
commit | 73bf06b4735b8a74c99ed185e52ae3350181f426 (patch) | |
tree | 60320e0261ebc0eecf54e5aedf99311f762cef78 /src/dotty/tools/dotc/typer/Namer.scala | |
parent | 2abcd02d2a2067ba78430262664f5d3ab9b61d00 (diff) | |
download | dotty-73bf06b4735b8a74c99ed185e52ae3350181f426.tar.gz dotty-73bf06b4735b8a74c99ed185e52ae3350181f426.tar.bz2 dotty-73bf06b4735b8a74c99ed185e52ae3350181f426.zip |
More uses of adaptIfHK
Also: fix EtaExpansion.
Also: Add some debug code to Applications, awaiting further fixes.
Diffstat (limited to 'src/dotty/tools/dotc/typer/Namer.scala')
-rw-r--r-- | src/dotty/tools/dotc/typer/Namer.scala | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/src/dotty/tools/dotc/typer/Namer.scala b/src/dotty/tools/dotc/typer/Namer.scala index 5eebdbad1..eecbd1347 100644 --- a/src/dotty/tools/dotc/typer/Namer.scala +++ b/src/dotty/tools/dotc/typer/Namer.scala @@ -18,6 +18,7 @@ import config.Printers._ import Annotations._ import Inferencing._ import transform.ValueClasses._ +import TypeApplications._ import language.implicitConversions trait NamerContextOps { this: Context => @@ -840,26 +841,23 @@ class Namer { typer: Typer => /** Eta expand all class types C appearing as arguments to a higher-kinded * type parameter to type lambdas, e.g. [HK0] => C[HK0]. This is necessary - * because in `typedAppliedTypeTree` we might ahve missed some eta expansions + * because in `typedAppliedTypeTree` we might have missed some eta expansions * of arguments in F-bounds, because the recursive type was initialized with * TypeBounds.empty. */ + // ### Check whether this is still needed! def etaExpandArgs(implicit ctx: Context) = new TypeMap { - def apply(tp: Type): Type = { - tp match { - case tp: RefinedType => - val args = tp.argInfos.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)((arg, tparam) => arg.EtaExpandIfHK(tparam.info)) - if (args1 ne args) return this(tycon).appliedTo(args1) - } - } - case _ => - } - mapOver(tp) + def apply(tp: Type): Type = tp match { + case tp: RefinedType => + val args = tp.argInfos.mapconserve(this) + if (args.nonEmpty) { + val tycon = tp.withoutArgs(args) + val tycon1 = this(tycon) + val tparams = tycon.typeParams + val args1 = if (args.length == tparams.length) adaptArgs(tparams, args) else args + if ((tycon1 eq tycon) && (args1 eq args)) tp else tycon1.appliedTo(args1) + } else mapOver(tp) + case _ => mapOver(tp) } } } |