-
Notifications
You must be signed in to change notification settings - Fork 26
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
Cross-build scalacheck module on scala 3 #857
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #857 +/- ##
==========================================
- Coverage 95.18% 95.16% -0.02%
==========================================
Files 51 52 +1
Lines 1827 1821 -6
Branches 153 159 +6
==========================================
- Hits 1739 1733 -6
Misses 88 88 ☔ View full report in Codecov by Sentry. |
bcaf9c4
to
27c1fb2
Compare
scalacheck/src/test/scala/magnolify/scalacheck/CogenDerivationSuite.scala
Outdated
Show resolved
Hide resolved
@@ -0,0 +1,58 @@ | |||
/* | |||
* Copyright 2019 Spotify AB |
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.
* Copyright 2019 Spotify AB | |
* Copyright 2023 Spotify AB |
Gen.choose(0, subtypes.size - 1) | ||
} else { | ||
// pick a fixed subtype to have a chance to stop recursion | ||
Gen.const(subtypes.size + size) |
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'm not totally following the subtypes.size + size
logic, can you explain a bit?
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.
Once we reach negative size, we'll stop picking type at random, and deterministically pick one of the subtype. This is done so we'll have a chance to end-up recursion when tree structure is big.
The downside is that such generated struct will often have the same kind of tali/leaves
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.
This was previously done by providing the Fallback
implicit.
} | ||
} | ||
|
||
implicit def gen[T]: Arbitrary[T] = macro Magnolia.gen[T] |
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 like this signature change, it matches the Scalacheck API better too imo 👍
c978456
to
5640767
Compare
889d14f
to
0125b32
Compare
Keep type param Add missing headers Prefer explicit imports instead of trait mixin Revert to implicit in shared Use implicit instead of given Add missing header Fix scala3 warning Remove trace Change year in header Update doc Simplify arbitrary derivation Update to next minor version Use import instead of mixin trait Avoid implicit name conflict Streamline macro naming Change macro naming
0125b32
to
58fc597
Compare
Looks like magnolia scala3 is creating a lambda with iuter reference in the
SubType.callByNeed
here that prevents the typeclass to be serializable.Changed the usage in
semiauto
to get more consistency with native magnolify typeclasses