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