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