@@ -36,7 +36,7 @@ object TypeApplications {
3636
3737 def apply (tycon : Type )(using Context ): Type =
3838 assert(tycon.typeParams.nonEmpty, tycon)
39- tycon.EtaExpand (tycon.typeParamSymbols)
39+ tycon.etaExpand (tycon.typeParamSymbols)
4040
4141 /** Test that the parameter bounds in a hk type lambda `[X1,...,Xn] => C[X1, ..., Xn]`
4242 * contain the bounds of the type parameters of `C`. This is necessary to be able to
@@ -71,7 +71,7 @@ object TypeApplications {
7171 */
7272 def EtaExpandIfHK (tparams : List [TypeParamInfo ], args : List [Type ])(using Context ): List [Type ] =
7373 if (tparams.isEmpty) args
74- else args.zipWithConserve(tparams)((arg, tparam) => arg.EtaExpandIfHK (tparam.paramInfoOrCompleter))
74+ else args.zipWithConserve(tparams)((arg, tparam) => arg.etaExpandIfHK (tparam.paramInfoOrCompleter))
7575
7676 /** A type map that tries to reduce (part of) the result type of the type lambda `tycon`
7777 * with the given `args`(some of which are wildcard arguments represented by type bounds).
@@ -245,7 +245,7 @@ class TypeApplications(val self: Type) extends AnyVal {
245245 def topType (using Context ): Type =
246246 if self.hasSimpleKind then
247247 defn.AnyType
248- else EtaExpand (self.typeParams) match
248+ else etaExpand (self.typeParams) match
249249 case tp : HKTypeLambda =>
250250 tp.derivedLambdaType(resType = tp.resultType.topType)
251251 case _ =>
@@ -302,7 +302,7 @@ class TypeApplications(val self: Type) extends AnyVal {
302302 /** Convert a type constructor `TC` which has type parameters `X1, ..., Xn`
303303 * to `[X1, ..., Xn] -> TC[X1, ..., Xn]`.
304304 */
305- def EtaExpand (tparams : List [TypeParamInfo ])(using Context ): Type =
305+ def etaExpand (tparams : List [TypeParamInfo ])(using Context ): Type =
306306 HKTypeLambda .fromParams(tparams, self.appliedTo(tparams.map(_.paramRef)))
307307 // .ensuring(res => res.EtaReduce =:= self, s"res = $res, core = ${res.EtaReduce}, self = $self, hc = ${res.hashCode}")
308308
@@ -311,7 +311,7 @@ class TypeApplications(val self: Type) extends AnyVal {
311311 if (isLambdaSub) self else EtaExpansion (self)
312312
313313 /** Eta expand if `self` is a (non-lambda) class reference and `bound` is a higher-kinded type */
314- def EtaExpandIfHK (bound : Type )(using Context ): Type = {
314+ def etaExpandIfHK (bound : Type )(using Context ): Type = {
315315 val hkParams = bound.hkTypeParams
316316 if (hkParams.isEmpty) self
317317 else self match {
@@ -321,6 +321,11 @@ class TypeApplications(val self: Type) extends AnyVal {
321321 }
322322 }
323323
324+ /** Maps [Ts] => C[Ts] to C */
325+ def etaCollapse (using Context ): Type = self match
326+ case EtaExpansion (classType) => classType
327+ case _ => self
328+
324329 /** The type representing
325330 *
326331 * T[U1, ..., Un]
0 commit comments