File tree 2 files changed +18
-16
lines changed
compiler/src/dotty/tools/dotc
2 files changed +18
-16
lines changed Original file line number Diff line number Diff line change @@ -321,6 +321,22 @@ class TypeApplications(val self: Type) extends AnyVal {
321
321
}
322
322
}
323
323
324
+ // Like `target.etaExpand(target.typeParams)`
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))))
339
+
324
340
/** Maps [Ts] => C[Ts] to C */
325
341
def etaCollapse (using Context ): Type = self match
326
342
case EtaExpansion (classType) => classType
Original file line number Diff line number Diff line change @@ -1196,22 +1196,8 @@ class Namer { typer: Typer =>
1196
1196
if mbr.isType then
1197
1197
val forwarderName = checkNoConflict(alias.toTypeName, isPrivate = false , span)
1198
1198
var target = pathType.select(sym)
1199
- val tparams = target.typeParams
1200
- if tparams.nonEmpty then
1201
- // like `target = target.etaExpand(target.typeParams)`
1202
- // except call `asSeenFrom` to fix class type parameter bounds
1203
- // e.g. in pos/i18569:
1204
- // `Test#F` should have `M2.A` or `Test.A` as bounds, not `M1#A`.
1205
- target = HKTypeLambda (tparams.map(_.paramName))(
1206
- tl => tparams.map {
1207
- case p : Symbol =>
1208
- val info = p.info.asSeenFrom(pathType, sym.owner)
1209
- HKTypeLambda .toPInfo(tl.integrate(tparams, info))
1210
- case p =>
1211
- val info = p.paramInfo
1212
- HKTypeLambda .toPInfo(tl.integrate(tparams, info))
1213
- },
1214
- tl => tl.integrate(tparams, target.appliedTo(tparams.map(_.paramRef))))
1199
+ if target.typeParams.nonEmpty then
1200
+ target = target.etaExpandWithAsf(pathType, sym.owner)
1215
1201
newSymbol(
1216
1202
cls, forwarderName,
1217
1203
Exported | Final ,
You can’t perform that action at this time.
0 commit comments