Skip to content

Fix #2292: Do not crash when a top-level class is untyped #2352

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/ast/Trees.scala
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ object Trees {
/** Tree's denotation can be derived from its type */
abstract class DenotingTree[-T >: Untyped] extends Tree[T] {
type ThisTree[-T >: Untyped] <: DenotingTree[T]
override def denot(implicit ctx: Context) = tpe match {
override def denot(implicit ctx: Context) = typeOpt match {
case tpe: NamedType => tpe.denot
case tpe: ThisType => tpe.cls.denot
case tpe: AnnotatedType => tpe.stripAnnots match {
Expand Down Expand Up @@ -363,7 +363,7 @@ object Trees {
type ThisTree[-T >: Untyped] = This[T]
// Denotation of a This tree is always the underlying class; needs correction for modules.
override def denot(implicit ctx: Context): Denotation = {
tpe match {
typeOpt match {
case tpe @ TermRef(pre, _) if tpe.symbol is Module =>
tpe.symbol.moduleClass.denot.asSeenFrom(pre)
case _ =>
Expand Down
3 changes: 3 additions & 0 deletions tests/neg/i2292.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package + // error

class Foo