Skip to content

Commit 4d14e7e

Browse files
liufengyunodersky
authored andcommitted
Fix #7219: export forwarder should use TypeAlias for parameterless class
1 parent 19b4216 commit 4d14e7e

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,8 @@ class Namer { typer: Typer =>
982982
*/
983983
def fwdInfo(ref: Type, info: Type): Type = info match {
984984
case _: ClassInfo =>
985-
HKTypeLambda.fromParams(info.typeParams, ref)
985+
if (info.typeParams.isEmpty) TypeAlias(ref)
986+
else HKTypeLambda.fromParams(info.typeParams, ref)
986987
case _: TypeBounds =>
987988
TypeAlias(ref)
988989
case info: HKTypeLambda =>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
object Foo {
2+
enum MyEnum {
3+
case Red
4+
case Blue(msg: String)
5+
}
6+
export MyEnum._
7+
}
8+
9+
object Bar {
10+
type Blue = Foo.Blue
11+
12+
// Related Issue -- my expectation is that
13+
// `export Foo.Blue` should be equivalent to
14+
// `type Blue = Foo.Blue`, but it's not:
15+
16+
// export Foo.Blue // Uncommenting this (and commenting `type Blue = ...`) results in compile error
17+
}
18+
19+
import Foo._
20+
21+
def foo(a: MyEnum): Seq[Bar.Blue] = a match {
22+
case Red => Seq.empty
23+
case m: Foo.Blue => Seq(m)
24+
}

tests/pos/i7219.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class Foo {
2+
object MyEnum {
3+
class Blue
4+
}
5+
export MyEnum._
6+
7+
val a: MyEnum.Blue = ???
8+
a : Blue // ok
9+
}

0 commit comments

Comments
 (0)