@@ -322,19 +322,23 @@ class TypeApplications(val self: Type) extends AnyVal {
322322
323323 // Like `target.etaExpand(target.typeParams)`
324324 // except call `asSeenFrom` to fix class type parameter bounds
325- // e.g. in pos/i18569:
326- // given prefix `M2.type` and symbol `trait F`
327- // the result of `prefix.select(sym)` is `M2.F`
328- // however F's type parameter T is `<: M1#A` rather than `<: M2.A`
329- // so add a call to `asSeenFrom` with prefix `M2.type` and owner `trait M1`
330- def etaExpandWithAsf (prefix : Type , owner : Symbol )(using Context ): Type =
331- val tparams = self.typeParams
332- HKTypeLambda (tparams.map(_.paramName))(
333- tl => tparams.map {
334- case p : Symbol => HKTypeLambda .toPInfo(tl.integrate(tparams, p.info.asSeenFrom(prefix, owner)))
335- case p => HKTypeLambda .toPInfo(tl.integrate(tparams, p.paramInfo))
336- },
337- tl => tl.integrate(tparams, self.appliedTo(tparams.map(_.paramRef))))
325+ // e.g. from pos/i18569:
326+ // trait M1:
327+ // trait A
328+ // trait F[T <: A]
329+ // object M2 extends M1
330+ // Type parameter T in M2.F has an upper bound of M1#A instead of M2.A
331+ // So we take the prefix M2.type and the F symbol's owner, M1,
332+ // to call asSeenFrom on T's info.
333+ def etaExpandWithAsf (using Context ): Type = self match
334+ case self : TypeRef if self.symbol.isClass =>
335+ val tparams = self.symbol.typeParams
336+ val prefix = self.prefix
337+ val owner = self.symbol.owner
338+ HKTypeLambda (tparams.map(_.paramName))(
339+ tl => tparams.map(p => HKTypeLambda .toPInfo(tl.integrate(tparams, p.info.asSeenFrom(prefix, owner)))),
340+ tl => tl.integrate(tparams, self.appliedTo(tparams.map(_.paramRef))))
341+ case _ => etaExpand(typeParams)
338342
339343 /** Maps [Ts] => C[Ts] to C */
340344 def etaCollapse (using Context ): Type = self match
0 commit comments