sageserpent-open / americium

Generation of test case data for Scala and Java, in the spirit of QuickCheck. When your test fails, it gives you a minimised failing test case and a way of reproducing the failure immediately.
MIT License
15 stars 1 forks source link

Port to Scala 3 #34

Closed sageserpent-open closed 2 years ago

sageserpent-open commented 2 years ago

Following on from issue #13, this spike is to capture ongoing attempts to port to Scala 3 in a structured way.

Casual attempts made previously have all ground to a halt, if this requires help or advice from others, it would be good to systematically capture the problems against commits, or maybe to provide minimised problem cases.

sageserpent-open commented 2 years ago

Good news - as of commit b68521a2d8077e81d2dfa9c009683e999dd2184d we have something that builds on Scala 3 and passes its tests.

Casualties incurred:

Other than that, while it's a pain rewriting the code to satisfy the nitpicking that comes with Scala 3, the results look OK.

On with the show...

sageserpent-open commented 2 years ago

Pull request here for the sake of seeing the impact: #35 .

sageserpent-open commented 2 years ago

More good news - the Java API has been restored, and mixed-mode is still in use. The fixes were mostly:

Other than that, there was nothing major that springs to mind, other than a lot of repeated partial reversions of the commits that pulled out the Java support and test for it.

That leaves the Magnolia work to be reinstated / rewritten - I think this should be via distinct source trees for Scala 2 and Scala 3 contributing the same old americium artifact in a cross-build SBT project.

sageserpent-open commented 2 years ago

The Magnolia support has been reinstated, but a) doesn't support derivation of Factory for parameter types that are recursively defined - this is a known issue with the Scala 3 branch of Magnolia at time of writing. Furthermore, attempting to compile code that triggers automatic derivation in such a case causes the Scala 3.1.1 compiler to fault with an assertion failure.

Nevertheless, it looks like this port has been a success overall, so it is being merged into work for cross building in issue #36 .

This issue will be left open as a place to document work on minimizing the Scala compiler fault in the meantime.

sageserpent-open commented 2 years ago

The bug mentioned above is documented here: https://github.com/lampepfl/dotty/issues/13406 and fixed by https://github.com/lampepfl/dotty/pull/14405 . This has gone out in Scala 3.1.2, so time to upgrade and re-release...

sageserpent-open commented 2 years ago

As of release 1.3.3, commit SHA 7e7e52c42e3520f0c9b573a88a0a737eae4380e1 , we have a release for Scala 2.13.8 and 3.1.2 . The test to show automatic derivation of a Trials for recursively defined types has been reinstated for Scala 3, it exists as a near duplicate of the one for Scala 2.13 - there is a wrinkle for the Scala 3 support that requires the use site for the automatically generated implicit to be captured in an, ahem, 'explicit' implicit definition. This isn't required for generation of Trials for types that are not recursively defined, so the test for that situation can be left as cross-version shared source.

They said that 'perfect as the enemy of the good', so on that note I'm closing this ticket.