If I have the contents of an object imported at the top of a Scala worksheet in Intellij, when I add new things to the object, they cannot be found in the worksheet. Even after I build the project and reevaluate the worksheet, it can't find the new property. Autocomplete works. If I quit and restart IntelliJ it works.
This is the error:
java.lang.NoSuchMethodError: Arith$.foo()Ljava/lang/String;
at #worksheet#.get$$instance$$res6(ArithWS.sc:15)
at A$A1$.main(ArithWS.sc:41)
at #worksheet#.#worksheet#(ArithWS.sc)
Weirdly, it seems to compile, but fails at runtime. This is a normal SBT project. IntelliJ 2017.2.5, Scala 2.12.3. Selecting the "Make project" checkbox doesn't help. Actually no combination of checkboxes makes it work. No amount of rebuilding the project or the worksheet helps either. Only restarting IntelliJ will get the worksheet to pick up the new code.
Example project code in Arith.scala:
object Arith {
val foo = "foo"
}
Example worksheet ArithWS.sc:
import Arith._
foo