Skip to content

Commit

Permalink
Fix scala#7219: export forwarder should use TypeAlias for parameterle…
Browse files Browse the repository at this point in the history
…ss class
  • Loading branch information
liufengyun committed Sep 13, 2019
1 parent 1d5e95e commit 300b427
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
3 changes: 2 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/Namer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,8 @@ class Namer { typer: Typer =>
*/
def fwdInfo(ref: Type, info: Type): Type = info match {
case _: ClassInfo =>
HKTypeLambda.fromParams(info.typeParams, ref)
if (info.typeParams.isEmpty) TypeAlias(ref)
else HKTypeLambda.fromParams(info.typeParams, ref)
case _: TypeBounds =>
TypeAlias(ref)
case info: HKTypeLambda =>
Expand Down
24 changes: 24 additions & 0 deletions tests/pos-special/fatal-warnings/i7219.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
object Foo {
enum MyEnum {
case Red
case Blue(msg: String)
}
export MyEnum._
}

object Bar {
type Blue = Foo.Blue

// Related Issue -- my expectation is that
// `export Foo.Blue` should be equivalent to
// `type Blue = Foo.Blue`, but it's not:

// export Foo.Blue // Uncommenting this (and commenting `type Blue = ...`) results in compile error
}

import Foo._

def foo(a: MyEnum): Seq[Bar.Blue] = a match {
case Red => Seq.empty
case m: Foo.Blue => Seq(m)
}
9 changes: 9 additions & 0 deletions tests/pos/i7219.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class Foo {
object MyEnum {
class Blue
}
export MyEnum._

val a: MyEnum.Blue = ???
a : Blue // ok
}

0 comments on commit 300b427

Please sign in to comment.