Open rssh opened 2 years ago
Missing the definition of ContextMonad
oops, here is the full text:
package x
trait ContextMonad[F[_]]:
type Context
object ContextMonad:
type Aux[F[_],C] = ContextMonad[F] { type Context = C }
trait CBContext:
def foo() = ???
trait CB[T]
given ContextMonad[CB] with
override type Context = CBContext
// inline am is significant - without inline this compild
inline def runContext[F[_]](using inline am: ContextMonad[F]) = InferAsyncArg(am)
class InferAsyncArg[F[_],C](val am: ContextMonad.Aux[F,C]):
def apply[T](f: C ?=> T):F[T] = ???
object X:
def bar = runContext[CB]{
summon[CBContext].foo()
1
}
The current failure is
-- [E007] Type Mismatch Error: t/Test.scala:19:78 ------------------------------
19 |inline def runContext[F[_]](using inline am: ContextMonad[F]) = InferAsyncArg(am)
| ^^
| Found: (am : x.ContextMonad[F])
| Required: x.ContextMonad.Aux[F², C]
|
| where: C is a type variable
| F is a type in method runContext with bounds <: [_] =>> Any
| F² is a type variable with constraint <: [_²] =>> Any
|
| longer explanation available when compiling with `-explain`
-- [E007] Type Mismatch Error: t/Test.scala:27:5 -------------------------------
27 | summon[CBContext].foo()
| ^^^^^^^^^^^^^^^^^
|Found: (evidence$1 : Nothing)
|Required: ?{ foo: ? }
|Note that implicit conversions were not tried because the result of an implicit conversion
|must be more specific than ?{ foo: [applied to () returning <?>] }
|
| longer explanation available when compiling with `-explain`
Not sure if that is the expected behavior.
Compiler version
3.1.0, 3.1.1-RC1
Minimized code
Output
Expectation
Should be compiled.