From 3b992918f661d07ab80889ce512a7f6df5917f72 Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Wed, 4 Oct 2023 13:53:17 +0100 Subject: [PATCH] Fix info of ASF nested class Class M1#F asSeenFrom M2 has type parameters with info of the original owner/prefix (M1). So running asSeenFrom against that info fixes the eta-expanded lambda. --- compiler/src/dotty/tools/dotc/typer/Namer.scala | 8 ++++++-- tests/pos/i18569.scala | 9 +++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 tests/pos/i18569.scala diff --git a/compiler/src/dotty/tools/dotc/typer/Namer.scala b/compiler/src/dotty/tools/dotc/typer/Namer.scala index 8ed881ca0d81..904cba8f67b5 100644 --- a/compiler/src/dotty/tools/dotc/typer/Namer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Namer.scala @@ -1175,8 +1175,12 @@ 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 => + HKTypeLambda.toPInfo(tl.integrate(tparams, p.info.asSeenFrom(pathType, sym.owner)))), + tl => tl.integrate(tparams, target.appliedTo(tparams.map(_.paramRef)))) newSymbol( cls, forwarderName, Exported | Final, diff --git a/tests/pos/i18569.scala b/tests/pos/i18569.scala new file mode 100644 index 000000000000..7dcdd5e68d6e --- /dev/null +++ b/tests/pos/i18569.scala @@ -0,0 +1,9 @@ +trait M1: + trait A + trait F[T <: A] + +object M2 extends M1 + +trait Test: + export M2.* + def y: F[A]