Skip to content

implicit parameters passed to macros can not be resolved #7839

Closed
@rssh

Description

@rssh

minimized code

package direct1
  
import org.junit.Test
import org.junit.Assert._

import scala.quoted._
import scala.quoted.matching._


trait DM[F[_]] {

   def pure[T:Type](t:Expr[T]):(given ctx:QuoteContext) => Expr[F[T]]

}

sealed trait CB[T]
case class Done[T](value:T) extends CB[T]

implicit object dmCB extends DM[CB] {

  def pure[T:Type](t:Expr[T]):(given ctx:QuoteContext) => Expr[CB[T]] =
    '{ Done(${t}) }

}


object A {

  inline def transform[F[_],T](expr: =>T): F[T] =
    ${   A.transformImpl('expr)  }

  def transformImpl[F[_]:DM,T:Type](f: Expr[T])(given QuoteContext):Expr[F[T]] =
    f match
      case Const(t) => implicitly[DM[F]].pure(f)
      case _ => print(f)
         throw new IllegalStateException("language construction is not supported")

}

class TestBS2

  @Test def tConstant(): Unit = {
     val c = A.transform[CB,Int](3)
     assert(c == Done(3))
  }

During compiling we have:

[error] -- Error: /Users/rssh/work/oss/dotty-async/dotty-async/src/test/scala/direct/TestCBS2.scala:31:29 
[error] 31 |       A.transformImpl('expr)
[error]    |                             ^
[error]    |no implicit argument of type direct1.DM[F] was found for parameter evidence$2 of method transformImpl in object A

but dmCB was defined.

expectation

compilation without a problem.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions