diff options
author | Paul Phillips <paulp@improving.org> | 2011-12-03 15:27:52 -0800 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-12-03 20:04:10 -0800 |
commit | 3e9e4ecf360e6eda5c26f798abfcb9bb882cf772 (patch) | |
tree | a0e9d34abff1403e30cb562ee0733cbe3d6496d7 /src/compiler/scala/tools/nsc/typechecker/Contexts.scala | |
parent | f7d436a0abf350ff573f155392393c357f489a93 (diff) | |
download | scala-3e9e4ecf360e6eda5c26f798abfcb9bb882cf772.tar.gz scala-3e9e4ecf360e6eda5c26f798abfcb9bb882cf772.tar.bz2 scala-3e9e4ecf360e6eda5c26f798abfcb9bb882cf772.zip |
Added -Ysuggest-idents.
Suggest possible alternatives when an identifier is not in scope.
% scala -Ysuggest-idents
scala> import scala.collection.mutable._
import scala.collection.mutable._
scala> new MistBuffer
<console>:11: error: not found: type MistBuffer (similar: ListBuffer, Buffer)
new MistBuffer
^
Too bad, no MistBuffer. We'll settle for ListBuffer.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Contexts.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Contexts.scala | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala index d252281002..1d9eb9c292 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala @@ -17,13 +17,16 @@ import annotation.tailrec trait Contexts { self: Analyzer => import global._ - val NoContext = new Context { - override def implicitss: List[List[ImplicitInfo]] = List() - outer = this + object NoContext extends Context { + outer = this + enclClass = this + enclMethod = this + + override def nextEnclosing(p: Context => Boolean): Context = this + override def enclosingContextChain: List[Context] = Nil + override def implicitss: List[List[ImplicitInfo]] = Nil override def toString = "NoContext" } - NoContext.enclClass = NoContext - NoContext.enclMethod = NoContext private val startContext = { NoContext.make( @@ -337,7 +340,9 @@ trait Contexts { self: Analyzer => } def nextEnclosing(p: Context => Boolean): Context = - if (this == NoContext || p(this)) this else outer.nextEnclosing(p) + if (p(this)) this else outer.nextEnclosing(p) + + def enclosingContextChain: List[Context] = this :: outer.enclosingContextChain override def toString = "Context(%s@%s unit=%s scope=%s)".format( owner.fullName, tree.shortClass, unit, scope.## |