Skip to content

Commit 68905c1

Browse files
committed
Fix the tparam bounds of exported inherited classes
When trying to export M2.F, seeing M1#F from the prefix M2 doesn't change the bounds of F's T type parameter, which still refers to M1.this.A, rather than M2.A. So, we run asSeenFrom against that info, when eta-expanding the class into a hk type lambda.
1 parent de4ad2b commit 68905c1

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

compiler/src/dotty/tools/dotc/typer/Namer.scala

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,8 +1175,14 @@ class Namer { typer: Typer =>
11751175
if mbr.isType then
11761176
val forwarderName = checkNoConflict(alias.toTypeName, isPrivate = false, span)
11771177
var target = pathType.select(sym)
1178-
if target.typeParams.nonEmpty then
1179-
target = target.EtaExpand(target.typeParams)
1178+
val tparams = target.typeParamSymbols
1179+
if tparams.nonEmpty then
1180+
target = HKTypeLambda(tparams.map(_.paramName))(
1181+
tl => tparams.map { p =>
1182+
val info = p.info.asSeenFrom(pathType, sym.owner)
1183+
HKTypeLambda.toPInfo(tl.integrate(tparams, info))
1184+
},
1185+
tl => tl.integrate(tparams, target.appliedTo(tparams.map(_.paramRef))))
11801186
newSymbol(
11811187
cls, forwarderName,
11821188
Exported | Final,

tests/pos/i18569.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
trait M1:
2+
trait A
3+
trait F[T <: A]
4+
5+
object M2 extends M1
6+
7+
trait Test:
8+
export M2.*
9+
def y: F[A]

0 commit comments

Comments
 (0)