aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dotty/tools/dotc/core/TypeApplications.scala3
-rw-r--r--src/dotty/tools/dotc/typer/Namer.scala5
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)
}
}