Skip to content

Fix #8031: Add testcase #9876

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 25, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions tests/pos/i8031.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
object Example extends App {

trait Has[A]

trait ZIO[-R] {
def provideLayer[R0, R1 <: Has[_]](
layer: ZLayer[R0, R1]
)(implicit ev: R1 <:< R): ZIO[R0] =
???
}

trait ZLayer[-RIn, +ROut <: Has[_]] {
def ++[RIn2, ROut1 >: ROut <: Has[_], ROut2 <: Has[_]](
that: ZLayer[RIn2, ROut2]
): ZLayer[RIn with RIn2, ROut1 with ROut2] = ???
}

trait RandomService
trait SizedService

type Random = Has[RandomService]
type Sized = Has[SizedService]

def random: ZLayer[Random, Random] = ???
def sized: ZLayer[Any, Sized] = ???

lazy val zio: ZIO[Random with Sized] = ???

// Okay on Scala 2, does not compile on Dotty
lazy val eliminated: ZIO[Random] =
zio.provideLayer(random ++ sized)

// Compiles on Dotty with an explicit type annotation
lazy val eliminated2: ZIO[Random] =
zio.provideLayer[Random, Random with Sized](random ++ sized)

println("It compiles!")
}