Skip to content

Commit bcb20c4

Browse files
committed
Generalize EtaExpand
make it work for al kinds of ParamInfos.
1 parent 8c80c31 commit bcb20c4

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

compiler/src/dotty/tools/dotc/core/TypeApplications.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,8 @@ class TypeApplications(val self: Type) extends AnyVal {
250250
/** Convert a type constructor `TC` which has type parameters `X1, ..., Xn`
251251
* to `[X1, ..., Xn] -> TC[X1, ..., Xn]`.
252252
*/
253-
def EtaExpand(tparams: List[TypeSymbol])(implicit ctx: Context): Type =
254-
HKTypeLambda.fromParams(tparams, self.appliedTo(tparams.map(_.typeRef)))
253+
def EtaExpand(tparams: List[TypeParamInfo])(implicit ctx: Context): Type =
254+
HKTypeLambda.fromParams(tparams, self.appliedTo(tparams.map(_.paramRef)))
255255
//.ensuring(res => res.EtaReduce =:= self, s"res = $res, core = ${res.EtaReduce}, self = $self, hc = ${res.hashCode}")
256256

257257
/** If self is not lambda-bound, eta expand it. */
@@ -361,7 +361,7 @@ class TypeApplications(val self: Type) extends AnyVal {
361361
}
362362

363363
/** Turns non-bounds types to type bounds.
364-
* A (possible lambda abstracted) match type is turned into an abstract type.
364+
* A (possible lambda abstracted) match type is turned into a match alias.
365365
* Every other type is turned into a type alias
366366
*/
367367
final def toBounds(implicit ctx: Context): TypeBounds = self match {

compiler/src/dotty/tools/dotc/core/TypeComparer.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -602,10 +602,8 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] w
602602
case _ =>
603603
val tparams1 = tp1.typeParams
604604
if (tparams1.nonEmpty)
605-
return recur(
606-
HKTypeLambda.fromParams(tparams1, tp1.appliedTo(tparams1.map(_.paramRef))),
607-
tp2) || fourthTry
608-
else tp2 match {
605+
return recur(tp1.EtaExpand(tparams1), tp2) || fourthTry
606+
tp2 match {
609607
case EtaExpansion(tycon2) if tycon2.symbol.isClass =>
610608
return recur(tp1, tycon2)
611609
case _ =>

0 commit comments

Comments
 (0)