summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-10-23 16:43:25 -0700
committerPaul Phillips <paulp@improving.org>2012-10-29 15:06:02 -0700
commit578c4c6c64250a12a0e625d1e54a74dbdad6d972 (patch)
treec3112dc73a9431f9673176fc788042456f92add8 /src
parente326d864d0a7fc9471695d89635c101a84592c58 (diff)
downloadscala-578c4c6c64250a12a0e625d1e54a74dbdad6d972.tar.gz
scala-578c4c6c64250a12a0e625d1e54a74dbdad6d972.tar.bz2
scala-578c4c6c64250a12a0e625d1e54a74dbdad6d972.zip
Make LookupNotFound a case object.
Turns out putting a group of case classes at what feels like the top level might not be top-level enough, like if your "top" is Analyzer and you wind up with different outer pointers in every instance of Typer. Moved the whole bundle to SymbolTable.
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Contexts.scala13
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala2
-rw-r--r--src/reflect/scala/reflect/internal/Scopes.scala8
3 files changed, 10 insertions, 13 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
index a79fec42bf..482fb2231b 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
@@ -35,17 +35,6 @@ trait Contexts { self: Analyzer =>
val completeList = JavaLangPackage :: ScalaPackage :: PredefModule :: Nil
}
- sealed abstract class NameLookup { def symbol: Symbol }
- case class LookupSucceeded(qualifier: Tree, symbol: Symbol) extends NameLookup
- case class LookupAmbiguous(msg: String) extends NameLookup { def symbol = NoSymbol }
- case class LookupInaccessible(symbol: Symbol, msg: String) extends NameLookup
- case class LookupNotFound() extends NameLookup { def symbol = NoSymbol }
- // case object LookupNotFound extends NameLookup { def symbol = NoSymbol }
- //
- // !!! Bug - case object LookupNotFound does not match - we get an
- // "impossible" MatchError. case class LookupNotFound() matches in
- // the same spot.
-
def ambiguousImports(imp1: ImportInfo, imp2: ImportInfo) =
LookupAmbiguous(s"it is imported twice in the same scope by\n$imp1\nand $imp2")
def ambiguousDefnAndImport(owner: Symbol, imp: ImportInfo) =
@@ -795,7 +784,7 @@ trait Contexts { self: Analyzer =>
if (lookupError ne null) lookupError
else sym match {
case NoSymbol if inaccessible ne null => inaccessible
- case NoSymbol => LookupNotFound()
+ case NoSymbol => LookupNotFound
case _ => LookupSucceeded(qual, sym)
}
)
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index e45df55ca7..884e4b3d9c 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -4789,7 +4789,7 @@ trait Typers extends Modes with Adaptations with Tags {
nameLookup match {
case LookupAmbiguous(msg) => issue(AmbiguousIdentError(tree, name, msg))
case LookupInaccessible(sym, msg) => issue(AccessError(tree, sym, context, msg))
- case LookupNotFound() => issue(SymbolNotFoundError(tree, name, context.owner, startContext))
+ case LookupNotFound => issue(SymbolNotFoundError(tree, name, context.owner, startContext))
case LookupSucceeded(qual, sym) =>
// this -> Foo.this
if (sym.isThisSym)
diff --git a/src/reflect/scala/reflect/internal/Scopes.scala b/src/reflect/scala/reflect/internal/Scopes.scala
index 89332d0ae5..a4b541e34d 100644
--- a/src/reflect/scala/reflect/internal/Scopes.scala
+++ b/src/reflect/scala/reflect/internal/Scopes.scala
@@ -8,6 +8,14 @@ package internal
trait Scopes extends api.Scopes { self: SymbolTable =>
+ /** An ADT to represent the results of symbol name lookups.
+ */
+ sealed trait NameLookup { def symbol: Symbol }
+ case class LookupSucceeded(qualifier: Tree, symbol: Symbol) extends NameLookup
+ case class LookupAmbiguous(msg: String) extends NameLookup { def symbol = NoSymbol }
+ case class LookupInaccessible(symbol: Symbol, msg: String) extends NameLookup
+ case object LookupNotFound extends NameLookup { def symbol = NoSymbol }
+
class ScopeEntry(val sym: Symbol, val owner: Scope) {
/** the next entry in the hash bucket
*/