Search code examples
scalaintellij-ideaintellij-scala

Intellij Worksheet Scala Version


I have an sbt project with Scala 2.12.12.

Working with the worksheet (REPL), i decided to check the Scala version, and typed the following:

util.Properties.versionString

To my surprise i got

res7: String = version 2.12.7

Any idea how is that possible?

EDIT1

Is there a way to ensure that the version of the Worksheet is the same as the one set in the sbt project? Am i looking at the wrong values?


Solution

  • Official answer from JetBrains:

    Is there a way to ensure that the version of the Worksheet is the same as the one set in the sbt project? Am I looking at the wrong values?

    The actual version of scala used in the worksheet is 2.12.12 (or whatever version is used in module). You can verify that e.g. by using some 2.13.3-specific syntax in worksheet, e.g val x: 42 = 42.

    Any idea how is that possible?

    The reason util.Properties.versionString returned 2.12.7 is a bug in our classloaders (similar to SCL-9229). versionString search for library.propertis resource and reads the version string from there. Due to the bug, resources of scala library of Scala Plugins itself (2.12.7 in 2020.2) leaked to the REPL instance. The bug was identified, fix is in progress.