Closed
Description
Minimized code
File 1:
package gopher
import scala.util.Try
def await[F[_],T](f:F[T])(using am:CpsAsyncMonad[F]):T = ???
trait CpsAsyncMonad[F[_]]:
def adoptCallbackStyle[A](source: (Try[A]=>Unit) => Unit): F[A]
trait IChannel[F[_]:CpsAsyncMonad, A]:
def aread:F[A] =
summon[CpsAsyncMonad[F]].adoptCallbackStyle(f => addReader(f))
inline def read: A = await(aread)
def addReader(f: Try[A]=>Unit): Unit
trait IOChannel[F[_]:CpsAsyncMonad,I,O] extends IChannel[F,I] with OChannel[F,O]
File 2:
package gopher
import scala.util.Try
trait OChannel[F[_]:CpsAsyncMonad, A]:
def awrite(a:A):F[Unit] =
summon[CpsAsyncMonad[F]].adoptCallbackStyle(f =>
addWriter(a, f)
)
inline def write(a:A): Unit = await(awrite(a))
def addWriter(a:A, f: Try[Unit]=>Unit): Unit
Output
[info] compiling 2 Scala sources to /Users/rssh/work/oss/dotty-bug1/jvm/target/scala-3.0.0-M2/classes ...
[error] -- Error: /Users/rssh/work/oss/dotty-bug1/shared/src/main/scala/gopher/Channel.scala:21:6
[error] 21 |trait IOChannel[F[_]:CpsAsyncMonad,I,O] extends IChannel[F,I] with OChannel[F,O]
[error] | ^
[error] |trait IOChannel inherits conflicting members:
[error] | method inline$evidence$1 in trait IChannel of type => gopher.CpsAsyncMonad[F] and
[error] | method inline$evidence$1 in trait OChannel of type => gopher.CpsAsyncMonad[F]
[error] |(Note: this can be resolved by declaring an override in trait IOChannel.)
[error] one error found
[error] (gopherJVM / Compile / compileIncremental) Compilation failed
Expectation
should compile.
Note, that if I put all definitions in one file -- compilation is successful.