Open som-snytt opened 8 months ago
The ancient comment underestimates the liberty that was taken:
/* If there is only a single object template in the file and it has a
* suitable main method, we will use it rather than building another object
* around it. Since objects are loaded lazily the whole script would have
* been a no-op, so we're not taking much liberty.
*/
// If we detect a main module with an arbitrary name, rename it to the expected name.
The workaround is to name it.
scala -Xscript C mainly.scala
Another example https://github.com/scala/bug/issues/9790
Relatedly and not coincidentally https://github.com/scala/bug/issues/10252
Reproduction steps
Scala version: 2.13.12
Problem
For some reason, the
scala
runner rudely assumes it can rename my object that has amain
method.Probably I am the last person on Earth to use the old
scala
runner.Noticed while trying out a snippet submitted for a Dotty bug (a different bug).