Review Simulacrum Scalafix annotation practices #3496
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a follow-up to @djspiewak's question here about whether the Simulacrum Scalafix annotations dependency needs to be in the runtime classpath.
With Simulacrum 1 we used the following approach:
StaticAnnotation
.@compileTimeOnly
.Provided
scope.With Simulacrum Scalafix we currently do the following:
scala.annotation.Annotation
.This PR changes that to reinstate the
Provided
scope configuration. I'm not sure this actually does anything given the POM postprocessing already in our build, but I also don't think it hurts anything.Some additional details
In the new model I made the annotations only extend
Annotation
because there's no step where we could remove them, and extendingAnnotation
directly seems to be the recommended way to define non-macro annotations that shouldn't exist at runtime. From the Scaladoc:I hadn't used
@compileTimeOnly
in Simulacrum Scalafix because it didn't seem necessary, since unlikeStaticAnnotation
, theAnnotation
-extending annotations are never preserved in the classfile.I don't think it would hurt to add the annotation, though, and will propose that in a Simulacrum Scalafix PR[update: adding the annotation fails for some reason—I guess it's only intended for use withStaticAnnotation
?].We can confirm that the Simulacrum Scalafix annotations aren't available to either Scala or Java reflection:
(This is the same both with and without
Provided
.)