-
Notifications
You must be signed in to change notification settings - Fork 533
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for type annotations (issue #922) #925
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
working to fix macros for scala 2.10 |
Build fails with 2.13.1, but it looks like the error is related to SBT. |
We're waiting on Scala.js to propagate ... won't be long. |
Actually, it's scoverage: scoverage/sbt-scoverage#295. |
You should be good if you rebase on master. |
Rebased. |
} | ||
|
||
/* | ||
* Workaround for Scala 2.10, which needs an object. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
macrocompat should allow you to keep to the same bundle style as 2.11+ ... can you say what problems you were seeing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I remove the companion object, I get compilation errors saying "value <macro> is not a member of object shapeless.AnnotationMacros":
[error] /Development/shapeless/core/src/main/scala/shapeless/annotation.scala:56:77: value materializeAnnotation is not a member of object shapeless.AnnotationMacros
[error] implicit def materialize[A, T]: Annotation[A, T] = macro AnnotationMacros.materializeAnnotation[A, T]
[error] ^
[error] /Development/shapeless/core/src/main/scala/shapeless/annotation.scala:117:89: value materializeVariableAnnotations is not a member of object shapeless.AnnotationMacros
[error] implicit def materialize[A, T, Out <: HList]: Aux[A, T, Out] = macro AnnotationMacros.materializeVariableAnnotations[A, T, Out]
[error] ^
[error] /Development/shapeless/core/src/main/scala/shapeless/annotation.scala:171:89: value materializeTypeAnnotations is not a member of object shapeless.AnnotationMacros
[error] implicit def materialize[A, T, Out <: HList]: Aux[A, T, Out] = macro AnnotationMacros.materializeTypeAnnotations[A, T, Out]
That made we believe that the problem was similar to LazyMacrosRef
, which is an object in 2.10 and a class in 2.11+.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Lazy
macros are "special" in all sorts of strange ways.
A closer comparison would be AnnotationMacros
here. If you follow that model I think it's fairly likely you can do this without needing any version specific source.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will try to get closer to the original code. But then there is the extraction of Types.AnnotatedType
which is slightly different between versions:
- 2.10: https://github.com/scala/scala/blob/v2.10.7/src/reflect/scala/reflect/api/Types.scala#L799
- 2.11: https://github.com/scala/scala/blob/v2.11.12/src/reflect/scala/reflect/api/Types.scala#L899
How to go around this?
Got rid of the companion object in 2.10 although there is still a tiny bit that is version specific. I don't see how to get around |
Can you use something like |
Thanks for the hint! |
Got rid of the version specific implementation. Now everything is in the common bundle. |
Sorry for the hold up ... That's great stuff. Many thanks ... merging :-) |
I don't think this was released |
No description provided.