Skip to content

Commit 02308c9

Browse files
retronymdotta
authored andcommitted
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.
1 parent 652b3b4 commit 02308c9

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/compiler/scala/tools/nsc/interactive/Global.scala

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,12 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "")
238238
* @param result The transformed node
239239
*/
240240
override def signalDone(context: Context, old: Tree, result: Tree) {
241-
if (interruptsEnabled && analyzer.lockedCount == 0) {
241+
val canObserveTree = (
242+
interruptsEnabled
243+
&& analyzer.lockedCount == 0
244+
&& !context.bufferErrors // SI-7558 look away during exploratory typing in "silent mode"
245+
)
246+
if (canObserveTree) {
242247
if (context.unit.exists &&
243248
result.pos.isOpaqueRange &&
244249
(result.pos includes context.unit.targetPos)) {
@@ -247,10 +252,7 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "")
247252
println("something's wrong: no "+context.unit+" in "+result+result.pos)
248253
located = result
249254
}
250-
located.tpe match {
251-
case _: OverloadedType => ()
252-
case _ => throw new TyperResult(located)
253-
}
255+
throw new TyperResult(located)
254256
}
255257
else {
256258
try {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Foo.this.I.+: (other: Foo.I.type)Unit
1+
Foo.this.I2BI(Foo.this.I).+: (other: Foo.BI.type)Unit

0 commit comments

Comments
 (0)