File tree 2 files changed +21
-1
lines changed
compiler/src/dotty/tools/dotc/typer
2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -1032,10 +1032,13 @@ class Namer { typer: Typer =>
1032
1032
val forwarder =
1033
1033
if mbr.isType then
1034
1034
val forwarderName = checkNoConflict(alias.toTypeName, isPrivate = false , span)
1035
+ var target = path.tpe.select(sym)
1036
+ if target.typeParams.nonEmpty then
1037
+ target = target.EtaExpand (target.typeParams)
1035
1038
newSymbol(
1036
1039
cls, forwarderName,
1037
1040
Exported | Final ,
1038
- TypeAlias (path.tpe.select(sym) ),
1041
+ TypeAlias (target ),
1039
1042
coord = span)
1040
1043
// Note: This will always create unparameterzied aliases. So even if the original type is
1041
1044
// a parameterized class, say `C[X]` the alias will read `type C = d.C`. We currently do
Original file line number Diff line number Diff line change
1
+ object example {
2
+ trait MyType [A ]
3
+ type Alias [A , B ] = MyType [B ]
4
+ }
5
+
6
+ object bug {
7
+ export example .{MyType , Alias }
8
+ def bug [A ](m : MyType [A ]): MyType [A ] = m
9
+ val bug2 : MyType [String ] => MyType [String ] = m => m
10
+ def bug3 [A , B ](m : Alias [A , B ]): MyType [B ] = m
11
+ def bug4 [A , B ](m : Alias [A , B ]): Alias [Int , B ] = m
12
+
13
+ // it works when referencing the original type in the parameter position.
14
+ def thisWorks [A ](m : example.MyType [A ]): MyType [A ] = m
15
+ val thisWorks2 : example.MyType [String ] => MyType [String ] = m => m
16
+ val thisWorks3 : MyType [String ] = (??? : MyType [String ])
17
+ }
You can’t perform that action at this time.
0 commit comments