-
-
Notifications
You must be signed in to change notification settings - Fork 10
Save primitives from erasure (Scala2 only) #166
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
Save primitives from erasure (Scala2 only) #166
Conversation
but leave all other annotation properties in tact branch:
by introducing a Scala 3 stub implementation of `erasedOptionalPrimitives`. Tests still fail
Codecov Report
@@ Coverage Diff @@
## develop #166 +/- ##
===========================================
+ Coverage 78.57% 82.45% +3.88%
===========================================
Files 1 2 +1
Lines 140 171 +31
Branches 12 20 +8
===========================================
+ Hits 110 141 +31
Misses 30 30
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
|
Thanks - I'll merge this but I'll probably need to do something to get the tests to run for the scala3 build, even if they will have different assertion expectations. Scala3 version of this lib is not yet widely used. |
|
@SamTheisens this change doesn't work as expected with swagger-akka-http. I have updated the sample - https://github.com/pjfanning/swagger-akka-http-sample - to use the swagger-scala-module v2.7.0. Swagger-akka-http may need to be changed to help the scala-reflect stuff to work. I think the current code passes around Java class instances and this possibly stops the scala-reflect code getting proper access to do its thing. |
|
@pjfanning that's too bad. I'll have a look as well. |
|
@SamTheisens I fixed the issue with the swagger annotations being ignored in #168 and did a v2.7.1 release. The new erasure code still does not work in swagger-akka-http-sample but at least the sample now works again when the swagger annotations are used. |
I've found out that the reflection doesn't work for case classes that are defined nested inside an object. Trying to figure out if and how that can be fixed. |
|
I've reproduced the issue with inner classes. It would be great to support inner classes but if necessary, we can document that the reflection support only works with classes that are not inner classes. On the Scala 3 side of things, I've used this lib before - https://github.com/gzoller/scala-reflection - it might be an option here. |
I think I've found a solution for the inner classes #169 |
This PR attempts to address the issue that optional and iterable Java primitive types e.g.
Option[Int],Seq[Boolean]are lost in translation as described in #117.Note that this implementation depends on scala reflection and therefore does not work in Scala 3. There is a stub method
ErasureHelper.erasedOptionalPrimitives(cls: Class[_]): Map[String, Class[_]]that would need to be implemented using macros(?).I may have a stab at that later, but I'm completely new to Scala 3 or macros for that matter. So if someone else know how to do this, help with that would be much appreciated!