Skip to content

Commit 37255c5

Browse files
authored
Merge pull request #2352 from dotty-staging/fix/not-assigned-2
Fix #2292: Do not crash when a top-level class is untyped
2 parents 1014af3 + da3b5fb commit 37255c5

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

compiler/src/dotty/tools/dotc/ast/Trees.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ object Trees {
233233
/** Tree's denotation can be derived from its type */
234234
abstract class DenotingTree[-T >: Untyped] extends Tree[T] {
235235
type ThisTree[-T >: Untyped] <: DenotingTree[T]
236-
override def denot(implicit ctx: Context) = tpe match {
236+
override def denot(implicit ctx: Context) = typeOpt match {
237237
case tpe: NamedType => tpe.denot
238238
case tpe: ThisType => tpe.cls.denot
239239
case tpe: AnnotatedType => tpe.stripAnnots match {
@@ -363,7 +363,7 @@ object Trees {
363363
type ThisTree[-T >: Untyped] = This[T]
364364
// Denotation of a This tree is always the underlying class; needs correction for modules.
365365
override def denot(implicit ctx: Context): Denotation = {
366-
tpe match {
366+
typeOpt match {
367367
case tpe @ TermRef(pre, _) if tpe.symbol is Module =>
368368
tpe.symbol.moduleClass.denot.asSeenFrom(pre)
369369
case _ =>

tests/neg/i2292.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package + // error
2+
3+
class Foo

0 commit comments

Comments
 (0)