com-lihaoyi / Ammonite

Scala Scripting
http://ammonite.io
MIT License
2.6k stars 365 forks source link

Add scala 3 compiler settings test #1484

Closed carlosrogue closed 1 month ago

carlosrogue commented 2 months ago

Official Compiler Flags documentation do not mention how to set settings for scala 3 compiler.

Maybe adding a comment like this in 2.12?:

@ // Disabling default Scala imports

@ List(1, 2, 3) + "lol"
res0: String = "List(1, 2, 3)lol"

@ interp.configureCompiler(_.settings.noimports.value = true)

@ // interp.preConfigureCompiler(ctx => ctx.setSetting(ctx.settings.YnoImports, true)) // Dotty

Fixes #1192

carlosrogue commented 2 months ago

@lefou should I also add also this hint comment to 2.12:

@ // interp.preConfigureCompiler(ctx => ctx.setSetting(ctx.settings.YnoImports, true)) // Dotty
lefou commented 2 months ago

@lefou should I also add also this hint comment to 2.12:

@ // interp.preConfigureCompiler(ctx => ctx.setSetting(ctx.settings.YnoImports, true)) // Dotty

I've no idea.

carlosrogue commented 2 months ago

@lefou there is a note regarding this test not working on 2.13:

      // not sure why that one doesn't pass in 2.13
      // even disabling the noimports and imports settings instead of setting noimports to false
      // doesn't seem to reinstate imports
      def sv = scala.util.Properties.versionNumberString
      // In 2.12.13, I would have expected things like
      //   interp.configureCompiler(_.settings.Wconf.tryToSet(List("any:wv", "cat=unchecked:ws")))
      // to re-instate the expected warning below, to no avail :|

I could check this later and verify if we can at least add newer 2.12 versions as part of other MR.