diff options
author | Martin Odersky <odersky@gmail.com> | 2009-05-26 19:00:36 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2009-05-26 19:00:36 +0000 |
commit | 9e6db195407d5c225b778180abbc4693c0811f55 (patch) | |
tree | 1859bc5797f0743fbf7037e2770d10d6a676e59f /src/compiler/scala | |
parent | 7702b798955247752bf1c0108cef02d4f81a030e (diff) | |
download | scala-9e6db195407d5c225b778180abbc4693c0811f55.tar.gz scala-9e6db195407d5c225b778180abbc4693c0811f55.tar.bz2 scala-9e6db195407d5c225b778180abbc4693c0811f55.zip |
removed deprecated files; more changes to repl.
Diffstat (limited to 'src/compiler/scala')
5 files changed, 26 insertions, 10 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/Trees.scala b/src/compiler/scala/tools/nsc/ast/Trees.scala index 736c9210ef..5e930bb4fc 100644 --- a/src/compiler/scala/tools/nsc/ast/Trees.scala +++ b/src/compiler/scala/tools/nsc/ast/Trees.scala @@ -1787,6 +1787,7 @@ trait Trees { override def point: Int = original.pos.point override def end: Int = original.pos.end override def underlying = original.pos.underlying + override def focus = original.pos.focus } } diff --git a/src/compiler/scala/tools/nsc/interactive/ContextTrees.scala b/src/compiler/scala/tools/nsc/interactive/ContextTrees.scala index 8e8d280b4b..b3a290964e 100755 --- a/src/compiler/scala/tools/nsc/interactive/ContextTrees.scala +++ b/src/compiler/scala/tools/nsc/interactive/ContextTrees.scala @@ -11,6 +11,7 @@ trait ContextTrees { self: Global => class ContextTree(val context: Context, val children: ArrayBuffer[ContextTree]) { def this(context: Context) = this(context, new ArrayBuffer[ContextTree]) def pos: Position = context.tree.pos + override def toString = "ContextTree("+pos+", "+children+")" } def locateContext(contexts: Contexts, pos: Position): Option[Context] = { @@ -39,15 +40,16 @@ trait ContextTrees { self: Global => def addContext(contexts: Contexts, context: Context) { val cpos = context.tree.pos + try { if (!cpos.isDefined || cpos.isSynthetic) {} else if (contexts.isEmpty) contexts += new ContextTree(context) else { val hi = contexts.length - 1 - if (contexts(hi).pos precedes cpos) + if (contexts(hi).pos properlyPrecedes cpos) contexts += new ContextTree(context) - else if (contexts(hi).pos includes cpos) // fast path w/o search + else if (contexts(hi).pos properlyIncludes cpos) // fast path w/o search addContext(contexts(hi).children, context) - else if (cpos precedes contexts(0).pos) + else if (cpos properlyPrecedes contexts(0).pos) new ContextTree(context) +: contexts else { def insertAt(idx: Int): Boolean = { @@ -86,6 +88,11 @@ trait ContextTrees { self: Global => loop(0, hi) } } - } + } catch { + case ex: Throwable => + println("failure inserting "+context.tree.pos+" into "+contexts+"/"+contexts(contexts.length - 1).pos+"/"+ + (contexts(contexts.length - 1).pos includes cpos)) + throw ex + }} } diff --git a/src/compiler/scala/tools/nsc/interactive/REPL.scala b/src/compiler/scala/tools/nsc/interactive/REPL.scala index 11def170b5..58477dd693 100644 --- a/src/compiler/scala/tools/nsc/interactive/REPL.scala +++ b/src/compiler/scala/tools/nsc/interactive/REPL.scala @@ -27,17 +27,19 @@ object REPL extends EvalLoop { val reloadResult = new SyncVar[Either[Unit, Throwable]] val typeatResult = new SyncVar[Either[comp.Tree, Throwable]] loop { line => + println("["+line+"]") + println((line split " ").toList) (line split " ").toList match { case "reload" :: args => comp.askReload(args map toSourceFile, reloadResult) show(reloadResult) - case List("typeat", file, line, col1, col2) => + case "typeat" :: file :: line :: col1 :: col2 :: Nil => val source = toSourceFile(file) val linestart = source.lineToOffset(line.toInt) val pos = comp.rangePos(source, linestart + col1.toInt, linestart + col1.toInt, linestart + col2.toInt) comp.askTypeAt(pos, typeatResult) show(typeatResult) - case List("quit") => + case "quit" :: Nil => System.exit(1) case _ => println("unrecongized command") diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala index 43f6d54be0..3e86181b73 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala @@ -28,7 +28,7 @@ self: Analyzer => import definitions._ import posAssigner.atPos - final val traceImplicits = true + final val traceImplicits = false var implicitTime = 0L var inscopeSucceed = 0L @@ -55,7 +55,6 @@ self: Analyzer => * @return A search result */ def inferImplicit(tree: Tree, pt0: Type, reportAmbiguous: Boolean, context: Context): SearchResult = { - println("infer impl "+pt0) if (traceImplicits && !tree.isEmpty && !context.undetparams.isEmpty) println("typing implicit with undetermined type params: "+context.undetparams+"\n"+tree) val search = new ImplicitSearch(tree, pt0, context.makeImplicit(reportAmbiguous)) @@ -303,7 +302,7 @@ self: Analyzer => */ val wildPt = approximate(pt) - if (traceImplicits) println("typed impl for "+wildPt+"? "+info.name+":"+info.tpe+"/"+undetParams) + //if (traceImplicits) println("typed impl for "+wildPt+"? "+info.name+":"+info.tpe+"/"+undetParams) if (isPlausiblyCompatible(info.tpe, wildPt) && isCompatible(depoly(info.tpe), wildPt) && isStable(info.pre)) { @@ -312,7 +311,7 @@ self: Analyzer => if (info.pre == NoPrefix) Ident(info.name) else Select(gen.mkAttributedQualifier(info.pre), info.name) } - if (traceImplicits) println("typed impl?? "+info.name+":"+info.tpe+" ==> "+itree+" with "+wildPt) + //if (traceImplicits) println("typed impl?? "+info.name+":"+info.tpe+" ==> "+itree+" with "+wildPt) def fail(reason: String): SearchResult = { if (settings.XlogImplicits.value) inform(itree+" is not a valid implicit value for "+pt0+" because:\n"+reason) diff --git a/src/compiler/scala/tools/nsc/util/Position.scala b/src/compiler/scala/tools/nsc/util/Position.scala index 1ebc2df19e..bd60035a5a 100644 --- a/src/compiler/scala/tools/nsc/util/Position.scala +++ b/src/compiler/scala/tools/nsc/util/Position.scala @@ -32,11 +32,17 @@ trait Position { def includes(pos: Position) = isDefined && pos.isDefined && start <= pos.start && pos.end <= end + def properlyIncludes(pos: Position) = + includes(pos) && (start < pos.start || pos.end < end) + /** Does this position precede that position? */ def precedes(pos: Position) = isDefined && pos.isDefined && end <= pos.start + def properlyPrecedes(pos: Position) = + precedes(pos) && start < pos.end + def sameRange(pos: Position) = isDefined && pos.isDefined && start == pos.start && end == pos.end @@ -118,6 +124,7 @@ extends OffsetPosition(source0, point) { override def pointOrElse(d: Int) = point override def endOrElse(d: Int) = end override def focus = OffsetPosition(source0, point) + override def toString = "RangePosition("+source0+", "+start+", "+point+", "+end+")" } |