Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is prompted by guardian/mobile-apps-api#3198 - we would like to be able to upgrade MAPI to Scala 3. As MAPI depends on https://github.com/guardian/cross-platform-navigation, it's good to have a Scala 3 version of this library. The only tricky part of upgrading `cross-platform-navigation` to Scala 3 is handling the explicit call to the `unapply()` method, which _used_ to return an `Option[(...,...,...)]` with all the parameters used to create the case class - in Scala 3 that's changed: * https://docs.scala-lang.org/scala3/guides/migration/incompat-other-changes.html#explicit-call-to-unapply * scala/scala3#2335 The least magical way to cope with the changed `unapply()` method is to manually write out what the unapply method used to produce, and that's what I've done here. Looking at the discussion on the Scala issue, there are other workarounds which are Scala 3-only (and so wouldn't easily work in this project, which cross-compiles with Scala 2): * scala/scala3#2335 (comment) gives us this, which did work for me, but just in Scala 3: ``` def doOldUnapply(ns: NavigationSection) = Some(Tuple.fromProductTyped(ns)) ``` * scala/scala3#2335 (comment) - this is apparently a general version of the method above, but didn't work for me - complained that `NavigationSection` is not a `Product`, I think?
- Loading branch information