From fb235681f5ff9b8fc96e3bc064d37b2ea61d94b1 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Tue, 2 May 2023 09:22:03 +0200 Subject: [PATCH] Add regression test Fix #14123 --- tests/neg-macros/i14123a.scala | 4 ++++ tests/neg-macros/i14123b.scala | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 tests/neg-macros/i14123a.scala create mode 100644 tests/neg-macros/i14123b.scala 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 + } + +}