Skip to content

Commit 3d46063

Browse files
committed
Define topLevelClass for NoDenotation
1 parent 2164c42 commit 3d46063

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

compiler/src/dotty/tools/dotc/core/SymDenotations.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,7 @@ object SymDenotations {
925925
/** The top-level class containing this denotation,
926926
* except for a toplevel module, where its module class is returned.
927927
*/
928-
final def topLevelClass(implicit ctx: Context): Symbol = {
928+
def topLevelClass(implicit ctx: Context): Symbol = {
929929
def topLevel(d: SymDenotation): Symbol = {
930930
if (d.isEffectiveRoot || (d is PackageClass) || (d.owner is PackageClass)) d.symbol
931931
else topLevel(d.owner)
@@ -1877,6 +1877,7 @@ object SymDenotations {
18771877
override def owner: Symbol = throw new AssertionError("NoDenotation.owner")
18781878
override def computeAsSeenFrom(pre: Type)(implicit ctx: Context): SingleDenotation = this
18791879
override def mapInfo(f: Type => Type)(implicit ctx: Context): SingleDenotation = this
1880+
override def topLevelClass(implicit ctx: Context): Symbol = symbol
18801881
NoSymbol.denot = this
18811882
validFor = Period.allInRun(NoRunId)
18821883
}

tests/pos/i3647.scala

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
object App {
2+
def main(args: Array[String]): Unit = {
3+
trait FooT {
4+
type T
5+
type Bar[A]
6+
7+
def get(k: Bar[T]): String
8+
}
9+
val test: FooT = new FooT {
10+
type T = String
11+
type Bar[A] = J[A]
12+
sealed abstract class J[A]
13+
final case object JName extends J[T]
14+
final case object JInt extends J[Int]
15+
16+
def get(k: J[T]): String = k match {
17+
case JName => "Age"
18+
}
19+
}
20+
}
21+
}

0 commit comments

Comments
 (0)