I noted that occasionally the eclipse scala IDE would lock up or crash
with a race condition. The
most common symptom of that was a "key not found" message in
Types.unique. This one I circumvented a while ago. Nevertheless, there
are other potential sources of race conditions.
The issue is that _any_ operation on a symbol, type or tree returned
by the presentation compiler is a potential race condition. Even a
simple member lookup or subtype check can internally change compiler
state, and if that happens concurrently with a presentation compiler
background compile, bad things will happen.
I believe some of the perceived remaining instability of the Eclipse
plugin might be attributable to this problem.
What to do? Any operation on a tree, type or symbol that was returned
by the presentation compiler, and that is more than a simple attribute
value get should be run on the presentation compiler thread.
Previously, there was no easy and fast way to do this, but now there
is: I added an `ask` operation to
scala.tools.nsc.interactive.CompilerControl which will execute the
passed operation as a high priarity "interrupt" on the presentation
compiler thread. You should never have to wait more than a couple of
milliseconds on operations dispatched to `ask`. Here's the signature
of this method:
def ask[A](op: () => A): A
So where previously you might have written T <:< U, say, you should
now transform this to
cc.ask(T <:< U)
where `cc` is your instance of the presentation compiler
CompilerControl.
I could not yet test it, so please let me know how it goes.
Cheers
-- Martin