Skip to content
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

Merged
merged 1 commit into from
Sep 29, 2019
Merged

Add support for type annotations (issue #922) #925

merged 1 commit into from
Sep 29, 2019

Conversation

pgrandjean
Copy link
Contributor

No description provided.

Copy link
Collaborator

@alexarchambault alexarchambault left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@pgrandjean
Copy link
Contributor Author

working to fix macros for scala 2.10

@pgrandjean
Copy link
Contributor Author

Build fails with 2.13.1, but it looks like the error is related to SBT.

@milessabin
Copy link
Owner

We're waiting on Scala.js to propagate ... won't be long.

@milessabin
Copy link
Owner

Actually, it's scoverage: scoverage/sbt-scoverage#295.

@milessabin
Copy link
Owner

You should be good if you rebase on master.

@pgrandjean
Copy link
Contributor Author

Rebased.

}

/*
* Workaround for Scala 2.10, which needs an object.
Copy link
Owner

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?

Copy link
Contributor Author

@pgrandjean pgrandjean Sep 18, 2019

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+.

Copy link
Owner

@milessabin milessabin Sep 18, 2019

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.

Copy link
Contributor Author

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:

How to go around this?

@pgrandjean
Copy link
Contributor Author

pgrandjean commented Sep 19, 2019

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 Types.AnnotatedType without getting compilation errors, so that part is now isolated in AnnotationsHelper.extract, defined in folders scala_2.10 and scala_2.11+. The macro implementations were fallbacked to the common bundle, in folder scala.

@milessabin
Copy link
Owner

Can you use something like case a: AnnotatedType => a.annots cross versions?

@pgrandjean
Copy link
Contributor Author

Thanks for the hint!

@pgrandjean
Copy link
Contributor Author

Got rid of the version specific implementation. Now everything is in the common bundle.

@milessabin
Copy link
Owner

Sorry for the hold up ...

That's great stuff. Many thanks ... merging :-)

@joroKr21
Copy link
Collaborator

I don't think this was released

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants