diff --git a/compiler/src/dotty/tools/dotc/typer/Namer.scala b/compiler/src/dotty/tools/dotc/typer/Namer.scala index 677beac079fb..aa0b1eccfc4c 100644 --- a/compiler/src/dotty/tools/dotc/typer/Namer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Namer.scala @@ -1032,10 +1032,13 @@ class Namer { typer: Typer => val forwarder = if mbr.isType then val forwarderName = checkNoConflict(alias.toTypeName, isPrivate = false, span) + var target = path.tpe.select(sym) + if target.typeParams.nonEmpty then + target = target.EtaExpand(target.typeParams) newSymbol( cls, forwarderName, Exported | Final, - TypeAlias(path.tpe.select(sym)), + TypeAlias(target), coord = span) // Note: This will always create unparameterzied aliases. So even if the original type is // a parameterized class, say `C[X]` the alias will read `type C = d.C`. We currently do diff --git a/tests/pos/i11922.scala b/tests/pos/i11922.scala new file mode 100644 index 000000000000..4e9011b15aba --- /dev/null +++ b/tests/pos/i11922.scala @@ -0,0 +1,17 @@ +object example { + trait MyType[A] + type Alias[A, B] = MyType[B] +} + +object bug { + export example.{MyType, Alias} + def bug[A](m: MyType[A]): MyType[A] = m + val bug2: MyType[String] => MyType[String] = m => m + def bug3[A, B](m: Alias[A, B]): MyType[B] = m + def bug4[A, B](m: Alias[A, B]): Alias[Int, B] = m + + //it works when referencing the original type in the parameter position. + def thisWorks[A](m: example.MyType[A]): MyType[A] = m + val thisWorks2: example.MyType[String] => MyType[String] = m => m + val thisWorks3: MyType[String] = (??? : MyType[String]) +} \ No newline at end of file