Skip to content

Commit ab1ffb0

Browse files
committed
scala3: add workarounds for scala/scala3#16183 and re-enable ModuleBaseInstancesTest for Scala 3
1 parent 43add64 commit ab1ffb0

File tree

4 files changed

+197
-55
lines changed

4 files changed

+197
-55
lines changed

distage/distage-core/src/test/scala-2/izumi/distage/compat/ModuleBaseInstancesTest.scala renamed to distage/distage-core/src/test/scala/izumi/distage/compat/ModuleBaseInstancesTest.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ final class ModuleBaseInstancesTest extends AnyWordSpec {
2525

2626
val mod3_2 = Module.empty
2727

28+
def t[K[_]: izumi.fundamentals.orphans.`cats.kernel.BoundedSemilattice`](): K[Int] = ().asInstanceOf
29+
t()
2830
val mod3 = (mod3_1 |+| mod3_2) :+ binding[NotInContext]
2931

3032
val mod4 = Module.make(
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
package izumi.fundamentals.orphans
2+
3+
import scala.annotation.unused
4+
5+
// FIXME Split instances for F[_]-kind because of a Scala 3 bug https://github.com/lampepfl/dotty/issues/16183
6+
7+
/**
8+
* `No More Orphans` type providers. See detail https://blog.7mind.io/no-more-orphans.html
9+
*
10+
* These instances uses 'no more orphans' trick to provide an Optional instance
11+
* only IFF you have cats-effect as a dependency without REQUIRING a cats-effect dependency.
12+
*
13+
* Optional instance via https://blog.7mind.io/no-more-orphans.html
14+
*/
15+
16+
// cats-kernel
17+
18+
final abstract class `cats.kernel.BoundedSemilattice`[K[_]]
19+
object `cats.kernel.BoundedSemilattice` {
20+
@inline implicit final def get: `cats.kernel.BoundedSemilattice`[cats.kernel.BoundedSemilattice] = null
21+
}
22+
23+
/**
24+
* This instance uses 'no more orphans' trick to provide an Optional instance
25+
* only IFF you have cats-effect as a dependency without REQUIRING a cats-effect dependency.
26+
*
27+
* Optional instance via https://blog.7mind.io/no-more-orphans.html
28+
*/
29+
final abstract class `cats.kernel.Monoid`[K[_]]
30+
object `cats.kernel.Monoid` {
31+
@inline implicit final def get: `cats.kernel.Monoid`[cats.kernel.Monoid] = null
32+
}
33+
34+
// cats-core
35+
36+
/**
37+
* This instance uses 'no more orphans' trick to provide an Optional instance
38+
* only IFF you have cats-effect as a dependency without REQUIRING a cats-effect dependency.
39+
*
40+
* Optional instance via https://blog.7mind.io/no-more-orphans.html
41+
*/
42+
final abstract class `cats.Semigroup`[S[_]]
43+
object `cats.Semigroup` {
44+
@inline implicit final def get: `cats.Semigroup`[cats.Semigroup] = null
45+
}
46+
47+
// cats-effect
48+
49+
/**
50+
* This instance uses 'no more orphans' trick to provide an Optional instance
51+
* only IFF you have cats-effect as a dependency without REQUIRING a cats-effect dependency.
52+
*
53+
* Optional instance via https://blog.7mind.io/no-more-orphans.html
54+
*/
55+
final abstract class `cats.effect.IO`[K[_]]
56+
object `cats.effect.IO` {
57+
@inline implicit final def get: `cats.effect.IO`[cats.effect.IO] = null
58+
}
59+
60+
//// monix
61+
//
62+
///**
63+
// * This instance uses 'no more orphans' trick to provide an Optional instance
64+
// * only IFF you have cats-effect as a dependency without REQUIRING a cats-effect dependency.
65+
// *
66+
// * Optional instance via https://blog.7mind.io/no-more-orphans.html
67+
// */
68+
//final abstract class `monix.eval.Task`[K[_]]
69+
//object `monix.eval.Task` {
70+
// @inline implicit final def get: `monix.eval.Task`[monix.eval.Task] = null
71+
//}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
package izumi.fundamentals.orphans
2+
3+
import scala.annotation.unused
4+
5+
// FIXME Split instances for F[_]-kind because of a Scala 3 bug https://github.com/lampepfl/dotty/issues/16183
6+
7+
/**
8+
* `No More Orphans` type providers. See detail https://blog.7mind.io/no-more-orphans.html
9+
*
10+
* These instances uses 'no more orphans' trick to provide an Optional instance
11+
* only IFF you have cats-effect as a dependency without REQUIRING a cats-effect dependency.
12+
*
13+
* Optional instance via https://blog.7mind.io/no-more-orphans.html
14+
*/
15+
16+
// cats-kernel
17+
18+
final abstract class `cats.kernel.BoundedSemilattice`[K[_]]
19+
object `cats.kernel.BoundedSemilattice` {
20+
@inline implicit final def get: `cats.kernel.BoundedSemilattice`[[A] =>> cats.kernel.BoundedSemilattice[A]] = null
21+
}
22+
23+
/**
24+
* This instance uses 'no more orphans' trick to provide an Optional instance
25+
* only IFF you have cats-effect as a dependency without REQUIRING a cats-effect dependency.
26+
*
27+
* Optional instance via https://blog.7mind.io/no-more-orphans.html
28+
*/
29+
final abstract class `cats.kernel.Monoid`[K[_]]
30+
object `cats.kernel.Monoid` {
31+
@inline implicit final def get: `cats.kernel.Monoid`[[A] =>> cats.kernel.Monoid[A]] = null
32+
}
33+
34+
/**
35+
* This instance uses 'no more orphans' trick to provide an Optional instance
36+
* only IFF you have cats-effect as a dependency without REQUIRING a cats-effect dependency.
37+
*
38+
* Optional instance via https://blog.7mind.io/no-more-orphans.html
39+
*/
40+
final abstract class `cats.kernel.Semigroup`[S[_]]
41+
object `cats.kernel.Semigroup` {
42+
@inline implicit final def get: `cats.kernel.Semigroup`[[A] =>> cats.kernel.Semigroup[A]] = null
43+
}
44+
45+
// cats-effect
46+
47+
/**
48+
* This instance uses 'no more orphans' trick to provide an Optional instance
49+
* only IFF you have cats-effect as a dependency without REQUIRING a cats-effect dependency.
50+
*
51+
* Optional instance via https://blog.7mind.io/no-more-orphans.html
52+
*/
53+
final abstract class `cats.effect.IO`[K[_]]
54+
object `cats.effect.IO` {
55+
@inline implicit final def get: `cats.effect.IO`[[A] =>> cats.effect.IO[A]] = null
56+
}
57+
58+
//// monix
59+
//
60+
///**
61+
// * This instance uses 'no more orphans' trick to provide an Optional instance
62+
// * only IFF you have cats-effect as a dependency without REQUIRING a cats-effect dependency.
63+
// *
64+
// * Optional instance via https://blog.7mind.io/no-more-orphans.html
65+
// */
66+
//final abstract class `monix.eval.Task`[K[_]]
67+
//object `monix.eval.Task` {
68+
// @inline implicit final def get: `monix.eval.Task`[monix.eval.Task] = null
69+
//}

fundamentals/fundamentals-orphans/src/main/scala/izumi/fundamentals/orphans/OrphanDefs.scala

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,19 @@ import scala.annotation.unused
1313

1414
// cats-kernel
1515

16-
final abstract class `cats.kernel.BoundedSemilattice`[K[_]]
17-
object `cats.kernel.BoundedSemilattice` {
18-
@inline implicit final def get: `cats.kernel.BoundedSemilattice`[cats.kernel.BoundedSemilattice] = null
19-
}
20-
21-
/**
22-
* This instance uses 'no more orphans' trick to provide an Optional instance
23-
* only IFF you have cats-effect as a dependency without REQUIRING a cats-effect dependency.
24-
*
25-
* Optional instance via https://blog.7mind.io/no-more-orphans.html
26-
*/
27-
final abstract class `cats.kernel.Monoid`[K[_]]
28-
object `cats.kernel.Monoid` {
29-
@inline implicit final def get: `cats.kernel.Monoid`[cats.kernel.Monoid] = null
16+
final abstract class `cats.kernel.PartialOrder with cats.kernel.Hash`[K[_]]
17+
object `cats.kernel.PartialOrder with cats.kernel.Hash` {
18+
type PartialOrderHashType[T] = cats.kernel.PartialOrder[T] & cats.kernel.Hash[T]
19+
@inline implicit final def get[K[_]](
20+
implicit @unused guard: `cats.kernel.BoundedSemilattice`[K]
21+
): `cats.kernel.PartialOrder with cats.kernel.Hash`[PartialOrderHashType] = null
3022
}
3123

3224
// cats-core
3325

3426
/**
3527
* This instance uses 'no more orphans' trick to provide an Optional instance
36-
* only IFF you have cats-core as a dependency without REQUIRING a cats-core dependency.
28+
* only IFF you have cats-effect as a dependency without REQUIRING a cats-effect dependency.
3729
*
3830
* Optional instance via https://blog.7mind.io/no-more-orphans.html
3931
*/
@@ -53,29 +45,28 @@ object `cats.Applicative` {
5345
@inline implicit final def get: `cats.Applicative`[cats.Applicative] = null
5446
}
5547

48+
/**
49+
* This instance uses 'no more orphans' trick to provide an Optional instance
50+
* only IFF you have cats-effect as a dependency without REQUIRING a cats-effect dependency.
51+
*
52+
* Optional instance via https://blog.7mind.io/no-more-orphans.html
53+
*/
5654
final abstract class `cats.Monad`[M[_[_]]]
5755
object `cats.Monad` {
5856
@inline implicit final def get: `cats.Monad`[cats.Monad] = null
5957
}
6058

61-
final abstract class `cats.Semigroup`[S[_]]
62-
object `cats.Semigroup` {
63-
@inline implicit final def get: `cats.Semigroup`[cats.Semigroup] = null
64-
}
65-
59+
/**
60+
* This instance uses 'no more orphans' trick to provide an Optional instance
61+
* only IFF you have cats-effect as a dependency without REQUIRING a cats-effect dependency.
62+
*
63+
* Optional instance via https://blog.7mind.io/no-more-orphans.html
64+
*/
6665
final abstract class `cats.Parallel`[K[_[_]]]
6766
object `cats.Parallel` {
6867
@inline implicit final def get: `cats.Parallel`[cats.Parallel] = null
6968
}
7069

71-
final abstract class `cats.kernel.PartialOrder with cats.kernel.Hash`[K[_]]
72-
object `cats.kernel.PartialOrder with cats.kernel.Hash` {
73-
type PartialOrderHashType[T] = cats.kernel.PartialOrder[T] & cats.kernel.Hash[T]
74-
@inline implicit final def get[K[_]](
75-
implicit @unused guard: `cats.kernel.BoundedSemilattice`[K]
76-
): `cats.kernel.PartialOrder with cats.kernel.Hash`[PartialOrderHashType] = null
77-
}
78-
7970
// cats-effect
8071

8172
/**
@@ -89,16 +80,34 @@ object `cats.effect.kernel.Sync` {
8980
@inline implicit final def get: `cats.effect.kernel.Sync`[cats.effect.kernel.Sync] = null
9081
}
9182

83+
/**
84+
* This instance uses 'no more orphans' trick to provide an Optional instance
85+
* only IFF you have cats-effect as a dependency without REQUIRING a cats-effect dependency.
86+
*
87+
* Optional instance via https://blog.7mind.io/no-more-orphans.html
88+
*/
9289
final abstract class `cats.effect.kernel.Async`[R[_[_]]]
9390
object `cats.effect.kernel.Async` {
9491
@inline implicit final def get: `cats.effect.kernel.Async`[cats.effect.kernel.Async] = null
9592
}
9693

94+
/**
95+
* This instance uses 'no more orphans' trick to provide an Optional instance
96+
* only IFF you have cats-effect as a dependency without REQUIRING a cats-effect dependency.
97+
*
98+
* Optional instance via https://blog.7mind.io/no-more-orphans.html
99+
*/
97100
final abstract class `cats.effect.kernel.MonadCancel`[R[_[_], E]]
98101
object `cats.effect.kernel.MonadCancel` {
99102
@inline implicit final def get: `cats.effect.kernel.MonadCancel`[cats.effect.kernel.MonadCancel] = null
100103
}
101104

105+
/**
106+
* This instance uses 'no more orphans' trick to provide an Optional instance
107+
* only IFF you have cats-effect as a dependency without REQUIRING a cats-effect dependency.
108+
*
109+
* Optional instance via https://blog.7mind.io/no-more-orphans.html
110+
*/
102111
final abstract class `cats.effect.kernel.Concurrent`[K[_[_]]]
103112
object `cats.effect.kernel.Concurrent` {
104113
@inline implicit final def get: `cats.effect.kernel.Concurrent`[cats.effect.kernel.Concurrent] = null
@@ -126,50 +135,41 @@ object `cats.effect.unsafe.IORuntime` {
126135
@inline implicit final def get: `cats.effect.unsafe.IORuntime`[cats.effect.unsafe.IORuntime] = null
127136
}
128137

129-
//final abstract class `cats.effect.kernel.ConcurrentEffect`[K[_[_]]]
130-
//object `cats.effect.kernel.ConcurrentEffect` {
131-
// @inline implicit final def get: `cats.effect.kernel.ConcurrentEffect`[cats.effect.kernel.ConcurrentEffect] = null
132-
//}
133-
134-
//final abstract class `cats.effect.kernel.Clock`[K[_[_]]]
135-
//object `cats.effect.kernel.Clock` {
136-
// @inline implicit final def get: `cats.effect.kernel.Clock`[cats.effect.kernel.Clock] = null
137-
//}
138-
139-
//final abstract class `cats.effect.ContextShift`[K[_[_]]]
140-
//object `cats.effect.ContextShift` {
141-
// @inline implicit final def get: `cats.effect.ContextShift`[cats.effect.ContextShift] = null
142-
//}
143-
144-
final abstract class `cats.effect.IO`[K[_]]
145-
object `cats.effect.IO` {
146-
@inline implicit final def get: `cats.effect.IO`[cats.effect.IO] = null
147-
}
148-
149138
// zio
150139

140+
/**
141+
* This instance uses 'no more orphans' trick to provide an Optional instance
142+
* only IFF you have cats-effect as a dependency without REQUIRING a cats-effect dependency.
143+
*
144+
* Optional instance via https://blog.7mind.io/no-more-orphans.html
145+
*/
151146
final abstract class `zio.ZIO`[K[_, _, _]]
152147
object `zio.ZIO` {
153148
@inline implicit final def get: `zio.ZIO`[zio.ZIO] = null
154149
}
155150

156151
// zio-interop-cats
157152

153+
/**
154+
* This instance uses 'no more orphans' trick to provide an Optional instance
155+
* only IFF you have cats-effect as a dependency without REQUIRING a cats-effect dependency.
156+
*
157+
* Optional instance via https://blog.7mind.io/no-more-orphans.html
158+
*/
158159
final abstract class `zio.interop.ZManagedSyntax`[K[_, _, _]]
159160
object `zio.interop.ZManagedSyntax` {
160161
@inline implicit final def get: `zio.interop.ZManagedSyntax`[zio.interop.ZManagedSyntax] = null
161162
}
162163

163164
//// monix-bio
164165
//
166+
///**
167+
// * This instance uses 'no more orphans' trick to provide an Optional instance
168+
// * only IFF you have cats-effect as a dependency without REQUIRING a cats-effect dependency.
169+
// *
170+
// * Optional instance via https://blog.7mind.io/no-more-orphans.html
171+
// */
165172
//final abstract class `monix.bio.IO`[K[_, _]]
166173
//object `monix.bio.IO` {
167174
// @inline implicit final def get: `monix.bio.IO`[monix.bio.IO] = null
168175
//}
169-
//
170-
//// monix
171-
//
172-
//final abstract class `monix.eval.Task`[K[_]]
173-
//object `monix.eval.Task` {
174-
// @inline implicit final def get: `monix.eval.Task`[monix.eval.Task] = null
175-
//}

0 commit comments

Comments
 (0)