summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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
*/