File tree 1 file changed +38
-0
lines changed
1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change
1
+ object Example extends App {
2
+
3
+ trait Has [A ]
4
+
5
+ trait ZIO [- R ] {
6
+ def provideLayer [R0 , R1 <: Has [_]](
7
+ layer : ZLayer [R0 , R1 ]
8
+ )(implicit ev : R1 <:< R ): ZIO [R0 ] =
9
+ ???
10
+ }
11
+
12
+ trait ZLayer [- RIn , + ROut <: Has [_]] {
13
+ def ++ [RIn2 , ROut1 >: ROut <: Has [_], ROut2 <: Has [_]](
14
+ that : ZLayer [RIn2 , ROut2 ]
15
+ ): ZLayer [RIn with RIn2 , ROut1 with ROut2 ] = ???
16
+ }
17
+
18
+ trait RandomService
19
+ trait SizedService
20
+
21
+ type Random = Has [RandomService ]
22
+ type Sized = Has [SizedService ]
23
+
24
+ def random : ZLayer [Random , Random ] = ???
25
+ def sized : ZLayer [Any , Sized ] = ???
26
+
27
+ lazy val zio : ZIO [Random with Sized ] = ???
28
+
29
+ // Okay on Scala 2, does not compile on Dotty
30
+ lazy val eliminated : ZIO [Random ] =
31
+ zio.provideLayer(random ++ sized)
32
+
33
+ // Compiles on Dotty with an explicit type annotation
34
+ lazy val eliminated2 : ZIO [Random ] =
35
+ zio.provideLayer[Random , Random with Sized ](random ++ sized)
36
+
37
+ println(" It compiles!" )
38
+ }
You can’t perform that action at this time.
0 commit comments