Skip to content

Commit

Permalink
Fix the tparam bounds of exported inherited classes
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dwijnand committed Oct 4, 2023
1 parent de4ad2b commit 68905c1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
10 changes: 8 additions & 2 deletions compiler/src/dotty/tools/dotc/typer/Namer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1175,8 +1175,14 @@ class Namer { typer: Typer =>
if mbr.isType then
val forwarderName = checkNoConflict(alias.toTypeName, isPrivate = false, span)
var target = pathType.select(sym)
if target.typeParams.nonEmpty then
target = target.EtaExpand(target.typeParams)
val tparams = target.typeParamSymbols
if tparams.nonEmpty then
target = HKTypeLambda(tparams.map(_.paramName))(
tl => tparams.map { p =>
val info = p.info.asSeenFrom(pathType, sym.owner)
HKTypeLambda.toPInfo(tl.integrate(tparams, info))
},
tl => tl.integrate(tparams, target.appliedTo(tparams.map(_.paramRef))))
newSymbol(
cls, forwarderName,
Exported | Final,
Expand Down
9 changes: 9 additions & 0 deletions tests/pos/i18569.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
trait M1:
trait A
trait F[T <: A]

object M2 extends M1

trait Test:
export M2.*
def y: F[A]

0 comments on commit 68905c1

Please sign in to comment.