Skip to content

Update inline parameters #8553

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import scala.quoted._
object StringContextMacro {

/** Implementation of scala.StringContext.f used in Dotty */
inline def f(sc: => StringContext)(args: Any*): String =
inline def f(inline sc: StringContext)(args: Any*): String =
scala.compiletime.error("Cannot expand f interpolator while bootstrapping the compiler")

}
2 changes: 1 addition & 1 deletion tests/neg-macros/i6432/Macro_1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import scala.quoted.autolift.{given _}


object Macro {
inline def (sc: => StringContext).foo(args: String*): Unit = ${ impl('sc) }
inline def (inline sc: StringContext).foo(args: String*): Unit = ${ impl('sc) }

def impl(sc: Expr[StringContext])(using qctx: QuoteContext) : Expr[Unit] = {
import qctx.tasty._
Expand Down
2 changes: 1 addition & 1 deletion tests/neg-macros/i6432b/Macro_1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import scala.quoted.autolift.{given _}


object Macro {
inline def (sc: => StringContext).foo(args: String*): Unit = ${ impl('sc) }
inline def (inline sc: StringContext).foo(args: String*): Unit = ${ impl('sc) }

def impl(sc: Expr[StringContext])(using qctx: QuoteContext) : Expr[Unit] = {
import qctx.tasty._
Expand Down
2 changes: 1 addition & 1 deletion tests/neg/i7698.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ def showInterpolatorImpl(sc: Expr[StringContext], argsExpr: Expr[Seq[Any]])(usin
case '[ Int ] => // error
???

inline def (sc: => StringContext) show (args: Any*): String = ${ showInterpolatorImpl('sc, 'args) }
inline def (inline sc: StringContext) show (args: Any*): String = ${ showInterpolatorImpl('sc, 'args) }
2 changes: 1 addition & 1 deletion tests/run-macros/i5119/Macro_1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ object Macro {
class StringContextOps(sc: => StringContext) {
inline def ff(args: => Any*): String = ${ Macro.impl('sc, 'args) }
}
implicit inline def XmlQuote(sc: => StringContext): StringContextOps = new StringContextOps(sc)
implicit inline def XmlQuote(inline sc: StringContext): StringContextOps = new StringContextOps(sc)
def impl(sc: Expr[StringContext], args: Expr[Seq[Any]])(using qctx: QuoteContext) : Expr[String] = {
import qctx.tasty._
(sc.unseal.underlyingArgument.showExtractors + "\n" + args.unseal.underlyingArgument.showExtractors)
Expand Down
2 changes: 1 addition & 1 deletion tests/run-macros/i6253-b/quoted_1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import scala.quoted._

object Macros {

inline def (self: => StringContext) xyz(args: => String*): String = ${impl('self, 'args)}
inline def (inline self: StringContext) xyz(args: => String*): String = ${impl('self, 'args)}

private def impl(self: Expr[StringContext], args: Expr[Seq[String]])(using QuoteContext): Expr[String] = {
self match {
Expand Down
2 changes: 1 addition & 1 deletion tests/run-macros/i6253/quoted_1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import scala.quoted._

object Macros {

inline def (self: => StringContext) xyz(args: => String*): String = ${impl('self, 'args)}
inline def (inline self: StringContext) xyz(args: => String*): String = ${impl('self, 'args)}

private def impl(self: Expr[StringContext], args: Expr[Seq[String]])(using QuoteContext): Expr[String] = {
self match {
Expand Down
2 changes: 1 addition & 1 deletion tests/run-macros/quote-elide-prefix/quoted_1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import scala.quoted._
object Macro {

// By name StringContext is used to elide the prefix
inline def (sc: => StringContext) ff (args: => Any*): String = ${ Macro.impl('sc, 'args) }
inline def (inline sc: StringContext) ff (args: => Any*): String = ${ Macro.impl('sc, 'args) }

def impl(sc: Expr[StringContext], args: Expr[Seq[Any]])(using QuoteContext): Expr[String] = '{ $args.mkString }
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import scala.quoted._

object Macros {

inline def (self: => StringContext) xyz(inline args: String*): String = ${impl('self, 'args)}
inline def (inline self: StringContext) xyz(inline args: String*): String = ${impl('self, 'args)}

private def impl(self: Expr[StringContext], args: Expr[Seq[String]])(using QuoteContext): Expr[String] = {
(self, args) match {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import scala.quoted._

object Macros {

inline def (self: => StringContext) S(args: => String*): String = ${impl('self, 'args)}
inline def (inline self: StringContext) S(args: => String*): String = ${impl('self, 'args)}

private def impl(self: Expr[StringContext], args: Expr[Seq[String]])(using QuoteContext): Expr[String] = {
self match {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import scala.quoted._

object Macros {

inline def (self: => StringContext) xyz(args: => String*): String = ${impl('self, 'args)}
inline def (inline self: StringContext) xyz(args: => String*): String = ${impl('self, 'args)}

private def impl(self: Expr[StringContext], args: Expr[Seq[String]])(using QuoteContext): Expr[String] = {
self match {
Expand Down
2 changes: 1 addition & 1 deletion tests/run-macros/quote-matcher-symantics-1/quoted_1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import scala.quoted._

object Macros {

inline def lift[T](sym: Symantics[T])(a: => DSL): T = ${impl[T]('sym, 'a)}
inline def lift[T](sym: Symantics[T])(inline a: DSL): T = ${impl[T]('sym, 'a)}

private def impl[T: Type](sym: Expr[Symantics[T]], a: Expr[DSL])(using qctx: QuoteContext): Expr[T] = {

Expand Down
6 changes: 3 additions & 3 deletions tests/run-macros/quote-matcher-symantics-2/quoted_1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import scala.quoted.unsafe._

object Macros {

inline def liftString(a: => DSL): String = ${impl(StringNum, 'a)}
inline def liftString(inline a: DSL): String = ${impl(StringNum, 'a)}

inline def liftCompute(a: => DSL): Int = ${impl(ComputeNum, 'a)}
inline def liftCompute(inline a: DSL): Int = ${impl(ComputeNum, 'a)}

inline def liftAST(a: => DSL): ASTNum = ${impl(ASTNum, 'a)}
inline def liftAST(inline a: DSL): ASTNum = ${impl(ASTNum, 'a)}

private def impl[T: Type](sym: Symantics[T], a: Expr[DSL])(using qctx: QuoteContext): Expr[T] = {

Expand Down
2 changes: 1 addition & 1 deletion tests/run-macros/quote-matcher-symantics-3/quoted_1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import scala.quoted.unsafe._
object Macros {


inline def lift[R[_]](sym: Symantics { type Repr = R })(a: => Int): R[Int] = ${impl('sym, 'a)}
inline def lift[R[_]](sym: Symantics { type Repr = R })(inline a: Int): R[Int] = ${impl('sym, 'a)}


private def impl[R[_]: Type](sym: Expr[Symantics { type Repr[X] = R[X] }], expr: Expr[Int])(using QuoteContext): Expr[R[Int]] = {
Expand Down
2 changes: 1 addition & 1 deletion tests/run-macros/quote-matching-open/Macro_1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import scala.quoted._
import scala.quoted.unsafe._
object Macro {

inline def openTest(x: => Any): Any = ${ Macro.impl('x) }
inline def openTest(inline x: Any): Any = ${ Macro.impl('x) }

def impl(x: Expr[Any])(using QuoteContext): Expr[Any] = {
x match {
Expand Down
4 changes: 2 additions & 2 deletions tests/run-macros/quoted-matching-docs-2/Macro_1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import scala.quoted._

def sum(args: Int*): Int = args.sum

inline def showOptimize(arg: Int): String = ${ showOptimizeExpr('arg) }
inline def optimize(arg: Int): Int = ${ optimizeExpr('arg) }
inline def showOptimize(inline arg: Int): String = ${ showOptimizeExpr('arg) }
inline def optimize(inline arg: Int): Int = ${ optimizeExpr('arg) }

private def showOptimizeExpr(body: Expr[Int])(using QuoteContext): Expr[String] =
Expr(optimizeExpr(body).show)
Expand Down
2 changes: 1 addition & 1 deletion tests/run-macros/quoted-pattern-open-expr/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import scala.quoted._

inline def test(e: Int): String = ${testExpr('e)}
inline def test(inline e: Int): String = ${testExpr('e)}

private def testExpr(e: Expr[Int])(using QuoteContext): Expr[String] = {
e match {
Expand Down
2 changes: 1 addition & 1 deletion tests/run-macros/quoted-pattern-type/Macro_1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import scala.quoted._

object Lib {

inline def foo[T](arg: => T): T = ${ impl('arg) }
inline def foo[T](inline arg: T): T = ${ impl('arg) }

private def impl[T: Type](arg: Expr[T])(using QuoteContext): Expr[T] = {
arg match {
Expand Down
2 changes: 1 addition & 1 deletion tests/run-macros/refined-selectable-macro/Macro_1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ object Macro {

trait SelectableRecordCompanion[T] {
protected def fromUntypedTuple(elems: (String, Any)*): T
inline def fromTuple[T <: Tuple](s: T) <: Any = ${ fromTupleImpl('s, '{ (x: Array[(String, Any)]) => fromUntypedTuple(x: _*) } ) }
inline def fromTuple[T <: Tuple](inline s: T) <: Any = ${ fromTupleImpl('s, '{ (x: Array[(String, Any)]) => fromUntypedTuple(x: _*) } ) }
}

private def toTupleImpl(s: Expr[Selectable])(using qctx:QuoteContext) : Expr[Tuple] = {
Expand Down