diff --git a/tests/neg-macros/i14123a.scala b/tests/neg-macros/i14123a.scala new file mode 100644 index 000000000000..29978f85102c --- /dev/null +++ b/tests/neg-macros/i14123a.scala @@ -0,0 +1,4 @@ +import scala.quoted._ + +def f(foo: Any => Any)(using Quotes): Expr[Any] = + '{ println(${ foo[Int]('{???}); ??? }) } // error diff --git a/tests/neg-macros/i14123b.scala b/tests/neg-macros/i14123b.scala new file mode 100644 index 000000000000..80cadf518766 --- /dev/null +++ b/tests/neg-macros/i14123b.scala @@ -0,0 +1,23 @@ +package x + +import scala.quoted._ + +object Impl { + + sealed trait UpdateOp[+T] + case class Assignment[T](value:Expr[T]) extends UpdateOp[T] + case class Update(operation:Expr[Unit]) extends UpdateOp[Nothing] + + def genRead[B:Type](newBuilder: Expr[B], + readVal: (Expr[B]) => UpdateOp[B] + )(using Quotes): Expr[B] = + '{ + var x = $newBuilder + ${readVal[B]('x) match { // error: method apply in trait Function1 does not take type parameters + case Assignment(value) => '{ x = $value } // error + case Update(operation) => operation // error + }} + x + } + +}