summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2013-12-01 10:03:27 +0100
committerMirco Dotta <mirco.dotta@typesafe.com>2013-12-02 10:39:40 +0100
commit02308c96910a76a09c2654db304a0696c0b603af (patch)
tree83871119f84c7b8eeab0788d0fb928959c103e01
parent652b3b4b9dcbf990e7ace409e050cc4ba4e83b16 (diff)
downloadscala-02308c96910a76a09c2654db304a0696c0b603af.tar.gz
scala-02308c96910a76a09c2654db304a0696c0b603af.tar.bz2
scala-02308c96910a76a09c2654db304a0696c0b603af.zip
SI-7458 Pres. compiler must not observe trees in silent mode
Otherwise we can think that `+` in `1 + BigInt(2)` refers to a method in `Int`. In general, this protects the IDE from observing results from "exploratory" typing which is discarded as the compiler backtracks to another possibility. This protection subsumes the condition that checked for overloaded types: presentation/t7458 now passes without this.
-rw-r--r--src/compiler/scala/tools/nsc/interactive/Global.scala12
-rw-r--r--test/files/presentation/t7548b.check2
2 files changed, 8 insertions, 6 deletions
diff --git a/src/compiler/scala/tools/nsc/interactive/Global.scala b/src/compiler/scala/tools/nsc/interactive/Global.scala
index b4e8170b19..02a37ec217 100644
--- a/src/compiler/scala/tools/nsc/interactive/Global.scala
+++ b/src/compiler/scala/tools/nsc/interactive/Global.scala
@@ -238,7 +238,12 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "")
* @param result The transformed node
*/
override def signalDone(context: Context, old: Tree, result: Tree) {
- if (interruptsEnabled && analyzer.lockedCount == 0) {
+ val canObserveTree = (
+ interruptsEnabled
+ && analyzer.lockedCount == 0
+ && !context.bufferErrors // SI-7558 look away during exploratory typing in "silent mode"
+ )
+ if (canObserveTree) {
if (context.unit.exists &&
result.pos.isOpaqueRange &&
(result.pos includes context.unit.targetPos)) {
@@ -247,10 +252,7 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "")
println("something's wrong: no "+context.unit+" in "+result+result.pos)
located = result
}
- located.tpe match {
- case _: OverloadedType => ()
- case _ => throw new TyperResult(located)
- }
+ throw new TyperResult(located)
}
else {
try {
diff --git a/test/files/presentation/t7548b.check b/test/files/presentation/t7548b.check
index 5ba69809f1..35445fedf6 100644
--- a/test/files/presentation/t7548b.check
+++ b/test/files/presentation/t7548b.check
@@ -1 +1 @@
-Foo.this.I.+: (other: Foo.I.type)Unit
+Foo.this.I2BI(Foo.this.I).+: (other: Foo.BI.type)Unit