Scala 3 worksheet issues in IntelliJ

I just tried using worksheets in IntelliJ, but immediately encountered several issues:

  1. Definitions are compiled in-order (precluding mutual recursion and proper code organization).
  2. Method overloading is not supported.
  3. Building the project also compiles the worksheet as if it were a normal Scala file, leading to highlighting errors about illegal toplevel definitions.

Does anyone know how such issues can be avoided?

P.S.: I was using Scastie before, but kept running into limitations due to it being browser-based. I have also tried to switch to Visual Studio Code several times over the years, but I simply cannot remember how to do even the most basic things (like creating a new project) in that IDE, as it feels terribly unintuitive to me.

IntelliJ’s Scala 3 support is not very good right now (they are working on it).

Try VS Code with Metals extension. Create your project with SBT on the command line / Terminal: sbt new scala/scala3.g8, then open the folder with build.sbt in it with the “Open Folder” option in VS Code.

You can also use the Command Palette (Ctrl+Shift+P) then type “Metals” and there is an option to create a new worksheet:

Another option is to use Scala-cli which is an awesome new tool. Install it, then use scala-cli setup-ide . in a folder, and then you can open that folder in VS Code and Metals will see it. Here I have an example Scala-cli project where I typed up all the Toolkit tutorials including worksheets and test files.