-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Regression in yurikpanic/zio-postgres
- ambigious extension methods prevent type reduction
#20288
Comments
Seems like another project fails due to 389f5be - I've not managed to minimize the compilation error in |
One more affected project // 1_defns.scala
import scala.compiletime.*
import scala.deriving.*
sealed trait ZIO[-R, +E, +A]
sealed abstract class ZLayer[-RIn, +E, +ROut]
object ZLayer:
def apply[RIn, E, ROut](zio: => ZIO[RIn, E, ROut]): ZLayer[RIn, E, ROut] = ???
type URIO[-R, +A] = ZIO[R, Nothing, A]
type IAnyType[T <: Tuple] = Tuple.Fold[T, Any, [x, y] =>> x & y]
type UAnyType[T <: Tuple] = Tuple.Fold[T, Any, [x, y] =>> x | y]
trait AutoLayer[A]:
def zlayer(using
p: Mirror.ProductOf[A]
): ZLayer[IAnyType[p.MirroredElemTypes], Nothing, A]
object AutoLayer:
inline given derived[A](using p: Mirror.ProductOf[A]): AutoLayer[A] = {
val a: ZIO[IAnyType[p.MirroredElemTypes], Nothing, A] = ???
new AutoLayer[A]:
override def zlayer(using
pp: Mirror.ProductOf[A]
): ZLayer[IAnyType[pp.MirroredElemTypes], Nothing, A] = ZLayer {
a.asInstanceOf[ZIO[IAnyType[pp.MirroredElemTypes], Nothing, A]]
}
} // 2_usage.scala
case class TestService(port: Int) derives AutoLayer yields: [error] Found: ZLayer[Tuple.Fold[pp.MirroredElemTypes, Any, [x, y] =>> x & y], Nothing,
[error] TestService]
[error] Required: ZLayer[IAnyType[pp.MirroredElemTypes], Nothing, TestService]
[error]
[error] Note: a match type could not be fully reduced:
[error]
[error] trying to reduce Tuple.Fold[pp.MirroredElemTypes, Any, [x, y] =>> x & y]
[error] failed since selector pp.MirroredElemTypes
[error] does not match case EmptyTuple => Any
[error] and cannot be shown to be disjoint from it either.
[error] Therefore, reduction cannot advance to the remaining case
[error]
[error] case h *: t => h & Tuple.Fold[t, Any, [x, y] =>> x & y]
[error] case class TestService(port: Int) derives AutoLayer |
) Backports #20857 to the LTS branch. PR submitted by the release tooling.
Based on OpenCB failure in
yurikpanic/zio-postgres
- build logsCompiler version
Last good release: 3.5.0-RC1-bin-20240406-521ce95-NIGHTLY
First bad release: 3.5.0-RC1-bin-20240408-1e8a653-NIGHTLY
Failed to finish bisect - the compiler fails to compile, first bad commit can by any of 389f5be 1dc5b99
Minimized code
Output
Expectation
The result type should be fully reduced into tuple.
The text was updated successfully, but these errors were encountered: