-
Notifications
You must be signed in to change notification settings - Fork 5
SBT plugin will most likely fail compile when treating errors as warnings #42
Comments
Is it possible to configure SBT to treat the generated files differently? (i.e different scalac flags) |
No, because then it masks real errors. With a lot of the macro annotations I have seen, the generated code makes up a small portion of the file. You still want compiler warnings for the parts which are untouched. It would be nice if we could ignore scalac warnings for ranges in documents. I think the eventual approach will be to remove select unused imports though. |
The original and expanded code should be in separate projects where you can tune the scalacOptions and logger level via sbt. In the generated sources you may want to filter out warnings which can be done with a
You can also override the sbt |
The problem I see is something like import scala.meta.generators.kase
import cats.NonEmptyList
@kase class Point(x: Int, y: Int) In the above case:
After some thought, here's a few ideas I have. Remove unused imports before compileRemove all unused imports in file. This would cause compiling when treating warnings as errors to pass. Cons:
Selectively remove unused imports only when compiler flag is detectedRemove any unused import of a Generator Subtype. We only have to do this when detecting the unused imports flag, otherwise, we do not care. Cons:
Just do not remove annotationsThe only reason we actually get this error is due to removing the annotation, thus leaving the import unused. Cons:
Force generator authors to use fully qualified names with unused importsimport cats.NonEmptyList
@scala.meta.generators.kase class Point(x: Int, y: Int) This becomes a non-issue and we do not have to change anything. Cons:
Note: After some thought, we do not know where the import is, thus we cannot just ignore warnings for this. Even a compiler plugin would not be able to figure it out. So ranges do not help. To be truly honest, I think this might be the last nail in the coffin for recursion because I like that idea best. Perhaps we should ask the community. @olafurpg Do you agree? |
IMHO, the best solutions is to not remove the annotations. |
@APari that is the final solution at this stage... nearly complete. We are removing recursion, although you will be able to call other generators from yours, so you an do the same thing as recursion, just without the “discovery” phase. |
Currently, we do not touch imports in generated files.
When we expand a generator, we remove the annotation.
Thus, code such as
will remove the annotation, leaving the import unused.
The solution to this problem is likely hard, but it should be noted somewhere in the docs at the least.
The text was updated successfully, but these errors were encountered: