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

Cross-build scalacheck module on scala 3 #857

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

RustedBones
Copy link
Contributor

@RustedBones RustedBones commented Nov 8, 2023

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

-val arbType: Arbitrary[Type] = ArbitraryDerivation[Type]
+val arbType: Arbitrary[Type] = Arbitrary.gen[Type]

Copy link

codecov bot commented Nov 8, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.16%. Comparing base (71df285) to head (58fc597).
Report is 3 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

@RustedBones RustedBones marked this pull request as ready for review November 16, 2023 06:34
@RustedBones RustedBones force-pushed the scala3-scalacheck branch 2 times, most recently from bcaf9c4 to 27c1fb2 Compare January 3, 2024 16:48
@@ -0,0 +1,58 @@
/*
* Copyright 2019 Spotify AB
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* 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)
Copy link
Contributor

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?

Copy link
Contributor Author

@RustedBones RustedBones Jan 5, 2024

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

Copy link
Contributor Author

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]
Copy link
Contributor

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 👍

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

2 participants