My scala project uses WartRemover for linting and has several "warts" set to be considered errors, particularly, Wart.PublicInference. This caused a problem when trying to use sbt console as anything typed into the console resulted in a compile error.
I was able to fix the issue with this hack I lifted from WartRemover issue #420
project.settings(
Compile / console / scalacOptions :=
(console / scalacOptions).value.filterNot { arg =>
Set("wart", "warn").exists { word =>
arg.contains(word)
}
},
)
The hack removes anything that looks like warnings or warts from the scalacOptions for the sbt console command. It ain't pretty but it works.
But now I've come across the problem again. This time while trying to use metals with the Debug Adapter Protocol (DAP). When setting a break point and trying to debug using the DAP console I get the same error as before:
dap> data.toJson
Cannot evaluate because of failed compilation:
[wartremover:PublicInference] Public member must have an explicit type ascription.
dap> println(data.toJson.toString)
Cannot evaluate because of failed compilation:
[wartremover:PublicInference] Public member must have an explicit type ascription.
dap> println(data.toJson.toString): Unit
Cannot evaluate because of failed compilation:
[wartremover:PublicInference] Public member must have an explicit type ascription.
Can I fix this with some similar SBT hack? I don't know which setting to override though. I'm also pretty sure metals and DAP use bloop not SBT. Is there some way to override it with the DAP configurations? My DAP configurations look something like this.
{
name = config_name,
type = "scala",
request = "launch",
metals = {
runType = "run",
mainClass = "my.main.Class",
jvmOptions = {"-Dlogback.configurationFile=.logback.xml"},
args = { "--config", config_file },
envFile = ".env",
},
}
I'm also using metals through neovim fwiw but that shouldn't matter afaik.