Skip to content

Commit f4528ce

Browse files
authored
Merge pull request #9876 from dotty-staging/fix-8031
2 parents 07d3e2d + 7d53bb8 commit f4528ce

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

tests/pos/i8031.scala

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
}

0 commit comments

Comments
 (0)