# How to migrate away from package objects containing implicits to Scala 3?

**URL:** <https://users.scala-lang.org/t/how-to-migrate-away-from-package-objects-containing-implicits-to-scala-3/9747>\
**Category:** Question\
**Created:** [January 26, 2024, 2:26pm UTC](https://users.scala-lang.org/t/how-to-migrate-away-from-package-objects-containing-implicits-to-scala-3/9747 "2024-01-26T14:26:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Turin](https://users.scala-lang.org/user_avatar/users.scala-lang.org/turin/32/2092_2.png) [@Turin](https://users.scala-lang.org/u/Turin)\
**Post date:** [January 26, 2024, 2:26pm UTC](https://users.scala-lang.org/t/how-to-migrate-away-from-package-objects-containing-implicits-to-scala-3/9747/1 "2024-01-26T14:26:18Z")

</div>

I have implicit conversions for types defined in a package (not classes, type aliases), so I need to locate them in the same namespace to be inside the implicit search scope. Scala 3 allows top level package definitions. That’s great. But package objects can extend `LowPriorityImplicits`-like traits, allowing to introduce precedence between several type classes. What’s the best path in adapting this to Scala 3, which will not cause several source incompatibility?

I know I can use `opaque` types instead of type aliases, and put the type classes to their companion object, which, obviously, can extend ‘low priority’ traits, but that means both that my Scala 2 and Scala 3 code diverges to a point severly impacting the ability to introduce changes in a coordinated manner (not cross compiling, but applying patches or cut&pastes with minimal effort), and that it might severly break client code sources (binary compatibility is not my goal).

Another is to turn my package into a huge object, but value classes can be declared only in the object itself, and the idea of ten thousand lines of code in a single file terrifies me.

Do you have better ideas?

---

<div class="post-metadata">

**Author:** ![som-snytt](https://users.scala-lang.org/letter_avatar_proxy/v4/letter/s/7cd45c/32.png) [@som-snytt](https://users.scala-lang.org/u/som-snytt)\
**Post date:** [January 26, 2024, 10:01pm UTC](https://users.scala-lang.org/t/how-to-migrate-away-from-package-objects-containing-implicits-to-scala-3/9747/2 "2024-01-26T22:01:33Z")

</div>

I thought they granted package objects with inheritance a reprieve in Scala 3, which for purposes of migration amounts to a full pardon.

---

<div class="post-metadata">

**Author:** ![Turin](https://users.scala-lang.org/user_avatar/users.scala-lang.org/turin/32/2092_2.png) [@Turin](https://users.scala-lang.org/u/Turin)\
**Post date:** [January 28, 2024, 4:02pm UTC](https://users.scala-lang.org/t/how-to-migrate-away-from-package-objects-containing-implicits-to-scala-3/9747/3 "2024-01-28T16:02:48Z")

</div>

The way things are going, it can be ten years away…
