diff --git a/community-build/community-projects/utest b/community-build/community-projects/utest index ce64e038ee8a..992c80ae071b 160000 --- a/community-build/community-projects/utest +++ b/community-build/community-projects/utest @@ -1 +1 @@ -Subproject commit ce64e038ee8af4551a8b22ee9cec5d510be4ef67 +Subproject commit 992c80ae071b027f0bfe4371788cb68987531808 diff --git a/compiler/src/dotty/tools/dotc/transform/Splicer.scala b/compiler/src/dotty/tools/dotc/transform/Splicer.scala index 570e646a749a..34c9edc944e9 100644 --- a/compiler/src/dotty/tools/dotc/transform/Splicer.scala +++ b/compiler/src/dotty/tools/dotc/transform/Splicer.scala @@ -146,18 +146,12 @@ object Splicer { case Apply(Select(Apply(fn, quoted :: Nil), nme.apply), _) if fn.symbol == defn.InternalQuoted_exprQuote => // OK - case TypeApply(fn, quoted :: Nil) if fn.symbol == defn.QuotedTypeModule_apply => + case Apply(Select(TypeApply(fn, List(quoted)), nme.apply), _)if fn.symbol == defn.QuotedTypeModule_apply => // OK case Literal(Constant(value)) => // OK - case Call(fn, args) - if (fn.symbol.isConstructor && fn.symbol.owner.owner.is(Package)) || - fn.symbol.is(Module) || fn.symbol.isStatic || - (fn.qualifier.symbol.is(Module) && fn.qualifier.symbol.isStatic) => - args.foreach(_.foreach(checkIfValidArgument)) - case NamedArg(_, arg) => checkIfValidArgument(arg) diff --git a/tests/neg-macros/i4492/quoted_1.scala b/tests/neg-macros/i4492/quoted_1.scala new file mode 100644 index 000000000000..4ac493c3ead1 --- /dev/null +++ b/tests/neg-macros/i4492/quoted_1.scala @@ -0,0 +1,6 @@ + +trait Index + +object Index { + inline def succ(prev: Index): Unit = ${ '{println("Ok")} } // error +} diff --git a/tests/run-macros/i4492/quoted_2.scala b/tests/neg-macros/i4492/quoted_2.scala similarity index 67% rename from tests/run-macros/i4492/quoted_2.scala rename to tests/neg-macros/i4492/quoted_2.scala index 7b1ed8119507..d261f7e49c29 100644 --- a/tests/run-macros/i4492/quoted_2.scala +++ b/tests/neg-macros/i4492/quoted_2.scala @@ -1,6 +1,6 @@ object Test { def main(args: Array[String]): Unit = { - Index.succ(null) + Index.succ(null) // error } } diff --git a/tests/neg-macros/i4493-b.scala b/tests/neg-macros/i4493-b.scala index c3b9f6cdeab6..6edf794d74b3 100644 --- a/tests/neg-macros/i4493-b.scala +++ b/tests/neg-macros/i4493-b.scala @@ -1,7 +1,8 @@ +import scala.quoted._ class Index[K] object Index { inline def succ[K](x: K): Unit = ${ - implicit val t: quoted.Type[K] = Type[K] // error - '{new Index[K]} + implicit val t: Type[K] = Type[K] // error + '{new Index[K]} // error } } diff --git a/tests/pos-macros/i4493-c.scala b/tests/neg-macros/i4493-c.scala similarity index 70% rename from tests/pos-macros/i4493-c.scala rename to tests/neg-macros/i4493-c.scala index 3ced80d53e22..1d3d8aed37d4 100644 --- a/tests/pos-macros/i4493-c.scala +++ b/tests/neg-macros/i4493-c.scala @@ -1,6 +1,6 @@ class Index[K] object Index { inline def succ[K]: Unit = ${ - '{new Index[K]} + '{new Index[K]} // error } } diff --git a/tests/neg-macros/i4493.scala b/tests/neg-macros/i4493.scala index 810594a06339..c0e8bc4b4bd7 100644 --- a/tests/neg-macros/i4493.scala +++ b/tests/neg-macros/i4493.scala @@ -1,7 +1,8 @@ +import scala.quoted._ class Index[K] object Index { inline def succ[K]: Unit = ${ - implicit val t: quoted.Type[K] = Type[K] // error - '{new Index[K]} + implicit val t: Type[K] = Type[K] // error + '{new Index[K]} // error } } diff --git a/tests/neg-macros/i5547.scala b/tests/neg-macros/i5547.scala new file mode 100644 index 000000000000..36a36214063c --- /dev/null +++ b/tests/neg-macros/i5547.scala @@ -0,0 +1,9 @@ +import scala.quoted._ + +object scalatest { + inline def assert2(condition: => Boolean): Unit = + ${ assertImpl('condition, Expr("")) } // error + + def assertImpl(condition: Expr[Boolean], clue: Expr[Any])(using QuoteContext): Expr[Unit] = + '{} +} diff --git a/tests/pos-macros/i4023c/Macro_1.scala b/tests/pos-macros/i4023c/Macro_1.scala index c6caf6bac980..7998b9166beb 100644 --- a/tests/pos-macros/i4023c/Macro_1.scala +++ b/tests/pos-macros/i4023c/Macro_1.scala @@ -1,5 +1,5 @@ import scala.quoted._ object Macro { - inline def ff[T](x: T): T = ${ impl('x)(Type[T], summon[QuoteContext]) } + inline def ff[T](x: T): T = ${ impl('x) } def impl[T](x: Expr[T])(implicit t: Type[T], qctx: QuoteContext): Expr[T] = '{ $x: $t } } diff --git a/tests/pos-macros/i5547.scala b/tests/pos-macros/i5547.scala index b6b167021a81..eca00b42d96f 100644 --- a/tests/pos-macros/i5547.scala +++ b/tests/pos-macros/i5547.scala @@ -2,10 +2,7 @@ import scala.quoted._ object scalatest { inline def assert1(condition: => Boolean): Unit = - ${assertImpl('condition, '{""})} - - inline def assert2(condition: => Boolean): Unit = - ${ assertImpl('condition, Expr("")) } + ${assertImpl('condition, '{""})} def assertImpl(condition: Expr[Boolean], clue: Expr[Any])(using QuoteContext): Expr[Unit] = '{} diff --git a/tests/run-macros/i4492/quoted_1.scala b/tests/run-macros/i4492/quoted_1.scala deleted file mode 100644 index 8c4810cc3c43..000000000000 --- a/tests/run-macros/i4492/quoted_1.scala +++ /dev/null @@ -1,6 +0,0 @@ - -trait Index - -object Index { - inline def succ(prev: Index): Unit = ${ '{println("Ok")} } -} diff --git a/tests/run-macros/quote-matcher-symantics-2/quoted_1.scala b/tests/run-macros/quote-matcher-symantics-2/quoted_1.scala index d8bf10c3b3a8..0d8cd78287d4 100644 --- a/tests/run-macros/quote-matcher-symantics-2/quoted_1.scala +++ b/tests/run-macros/quote-matcher-symantics-2/quoted_1.scala @@ -4,11 +4,20 @@ import scala.quoted.unsafe._ object Macros { - inline def liftString(inline a: DSL): String = ${impl(StringNum, 'a)} + inline def liftString(inline a: DSL): String = ${implStringNum('a)} - inline def liftCompute(inline a: DSL): Int = ${impl(ComputeNum, 'a)} + private def implStringNum(a: Expr[DSL])(using qctx: QuoteContext): Expr[String] = + impl(StringNum, a) - inline def liftAST(inline a: DSL): ASTNum = ${impl(ASTNum, 'a)} + inline def liftCompute(inline a: DSL): Int = ${implComputeNum('a)} + + private def implComputeNum(a: Expr[DSL])(using qctx: QuoteContext): Expr[Int] = + impl(ComputeNum, a) + + inline def liftAST(inline a: DSL): ASTNum = ${implASTNum('a)} + + private def implASTNum(a: Expr[DSL])(using qctx: QuoteContext): Expr[ASTNum] = + impl(ASTNum, a) private def impl[T: Type](sym: Symantics[T], a: Expr[DSL])(using qctx: QuoteContext): Expr[T] = {