Open
Description
Compiler version
All Scala versions since 3.4.0
Minimized code
sealed abstract class ZLayer[-RIn, +E, +ROut]
trait Tag[T]
trait GraphQLInterpreter[-R, +E]:
final def provideSomeLayer[R0]: GraphQLInterpreter.ProvideSomeLayer[R0, R, E] = ???
object GraphQLInterpreter:
final class ProvideSomeLayer[R0, -R, +E](private val self: GraphQLInterpreter[R, E]):
def apply[E1 >: E, R1](layer: => ZLayer[R0, E1, R1])(implicit ev1: R0 with R1 <:< R, tagged: Tag[R1]): GraphQLInterpreter[R0, E1] = ???
final class UnsafeApi[R](interpreter: GraphQLInterpreter[R, Any]):
def provideSomeLayer[R0](layer: ZLayer[R0, Any, R])(implicit tag: Tag[R]): UnsafeApi[R0] =
new UnsafeApi(interpreter.provideSomeLayer(layer))
Output
Rewrites R0 with R1 <:< R
to R0 & R1 <:< R
. However it's interpreted differently:
R0 with R1 <:< R
=== (R0 & R1) <:< R
R0 & R1 <:< R
=== R0 & (R1 <:< R)
[error] ./src/main/scala/test.scala:12:54
[error] Cannot prove that R <:< R.
[error] new UnsafeApi(interpreter.provideSomeLayer(layer))
[error]
Expectation
The compiler should either treat the symbolic &
in the same as the with
symbol, or it should introduce parenthesis when rewriting symbols.