From ace188346e49622f9ec17a32ff07e0d246c480e8 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Wed, 13 Feb 2019 11:48:37 +0100 Subject: [PATCH 01/26] Use `$` for splices in syntax and parsing Also, update the reference document. --- community-build/community-projects/scalatest | 2 +- .../src/dotty/tools/dotc/ast/Desugar.scala | 12 +- compiler/src/dotty/tools/dotc/ast/untpd.scala | 41 +- .../dotc/core/quoted/PickledQuotes.scala | 2 +- .../tools/dotc/parsing/CharArrayReader.scala | 2 + .../dotty/tools/dotc/parsing/Parsers.scala | 54 ++- .../dotty/tools/dotc/parsing/Scanners.scala | 66 +-- .../src/dotty/tools/dotc/parsing/Tokens.scala | 12 +- .../tools/dotc/printing/RefinedPrinter.scala | 10 +- .../dotty/tools/dotc/transform/Splicer.scala | 8 +- .../dotty/tools/dotc/transform/Staging.scala | 2 +- docs/docs/internals/syntax.md | 11 +- .../principled-meta-programming.md | 417 +++++++++--------- 13 files changed, 341 insertions(+), 298 deletions(-) diff --git a/community-build/community-projects/scalatest b/community-build/community-projects/scalatest index d4fbd597712c..f1147035fd11 160000 --- a/community-build/community-projects/scalatest +++ b/community-build/community-projects/scalatest @@ -1 +1 @@ -Subproject commit d4fbd597712cc74961d5200cb88ec447ea6aa3c6 +Subproject commit f1147035fd11830eaf658d323d8bf49531a95721 diff --git a/compiler/src/dotty/tools/dotc/ast/Desugar.scala b/compiler/src/dotty/tools/dotc/ast/Desugar.scala index 516028ec9f1f..55b8b58b54ae 100644 --- a/compiler/src/dotty/tools/dotc/ast/Desugar.scala +++ b/compiler/src/dotty/tools/dotc/ast/Desugar.scala @@ -1313,11 +1313,15 @@ object desugar { val desugared = tree match { case SymbolLit(str) => Literal(Constant(scala.Symbol(str))) - case Quote(expr) => - if (expr.isType) - TypeApply(ref(defn.QuotedType_applyR), List(expr)) + case Quote(t) => + if (t.isType) + TypeApply(ref(defn.QuotedType_applyR), List(t)) else - Apply(ref(defn.QuotedExpr_applyR), expr) + Apply(ref(defn.QuotedExpr_applyR), t) + case Splice(expr) => + Select(expr, nme.UNARY_PREFIX ++ nme.raw.TILDE) + case TypSplice(expr) => + Select(expr, tpnme.UNARY_PREFIX ++ nme.raw.TILDE) case InterpolatedString(id, segments) => val strs = segments map { case ts: Thicket => ts.trees.head diff --git a/compiler/src/dotty/tools/dotc/ast/untpd.scala b/compiler/src/dotty/tools/dotc/ast/untpd.scala index 00d0b9fbbcc9..b4e85704e88a 100644 --- a/compiler/src/dotty/tools/dotc/ast/untpd.scala +++ b/compiler/src/dotty/tools/dotc/ast/untpd.scala @@ -16,8 +16,8 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo { abstract class OpTree(implicit @constructorOnly src: SourceFile) extends Tree { def op: Ident - override def isTerm: Boolean = op.name.isTermName - override def isType: Boolean = op.name.isTypeName + override def isTerm: Boolean = op.isTerm + override def isType: Boolean = op.isType } /** A typed subtree of an untyped tree needs to be wrapped in a TypedSplice @@ -84,10 +84,7 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo { case class InfixOp(left: Tree, op: Ident, right: Tree)(implicit @constructorOnly src: SourceFile) extends OpTree case class PostfixOp(od: Tree, op: Ident)(implicit @constructorOnly src: SourceFile) extends OpTree - case class PrefixOp(op: Ident, od: Tree)(implicit @constructorOnly src: SourceFile) extends OpTree { - override def isType: Boolean = op.isType - override def isTerm: Boolean = op.isTerm - } + case class PrefixOp(op: Ident, od: Tree)(implicit @constructorOnly src: SourceFile) extends OpTree case class Parens(t: Tree)(implicit @constructorOnly src: SourceFile) extends ProxyTree { def forwardTo: Tree = t } @@ -96,7 +93,9 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo { override def isType: Boolean = !isTerm } case class Throw(expr: Tree)(implicit @constructorOnly src: SourceFile) extends TermTree - case class Quote(expr: Tree)(implicit @constructorOnly src: SourceFile) extends TermTree + case class Quote(t: Tree)(implicit @constructorOnly src: SourceFile) extends TermTree + case class Splice(expr: Tree)(implicit @constructorOnly src: SourceFile) extends TermTree + case class TypSplice(expr: Tree)(implicit @constructorOnly src: SourceFile) extends TypTree case class DoWhile(body: Tree, cond: Tree)(implicit @constructorOnly src: SourceFile) extends TermTree case class ForYield(enums: List[Tree], expr: Tree)(implicit @constructorOnly src: SourceFile) extends TermTree case class ForDo(enums: List[Tree], body: Tree)(implicit @constructorOnly src: SourceFile) extends TermTree @@ -493,9 +492,17 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo { case tree: Throw if expr eq tree.expr => tree case _ => finalize(tree, untpd.Throw(expr)(tree.source)) } - def Quote(tree: Tree)(expr: Tree)(implicit ctx: Context): TermTree = tree match { - case tree: Quote if expr eq tree.expr => tree - case _ => finalize(tree, untpd.Quote(expr)(tree.source)) + def Quote(tree: Tree)(t: Tree)(implicit ctx: Context): Tree = tree match { + case tree: Quote if t eq tree.t => tree + case _ => finalize(tree, untpd.Quote(t)(tree.source)) + } + def Splice(tree: Tree)(expr: Tree)(implicit ctx: Context): Tree = tree match { + case tree: Splice if expr eq tree.expr => tree + case _ => finalize(tree, untpd.Splice(expr)(tree.source)) + } + def TypSplice(tree: Tree)(expr: Tree)(implicit ctx: Context): Tree = tree match { + case tree: TypSplice if expr eq tree.expr => tree + case _ => finalize(tree, untpd.TypSplice(expr)(tree.source)) } def DoWhile(tree: Tree)(body: Tree, cond: Tree)(implicit ctx: Context): TermTree = tree match { case tree: DoWhile if (body eq tree.body) && (cond eq tree.cond) => tree @@ -557,8 +564,12 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo { cpy.Tuple(tree)(transform(trees)) case Throw(expr) => cpy.Throw(tree)(transform(expr)) - case Quote(expr) => - cpy.Quote(tree)(transform(expr)) + case Quote(t) => + cpy.Quote(tree)(transform(t)) + case Splice(expr) => + cpy.Splice(tree)(transform(expr)) + case TypSplice(expr) => + cpy.TypSplice(tree)(transform(expr)) case DoWhile(body, cond) => cpy.DoWhile(tree)(transform(body), transform(cond)) case ForYield(enums, expr) => @@ -606,7 +617,11 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo { this(x, trees) case Throw(expr) => this(x, expr) - case Quote(expr) => + case Quote(t) => + this(x, t) + case Splice(expr) => + this(x, expr) + case TypSplice(expr) => this(x, expr) case DoWhile(body, cond) => this(this(x, body), cond) diff --git a/compiler/src/dotty/tools/dotc/core/quoted/PickledQuotes.scala b/compiler/src/dotty/tools/dotc/core/quoted/PickledQuotes.scala index d226d3582735..3111ba3fadc4 100644 --- a/compiler/src/dotty/tools/dotc/core/quoted/PickledQuotes.scala +++ b/compiler/src/dotty/tools/dotc/core/quoted/PickledQuotes.scala @@ -26,7 +26,7 @@ object PickledQuotes { def pickleQuote(tree: Tree)(implicit ctx: Context): scala.runtime.quoted.Unpickler.Pickled = { if (ctx.reporter.hasErrors) Nil else { - assert(!tree.isInstanceOf[Hole]) // Should not be pickled as it represents `'(~x)` which should be optimized to `x` + assert(!tree.isInstanceOf[Hole]) // Should not be pickled as it represents `'{$x}` which should be optimized to `x` val pickled = pickle(tree) TastyString.pickle(pickled) } diff --git a/compiler/src/dotty/tools/dotc/parsing/CharArrayReader.scala b/compiler/src/dotty/tools/dotc/parsing/CharArrayReader.scala index 1d07b99ea07e..ca784d6de87f 100644 --- a/compiler/src/dotty/tools/dotc/parsing/CharArrayReader.scala +++ b/compiler/src/dotty/tools/dotc/parsing/CharArrayReader.scala @@ -122,6 +122,8 @@ abstract class CharArrayReader { self => /** A new reader that takes off at the current character position */ def lookaheadReader(): CharArrayLookaheadReader = new CharArrayLookaheadReader + def lookaheadChar(): Char = lookaheadReader().getc() + class CharArrayLookaheadReader extends CharArrayReader { val buf: Array[Char] = self.buf charOffset = self.charOffset diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index bdd00d714f9d..6278b6aa30c2 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -918,15 +918,33 @@ object Parsers { }) else t + /** The block in a quote or splice */ + def stagedBlock(isQuote: Boolean) = { + val saved = in.inQuote + in.inQuote = isQuote + inDefScopeBraces { + try block() finally in.inQuote = saved + } + } + + /** SimpleEpxr ::= ‘$’ (id | ‘{’ Block ‘}’) + * SimpleType ::= ‘$’ (id | ‘{’ Block ‘}’) + */ + def splice(isType: Boolean): Tree = + atSpan(in.skipToken()) { + val expr = if (isIdent) termIdent() else stagedBlock(isQuote = false) + if (isType) TypSplice(expr) else Splice(expr) + } + /** SimpleType ::= SimpleType TypeArgs * | SimpleType `#' id * | StableId - * | ['~'] StableId * | Path `.' type * | `(' ArgTypes `)' * | `_' TypeBounds * | Refinement * | Literal + * | ‘$’ (id | ‘{’ Block ‘}’) */ def simpleType(): Tree = simpleTypeRest { if (in.token == LPAREN) @@ -940,8 +958,8 @@ object Parsers { val start = in.skipToken() typeBounds().withSpan(Span(start, in.lastOffset, start)) } - else if (isIdent(nme.raw.TILDE) && in.lookaheadIn(BitSet(IDENTIFIER, BACKQUOTED_IDENT))) - atSpan(in.offset) { PrefixOp(typeIdent(), path(thisOK = true)) } + else if (in.token == SPLICE) + splice(isType = true) else path(thisOK = false, handleSingletonType) match { case r @ SingletonTypeTree(_) => r case r => convertToTypeId(r) @@ -1402,9 +1420,9 @@ object Parsers { /** SimpleExpr ::= ‘new’ (ConstrApp [TemplateBody] | TemplateBody) * | BlockExpr - * | ‘'{’ BlockExprContents ‘}’ - * | ‘'(’ ExprsInParens ‘)’ - * | ‘'[’ Type ‘]’ + * | ‘'’ (id | ‘{’ Block ‘}’) + * | ‘'’ ‘[’ Type ‘]’ + * | ‘$’ (id | ‘{’ Block ‘}’) * | SimpleExpr1 [`_'] * SimpleExpr1 ::= literal * | xmlLiteral @@ -1433,15 +1451,21 @@ object Parsers { case LBRACE => canApply = false blockExpr() - case QPAREN => - in.token = LPAREN - atSpan(in.offset)(Quote(simpleExpr())) - case QBRACE => - in.token = LBRACE - atSpan(in.offset)(Quote(simpleExpr())) - case QBRACKET => - in.token = LBRACKET - atSpan(in.offset)(Quote(inBrackets(typ()))) + case QUOTE => + atSpan(in.skipToken()) { + Quote { + if (in.token == LBRACKET) { + val saved = in.inQuote + in.inQuote = true + inBrackets { + try typ() finally in.inQuote = saved + } + } + else stagedBlock(isQuote = true) + } + } + case SPLICE => + splice(isType = false) case NEW => canApply = false newExpr() diff --git a/compiler/src/dotty/tools/dotc/parsing/Scanners.scala b/compiler/src/dotty/tools/dotc/parsing/Scanners.scala index 2ea56b46cff3..f95d27857c52 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Scanners.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Scanners.scala @@ -184,6 +184,8 @@ object Scanners { /** Return a list of all the comment positions */ def commentSpans: List[Span] = commentPosBuf.toList + var inQuote = false + private[this] def addComment(comment: Comment): Unit = { val lookahead = lookaheadReader() def nextPos: Int = (lookahead.getc(): @switch) match { @@ -415,7 +417,7 @@ object Scanners { 'K' | 'L' | 'M' | 'N' | 'O' | 'P' | 'Q' | 'R' | 'S' | 'T' | 'U' | 'V' | 'W' | 'X' | 'Y' | - 'Z' | '$' | '_' | + 'Z' | '_' | 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | @@ -424,9 +426,15 @@ object Scanners { 'z' => putChar(ch) nextChar() - getIdentRest() - if (ch == '"' && token == IDENTIFIER) - token = INTERPOLATIONID + finishIdent() + case '$' => + putChar(ch) + nextChar() + if (inQuote) { + token = SPLICE + litBuf.clear() + } + else finishIdent() case '<' => // is XMLSTART? def fetchLT() = { val last = if (charOffset >= 2) buf(charOffset - 2) else ' ' @@ -523,19 +531,13 @@ object Scanners { charLitOr { getIdentRest(); SYMBOLLIT } else if (isOperatorPart(ch) && (ch != '\\')) charLitOr { getOperatorRest(); SYMBOLLIT } - else if (ch == '(' || ch == '{' || ch == '[') { - val tok = quote(ch) - charLitOr(tok) - } - else { - getLitChar() - if (ch == '\'') { - nextChar() - token = CHARLIT - setStrVal() - } else { - error("unclosed character literal") - } + else ch match { + case '{' | '[' | ' ' | '\t' if lookaheadChar() != '\'' => + token = QUOTE + case _ => + getLitChar() + if (ch == '\'') finishCharLit() + else error("unclosed character literal") } } fetchSingleQuote() @@ -716,6 +718,11 @@ object Scanners { } } + def finishIdent(): Unit = { + getIdentRest() + if (ch == '"' && token == IDENTIFIER) token = INTERPOLATIONID + } + private def getOperatorRest(): Unit = (ch: @switch) match { case '~' | '!' | '@' | '#' | '%' | '^' | '*' | '+' | '-' | '<' | @@ -965,9 +972,8 @@ object Scanners { } token = INTLIT if (base == 10 && ch == '.') { - val lookahead = lookaheadReader() - lookahead.nextChar() - if ('0' <= lookahead.ch && lookahead.ch <= '9') { + val lch = lookaheadChar() + if ('0' <= lch && lch <= '9') { putChar('.'); nextChar(); getFraction() } } else (ch: @switch) match { @@ -981,30 +987,26 @@ object Scanners { setStrVal() } + private def finishCharLit(): Unit = { + nextChar() + token = CHARLIT + setStrVal() + } + /** Parse character literal if current character is followed by \', * or follow with given op and return a symbol literal token */ def charLitOr(op: => Token): Unit = { putChar(ch) nextChar() - if (ch == '\'') { - nextChar() - token = CHARLIT - setStrVal() - } else { + if (ch == '\'') finishCharLit() + else { token = op strVal = if (name != null) name.toString else null litBuf.clear() } } - /** The opening quote bracket token corresponding to `c` */ - def quote(c: Char): Token = c match { - case '(' => QPAREN - case '{' => QBRACE - case '[' => QBRACKET - } - override def toString: String = showTokenDetailed(token) + { if ((identifierTokens contains token) || (literalTokens contains token)) " " + name diff --git a/compiler/src/dotty/tools/dotc/parsing/Tokens.scala b/compiler/src/dotty/tools/dotc/parsing/Tokens.scala index 20dcf1b7e152..22b28fe8505b 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Tokens.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Tokens.scala @@ -193,16 +193,14 @@ object Tokens extends TokensCommon { final val SUPERTYPE = 81; enter(SUPERTYPE, ">:") final val HASH = 82; enter(HASH, "#") final val VIEWBOUND = 84; enter(VIEWBOUND, "<%") // TODO: deprecate - final val QPAREN = 85; enter(QPAREN, "'(") - final val QBRACE = 86; enter(QBRACE, "'{") - final val QBRACKET = 87; enter(QBRACKET, "'[") + final val SPLICE = 85; enter(SPLICE, "$") + final val QUOTE = 86; enter(QUOTE, "'") /** XML mode */ final val XMLSTART = 96; enter(XMLSTART, "$XMLSTART$<") // TODO: deprecate final val alphaKeywords: TokenSet = tokenRange(IF, GIVEN) - final val symbolicKeywords: TokenSet = tokenRange(USCORE, VIEWBOUND) - final val symbolicTokens: TokenSet = tokenRange(COMMA, VIEWBOUND) + final val symbolicKeywords: TokenSet = tokenRange(USCORE, SPLICE) final val keywords: TokenSet = alphaKeywords | symbolicKeywords final val allTokens: TokenSet = tokenRange(minToken, maxToken) @@ -214,10 +212,10 @@ object Tokens extends TokensCommon { USCORE, NULL, THIS, SUPER, TRUE, FALSE, RETURN, XMLSTART) final val canStartExpressionTokens: TokenSet = atomicExprTokens | BitSet( - LBRACE, LPAREN, QBRACE, QPAREN, QBRACKET, IF, DO, WHILE, FOR, NEW, TRY, THROW) + LBRACE, LPAREN, QUOTE, SPLICE, IF, DO, WHILE, FOR, NEW, TRY, THROW) final val canStartTypeTokens: TokenSet = literalTokens | identifierTokens | BitSet( - THIS, SUPER, USCORE, LPAREN, AT) + THIS, SUPER, USCORE, LPAREN, AT, SPLICE) final val canStartBindingTokens: TokenSet = identifierTokens | BitSet(USCORE, LPAREN) diff --git a/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala b/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala index 082b737c8d81..407635418b3d 100644 --- a/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala +++ b/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala @@ -302,6 +302,11 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { case _ => toTextGlobal(arg) } + def dropBlock(tree: Tree): Tree = tree match { + case Block(Nil, expr) => expr + case _ => tree + } + tree match { case id: Trees.BackquotedIdent[_] if !homogenizedView => "`" ~ toText(id.name) ~ "`" @@ -572,7 +577,10 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { keywordStr("try ") ~ toText(expr) ~ " " ~ keywordStr("catch") ~ " {" ~ toText(handler) ~ "}" ~ optText(finalizer)(keywordStr(" finally ") ~ _) } case Quote(tree) => - if (tree.isType) keywordStr("'[") ~ toTextGlobal(tree) ~ keywordStr("]") else keywordStr("'{") ~ toTextGlobal(tree) ~ keywordStr("}") + if (tree.isType) keywordStr("'[") ~ toTextGlobal(dropBlock(tree)) ~ keywordStr("]") + else keywordStr("'{") ~ toTextGlobal(dropBlock(tree)) ~ keywordStr("}") + case Splice(tree) => + keywordStr("${") ~ toTextGlobal(dropBlock(tree)) ~ keywordStr("}") case Thicket(trees) => "Thicket {" ~~ toTextGlobal(trees, "\n") ~~ "}" case _ => diff --git a/compiler/src/dotty/tools/dotc/transform/Splicer.scala b/compiler/src/dotty/tools/dotc/transform/Splicer.scala index 638abf19e613..212eef754d1d 100644 --- a/compiler/src/dotty/tools/dotc/transform/Splicer.scala +++ b/compiler/src/dotty/tools/dotc/transform/Splicer.scala @@ -29,8 +29,8 @@ import scala.reflect.ClassTag object Splicer { import tpd._ - /** Splice the Tree for a Quoted expression. `~'(xyz)` becomes `xyz` - * and for `~xyz` the tree of `xyz` is interpreted for which the + /** Splice the Tree for a Quoted expression. `${'{xyz}}` becomes `xyz` + * and for `$xyz` the tree of `xyz` is interpreted for which the * resulting expression is returned as a `Tree` * * See: `Staging` @@ -59,8 +59,8 @@ object Splicer { } } - /** Check that the Tree can be spliced. `~'(xyz)` becomes `xyz` - * and for `~xyz` the tree of `xyz` is interpreted for which the + /** Check that the Tree can be spliced. `${'{xyz}}` becomes `xyz` + * and for `$xyz` the tree of `xyz` is interpreted for which the * resulting expression is returned as a `Tree` * * See: `Staging` diff --git a/compiler/src/dotty/tools/dotc/transform/Staging.scala b/compiler/src/dotty/tools/dotc/transform/Staging.scala index 103c9ad72fe8..637a0b698961 100644 --- a/compiler/src/dotty/tools/dotc/transform/Staging.scala +++ b/compiler/src/dotty/tools/dotc/transform/Staging.scala @@ -30,7 +30,7 @@ import scala.annotation.constructorOnly * * Type healing consists in transforming a phase inconsistent type `T` into `implicitly[Type[T]].unary_~`. * - * For macro definitions we assume that we have a single ~ directly as the RHS. + * For macro definitions we assume that we have a single ${...} directly as the RHS. * The Splicer is used to check that the RHS will be interpretable (with the `Splicer`) once inlined. */ class Staging extends MacroTransform { diff --git a/docs/docs/internals/syntax.md b/docs/docs/internals/syntax.md index bbdbb5bd5842..4a9c2f04559e 100644 --- a/docs/docs/internals/syntax.md +++ b/docs/docs/internals/syntax.md @@ -153,12 +153,12 @@ AnnotType ::= SimpleType {Annotation} SimpleType ::= SimpleType TypeArgs AppliedTypeTree(t, args) | SimpleType ‘#’ id Select(t, name) | StableId - | [‘-’ | ‘+’ | ‘~’ | ‘!’] StableId PrefixOp(expr, op) | Path ‘.’ ‘type’ SingletonTypeTree(p) | ‘(’ ArgTypes ‘)’ Tuple(ts) | ‘_’ SubtypeBounds | Refinement RefinedTypeTree(EmptyTree, refinement) | SimpleLiteral SingletonTypeTree(l) + | ‘$’ (id | ‘{’ Block ‘}’) ArgTypes ::= Type {‘,’ Type} | NamedTypeArg {‘,’ NamedTypeArg} FunArgType ::= Type @@ -208,9 +208,9 @@ InfixExpr ::= PrefixExpr PrefixExpr ::= [‘-’ | ‘+’ | ‘~’ | ‘!’] SimpleExpr PrefixOp(expr, op) SimpleExpr ::= ‘new’ (ConstrApp [TemplateBody] | TemplateBody) New(constr | templ) | BlockExpr - | ''{’ BlockExprContents ‘}’ - | ‘'(’ ExprsInParens ‘)’ - | ‘'[’ Type ‘]’ + | ‘'’ (id | ‘{’ Block ‘}’) + | ‘'’ ‘[’ Type ‘]’ + | ‘$’ (id | ‘{’ Block ‘}’) | SimpleExpr1 [‘_’] PostfixOp(expr, _) SimpleExpr1 ::= Literal | Path @@ -227,8 +227,7 @@ ParArgumentExprs ::= ‘(’ ExprsInParens ‘)’ | ‘(’ [ExprsInParens] PostfixExpr ‘:’ ‘_’ ‘*’ ‘)’ exprs :+ Typed(expr, Ident(wildcardStar)) ArgumentExprs ::= ParArgumentExprs | [nl] BlockExpr -BlockExpr ::= ‘{’ BlockExprContents ‘}’ -BlockExprContents ::= CaseClauses | Block +BlockExpr ::= ‘{’ CaseClauses | Block ‘}’ Block ::= {BlockStat semi} [BlockResult] Block(stats, expr?) BlockStat ::= Import | {Annotation} [‘implicit’ | ‘lazy’] Def diff --git a/docs/docs/reference/other-new-features/principled-meta-programming.md b/docs/docs/reference/other-new-features/principled-meta-programming.md index f382c428fc5a..7dd5c39f9049 100644 --- a/docs/docs/reference/other-new-features/principled-meta-programming.md +++ b/docs/docs/reference/other-new-features/principled-meta-programming.md @@ -16,33 +16,33 @@ splices in exactly the same way. Principled meta programming is built on two well-known fundamental operations: quotation and splicing. Quotation is expressed as -`'(...)` or `'{...}` for expressions (both forms are equivalent) and -as `'[...]` for types. Splicing is expressed as a prefix `~` operator. +`'{...}` for expressions (both forms are equivalent) and +as `'[...]` for types. Splicing is expressed as `${ ... }`. For example, the code below presents an inline function `assert` which calls at compile-time a method `assertImpl` with a boolean expression tree as argument. `assertImpl` evaluates the expression and prints it again in an error message if it evaluates to `false`. - +```scala import scala.quoted._ inline def assert(expr: => Boolean): Unit = - ~ assertImpl('(expr)) + ${ assertImpl('{ expr }) } def assertImpl(expr: Expr[Boolean]) = '{ - if !(~expr) then - throw new AssertionError(s"failed assertion: ${~showExpr(expr)}") + if !(${ expr }) then + throw new AssertionError(s"failed assertion: ${${ showExpr(expr) }}") } def showExpr(expr: Expr[Boolean]): Expr[String] = - '("") // Better implementation later in this document - -If `e` is an expression, then `'(e)` or `'{e}` represent the typed + '{ "" } // Better implementation later in this document +``` +If `e` is an expression, then `'{e}` represent the typed abstract syntax tree representing `e`. If `T` is a type, then `'[T]` represents the type structure representing `T`. The precise definitions of "typed abstract syntax tree" or "type-structure" do not matter for now, the terms are used only to give some -intuition. Conversely, `~ e` evaluates the expression `e`, which must +intuition. Conversely, `${e}` evaluates the expression `e`, which must yield a typed abstract syntax tree or type structure, and embeds the result as an expression (respectively, type) in the enclosing program. @@ -50,13 +50,18 @@ Quotations can have spliced parts in them; in this case the embedded splices are evaluated and embedded as part of the formation of the quotation. +Quotes and splices can also be applied directly to identifiers. An identifier +`$x` starting with a `$` that appears inside a quoted expression or type is treated as a +splice `${x}`. Analogously, an identifier 'x will be treated in the future as a quote `'{x}`. +See the Syntax section below for details. + Quotes and splices are duals of each other. For arbitrary expressions `e` and types `T` we have: - ~'(e) = e - '(~e) = e - ~'[T] = T - '[~T] = T + ${'{e}} = e + '{${e}} = e + ${'[T]} = T + '[${T}] = T ### Types for Quotations @@ -72,16 +77,12 @@ takes expressions of type `Expr[T]` to expressions of type `T` and it takes expressions of type `Type[T]` to types `T`. The two types can be defined in package `scala.quoted` as follows: - +```scala package scala.quoted - sealed abstract class Expr[T] { - def unary_~: T // splice operation - } - sealed abstract class Type[T] { - type unary_~ = T // splice type - } - + sealed abstract class Expr[T] + sealed abstract class Type[T] +``` Both `Expr` and `Type` are abstract and sealed, so all constructors for these types are provided by the system. One way to construct values of these types is by quoting, the other is by type-specific lifting @@ -106,7 +107,7 @@ represented only by referring to the original variable `x`. Hence, the result of the program will need to persist the program state itself as one of its parts. We don’t want to do this, hence this situation should be made illegal. Dually, suppose a top-level part of a program -is a spliced text `~{ ... x ... }` that refers to a free variable `x` +is a spliced text `${ ... x ... }` that refers to a free variable `x` in `P`. This would mean that we refer during _construction_ of `P` to a value that is available only during _execution_ of `P`. This is of course impossible and therefore needs to be ruled out. Now, the @@ -130,33 +131,31 @@ PCP. This is explained further in a later section. ### From `Expr`s to Functions and Back -The `Expr` companion object contains an `AsFunctionN` (for 0 <= N < 23) decorator that turns a tree +The `Expr` companion object contains an implicit `AsFunctionN` (for 0 <= N < 23) conversion that turns a tree describing a function into a function mapping trees to trees. - +```scala object Expr { ... - implicit class AsFunction1[T, U](f: Expr[T => U]) extends AnyVal { - def apply(x: Expr[T]): Expr[U] = ??? - } + implied AsFunction1[T, U] for Conversion[Expr[T => U], Expr[T] => Expr[U]] ... } - +``` This decorator gives `Expr` the `apply` operation of an applicative functor, where `Expr`s over function types can be applied to `Expr` arguments. The definition of `AsFunction1(f).apply(x)` is assumed to be functionally the same as -`'((~f)(~x))`, however it should optimize this call by returning the +`'{($f)($x)}`, however it should optimize this call by returning the result of beta-reducing `f(x)` if `f` is a known lambda expression. The `AsFunction1` decorator distributes applications of `Expr` over function arrows: - +```scala AsFunction1(_).apply: Expr[S => T] => (Expr[S] => Expr[T]) - +``` Its dual, let’s call it `reflect`, can be defined as follows: - +```scala def reflect[T, U](f: Expr[T] => Expr[U]): Expr[T => U] = '{ - (x: T) => ~f('(x)) + (x: T) => ${ f('x) } } - +``` Note how the fundamental phase consistency principle works in two different directions here for `f` and `x`. The reference to `f` is legal because it is quoted, then spliced, whereas the reference to `x` @@ -170,28 +169,28 @@ definition of `reflect` above is not phase correct since there is a quote but no splice between the parameter binding of `T` and its usage. But the code can be made phase correct by adding a binding of a `Type[T]` tag: - - def reflect[T, U](f: Expr[T] => Expr[U])(implicit t: Type[T]): Expr[T => U] = - '{ (x: ~t) => ~f('(x)) } - +```scala + def reflect[T, U](f: Expr[T] => Expr[U]) given (t: Type[T]): Expr[T => U] = + '{ (x: $t) => ${ f('x) } } +``` In this version of `reflect`, the type of `x` is now the result of splicing the `Type` value `t`. This operation _is_ splice correct -- there is one quote and one splice between the use of `t` and its definition. To avoid clutter, the Scala implementation tries to convert any phase-incorrect -reference to a type `T` to a type-splice, by rewriting `T` to `~implicitly[Type[T]]`. +reference to a type `T` to a type-splice, by rewriting `T` to `${ the[Type[T]] }`. For instance, the user-level definition of `reflect`: - +```scala def reflect[T: Type, U](f: Expr[T] => Expr[U]): Expr[T => U] = - '{ (x: T) => ~f('(x)) } - + '{ (x: T) => ${ f('x) } } +``` would be rewritten to - +```scala def reflect[T: Type, U](f: Expr[T] => Expr[U]): Expr[T => U] = - '{ (x: ~implicitly[Type[T]]) => ~f('(x)) } - -The `implicitly` query succeeds because there is an implicit value of -type `Type[T]` available (namely the evidence parameter corresponding + '{ (x: ${ the[Type[T]] }) => ${ f('x) } } +``` +The `the` query succeeds because there is an implied value of +type `Type[T]` available (namely the given parameter corresponding to the context bound `: Type`), and the reference to that value is phase-correct. If that was not the case, the phase inconsistency for `T` would be reported as an error. @@ -209,16 +208,16 @@ just reifying the containing type together with the member name. But what to do for references to type parameters or local type definitions that are not defined in the current stage? Here, we cannot construct the `Type[T]` tree directly, so we need to get it from a recursive -implicit search. For instance, to implemenent - - implicitly[Type[List[T]]] - +implicit search. For instance, to implement +```scala + the[Type[List[T]]] +``` where `T` is not defined in the current stage, we construct the type constructor -of `List` applied to the splice of the result of searching for an implicit `Type[T]`: - - '[List[~implicitly[Type[T]]]] - -This is in exactly the algorithm that Scala 2 uses to search for type tags. +of `List` applied to the splice of the result of searching for an implied instance for `Type[T]`: +```scala + '[ List[ ${ the[Type[T]] } ] ] +``` +This is exactly the algorithm that Scala 2 uses to search for type tags. In fact Scala 2's type tag feature can be understood as a more ad-hoc version of `quoted.Type`. As was the case for type tags, the implicit search for a `quoted.Type` is handled by the compiler, using the algorithm sketched above. @@ -226,63 +225,63 @@ is handled by the compiler, using the algorithm sketched above. ### Example Expansion Assume an `Array` class with an inline `map` method that forwards to a macro implementation. - +```scala class Array[T] { - inline def map[U](f: T => U): Array[U] = ~ Macros.mapImpl[T, U]('[U], '(this), '(f)) + inline def map[U](f: T => U): Array[U] = ${ Macros.mapImpl[T, U]('[U], 'this, 'f) } } - +``` Here’s the definition of the `mapImpl` macro, which takes quoted types and expressions to a quoted expression: - +```scala object Macros { def mapImpl[T, U](u: Type[U], arr: Expr[Array[T]], op: Expr[T => U]): Expr[Array[U]] = '{ var i = 0 - val xs = ~arr + val xs = $arr var len = xs.length - val ys = new Array[~u](len) + val ys = new Array[$u](len) while (i < len) { - ys(i) = ~op('(xs(i))) + ys(i) = ${ op('{ xs(i) }) } i += 1 } ys } } - +``` Here’s an application of `map` and how it rewrites to optimized code: - +```scala genSeq[Int]().map(x => x + 1) - +``` ==> (inline) - - val $this: Seq[Int] = genSeq[Int]() +```scala + val _this: Seq[Int] = genSeq[Int]() val f: Int => Int = x => x + 1 - ~ _root_.Macros.mapImpl[Int, Int]('[Int], '($this), '(f)) - + ${ _root_.Macros.mapImpl[Int, Int]('[Int], '_this, 'f) } +``` ==> (splice) - - val $this: Seq[Int] = genSeq[Int]() +```scala + val _this: Seq[Int] = genSeq[Int]() val f: Int => Int = x => x + 1 { var i = 0 - val xs = ~'($this) + val xs = ${ '_this } var len = xs.length - val ys = new Array[~'[Int]](len) + val ys = new Array[${ '[Int] }](len) while (i < len) { - ys(i) = ~('(f)('(xs(i)))) + ys(i) = ${ ('f)('{ xs(i) }) } i += 1 } ys } - +``` ==> (expand and splice inside quotes) - - val $this: Seq[Int] = genSeq[Int]() +```scala + val _this: Seq[Int] = genSeq[Int]() val f: Int => Int = x => x + 1 { var i = 0 - val xs = $this + val xs = _this var len = xs.length val ys = new Array[Int](len) while (i < len) { @@ -291,14 +290,14 @@ Here’s an application of `map` and how it rewrites to optimized code: } ys } - +``` ==> (elim dead code) - - val $this: Seq[Int] = genSeq[Int]() +```scala + val _this: Seq[Int] = genSeq[Int]() { var i = 0 - val xs = $this + val xs = _this var len = xs.length val ys = new Array[Int](len) while (i < len) { @@ -307,7 +306,7 @@ Here’s an application of `map` and how it rewrites to optimized code: } ys } - +``` ### Relationship with Inline and Macros Seen by itself, principled meta-programming looks more like a @@ -317,31 +316,30 @@ compile-time system. The idea is that macro elaboration can be understood as a combination of a macro library and a quoted program. For instance, here’s the `assert` macro again together with a program that calls `assert`. - +```scala object Macros { inline def assert(expr: => Boolean): Unit = - ~ assertImpl('(expr)) + ${ assertImpl('expr) } def assertImpl(expr: Expr[Boolean]) = - '{ if !(~expr) then throw new AssertionError(s"failed assertion: ${~expr}") } + '{ if !($expr) then throw new AssertionError(s"failed assertion: ${$expr}") } } - // has to be in a different compilation unit that depends on Macros object App { val program = { val x = 1 Macros.assert(x != 0) } } - +``` Inlining the `assert` function would give the following program: - +```scala val program = { val x = 1 - ~Macros.assertImpl('(x != 0)) + ${ Macros.assertImpl('{ x != 0) } } } - +``` The example is only phase correct because Macros is a global value and as such not subject to phase consistency checking. Conceptually that’s a bit unsatisfactory. If the PCP is so fundamental, it should be @@ -357,12 +355,12 @@ macros would be to have the user program be in a phase after the macro definitions, reflecting the fact that macros have to be defined and compiled before they are used. Hence, conceptually the program part should be treated by the compiler as if it was quoted: - +```scala val program = '{ val x = 1 - ~Macros.assertImpl('(x != 0)) + ${ Macros.assertImpl('{ x != 0 }) } } - +``` If `program` is treated as a quoted expression, the call to `Macro.assertImpl` becomes phase correct even if macro library and program are conceptualized as local definitions. @@ -382,20 +380,20 @@ either a constant or is a parameter that will be a constant when instantiated. T aspect is also important for macro expansion. To illustrate this, consider an implementation of the `power` function that makes use of a statically known exponent: - - inline def power(inline n: Int, x: Double) = ~powerCode(n, '(x)) +```scala + inline def power(inline n: Int, x: Double) = ${ powerCode(n, 'x) } private def powerCode(n: Int, x: Expr[Double]): Expr[Double] = - if (n == 0) '(1.0) + if (n == 0) '{ 1.0 } else if (n == 1) x - else if (n % 2 == 0) '{ val y = ~x * ~x; ~powerCode(n / 2, '(y)) } - else '{ ~x * ~powerCode(n - 1, x) } - -The reference to `n` as an argument in `~powerCode(n, '(x))` is not + else if (n % 2 == 0) '{ val y = $x * $x; ${ powerCode(n / 2, 'y) } } + else '{ $x * ${ powerCode(n - 1, x) } } +``` +The reference to `n` as an argument in `${ powerCode(n, 'x) }` is not phase-consistent, since `n` appears in a splice without an enclosing quote. Normally that would be a problem because it means that we need the _value_ of `n` at compile time, which is not available for general -parameters. But since `n` is a inline parameter of a macro, we know +parameters. But since `n` is an inline parameter of a macro, we know that at the macro’s expansion point `n` will be instantiated to a constant, so the value of `n` will in fact be known at this point. To reflect this, we loosen the phase consistency requirements @@ -450,24 +448,24 @@ we currently impose the following restrictions on the use of splices. The framework as discussed so far allows code to be staged, i.e. be prepared to be executed at a later stage. To run that code, there is another method -in class `Expr` called `run`. Note that `~` and `run` both map from `Expr[T]` -to `T` but only `~` is subject to the PCP, whereas `run` is just a normal method. - +in class `Expr` called `run`. Note that `$` and `run` both map from `Expr[T]` +to `T` but only `$` is subject to the PCP, whereas `run` is just a normal method. +```scala sealed abstract class Expr[T] { - def unary_~: T - def run(implicit runner: Runner[T]): T // run staged code - def show(implicit runner: Runner[T]): String // show staged code + def run given (toolbox: Toolbox): T // run staged code + def show given (toolbox: Toolbox): String // show staged code } +``` ### Limitations to Splicing Quotes and splices are duals as far as the PCP is concerned. But there is an additional restriction that needs to be imposed on splices to guarantee soundness: code in splices must be free of side effects. The restriction prevents code like this: - +```scala var x: Expr[T] - '{ (y: T) => ~{ x = '(y); 1 } } - + '{ (y: T) => ${ x = 'y; 1 } } +``` This code, if it was accepted, would "extrude" a reference to a quoted variable `y` from its scope. This means we an subsequently access a variable outside the scope where it is defined, which is likely problematic. The code is clearly phase consistent, so we cannot use PCP to @@ -477,14 +475,14 @@ pure by convention, and allow for undefined compiler behavior if they are not. T to the status of pattern guards in Scala, which are also required, but not verified, to be pure. There is also a problem with `run` in splices. Consider the following expression: - - '{ (x: Int) => ~{ {'(x)}.run; 1 } } - +```scala + '{ (x: Int) => ${ ('x).run; 1 } } +``` This is again phase correct, but will lead us into trouble. Indeed, evaluating the splice will reduce the -expression `{'(x)}.run` to `x`. But then the result - - '{ (x: Int) => ~{ x; 1 } } - +expression `('x).run` to `x`. But then the result +```scala + '{ (x: Int) => ${ x; 1 } } +``` is no longer phase correct. To prevent this soundness hole it seems easiest to classify `run` as a side-effecting operation. It would thus be prevented from appearing in splices. In a base language with side-effects we'd have to do this anyway: Since `run` runs arbitrary code it can always produce a side effect if the code it runs produces one. @@ -493,7 +491,7 @@ do this anyway: Since `run` runs arbitrary code it can always produce a side eff Consider the following implementation of a staged interpreter that implements a compiler through staging. - +```scala import scala.quoted._ enum Exp { @@ -502,51 +500,53 @@ a compiler through staging. case Var(x: String) case Let(x: String, e: Exp, in: Exp) } - +``` The interpreted language consists of numbers `Num`, addition `Plus`, and variables `Var` which are bound by `Let`. Here are two sample expressions in the language: - +```scala val exp = Plus(Plus(Num(2), Var("x")), Num(4)) val letExp = Let("x", Num(3), exp) - +``` Here’s a compiler that maps an expression given in the interpreted language to quoted Scala code of type `Expr[Int]`. The compiler takes an environment that maps variable names to Scala `Expr`s. +```scala + import implied scala.quoted._ def compile(e: Exp, env: Map[String, Expr[Int]]): Expr[Int] = e match { case Num(n) => n.toExpr case Plus(e1, e2) => - '(~compile(e1, env) + ~compile(e2, env)) + '{ ${ compile(e1, env) } + ${ compile(e2, env) } } case Var(x) => env(x) case Let(x, e, body) => - '{ val y = ~compile(e, env); ~compile(body, env + (x -> '(y))) } + '{ val y = ${ compile(e, env) }; ${ compile(body, env + (x -> 'y)) } } } - +``` Running `compile(letExp, Map())` would yield the following Scala code: - +```scala '{ val y = 3; (2 + y) + 4 } - +``` The body of the first clause, `case Num(n) => n.toExpr`, looks suspicious. `n` -is declared as an `Int`, yet it is conveted to an `Expr[Int]` with `toExpr`. +is declared as an `Int`, yet it is converted to an `Expr[Int]` with `toExpr`. Shouldn’t `n` be quoted? In fact this would not work since replacing `n` by `'n` in the clause would not be phase correct. -What happens instead "under the hood" is an extension method `toExpr` is added: `n.toExpr` -is expanded to `new scala.quoted.LiftExprOps(n).toExpr`. The `toExpr` extension -is defined in the companion object of class `Liftable` as follows: +The `toExpr` extension method is defined in package `quoted`: +```scala + package quoted - package object quoted { - implicit class LiftExprOps[T](val x: T) extends AnyVal { - def toExpr(implicit ev: Liftable[T]): Expr[T] = ev.toExpr(x) - } + implied LiftingOps { + def (x: T) toExpr[T] given (ev: Liftable[T]): Expr[T] = ev.toExpr(x) } - +``` The extension says that values of types implementing the `Liftable` type class can be -converted ("lifted") to `Expr` values using `toExpr` when `scala.quoted._` is imported. -Dotty comes with instance definitions of `Liftable` for +converted ("lifted") to `Expr` values using `toExpr`, provided an implied import +of `scala.quoted._` is in scope. + +Dotty comes with implied instance definitions of `Liftable` for several types including `Boolean`, `String`, and all primitive number types. For example, `Int` values can be converted to `Expr[Int]` values by wrapping the value in a `Literal` tree node. This makes use @@ -555,81 +555,71 @@ efficiency. But the `Liftable` instances are nevertheless not "magic" in the sense that they could all be defined in a user program without knowing anything about the representation of `Expr` trees. For instance, here is a possible instance of `Liftable[Boolean]`: - - implicit def BooleanIsLiftable: Liftable[Boolean] = new { - implicit def toExpr(b: Boolean) = if (b) '(true) else '(false) +```scala + implied for Liftable[Boolean] { + def toExpr(b: Boolean) = if (b) '{ true } else '{ false } } - +``` Once we can lift bits, we can work our way up. For instance, here is a possible implementation of `Liftable[Int]` that does not use the underlying tree machinery: - - implicit def IntIsLiftable: Liftable[Int] = new { +```scala + implied for Liftable[Int] { def toExpr(n: Int): Expr[Int] = n match { - case Int.MinValue => '(Int.MinValue) - case _ if n < 0 => '(-(~toExpr(n))) - case 0 => '(0) - case _ if n % 2 == 0 => '(~toExpr(n / 2) * 2) - case _ => '(~toExpr(n / 2) * 2 + 1) + case Int.MinValue => '{ Int.MinValue } + case _ if n < 0 => '{ - ${ toExpr(n) } } + case 0 => '{ 0 } + case _ if n % 2 == 0 => '{ ${ toExpr(n / 2) } * 2 } + case _ => '{ ${ toExpr(n / 2) } * 2 + 1 } } } - +``` Since `Liftable` is a type class, its instances can be conditional. For example, a `List` is liftable if its element type is: - - implicit def ListIsLiftable[T: Liftable]: Liftable[List[T]] = new { +```scala + implied [T: Liftable] for Liftable[List[T]] { def toExpr(xs: List[T]): Expr[List[T]] = xs match { - case x :: xs1 => '(~x.toExpr :: ~toExpr(xs1)) - case Nil => '(Nil: List[T]) + case x :: xs1 => '{ ${ toExpr(x) } :: ${ toExpr(xs1) } } + case Nil => '{ Nil: List[T] } } } - +``` In the end, `Liftable` resembles very much a serialization framework. Like the latter it can be derived systematically for all -collections, case classes and enums. Note also that the implicit synthesis +collections, case classes and enums. Note also that the synthesis of "type-tag" values of type `Type[T]` is essentially the type-level analogue of lifting. Using lifting, we can now give the missing definition of `showExpr` in the introductory example: - +```scala def showExpr[T](expr: Expr[T]): Expr[String] = { val code = expr.show code.toExpr } - +``` That is, the `showExpr` method converts its `Expr` argument to a string (`code`), and lifts -the result back to an `Expr[String]` using the implicit `toExpr` conversion. +the result back to an `Expr[String]` using the `toExpr` wrapper. ## Implementation -### Syntax changes - -A splice `~e` on an expression of type `Expr[T]` is a normal prefix -operator. To make it work as a type operator on `Type[T]` as well, we -need a syntax change that introduces prefix operators as types. - - SimpleType ::= ... - [‘-’ | ‘+’ | ‘~’ | ‘!’] StableId - -Analogously to the situation with expressions, a prefix type operator -such as `~ e` is treated as a shorthand for the type `e.unary_~`. +### Syntax -Quotes are supported by introducing new tokens `'(`, `'{`, and `'[` -and adding quoted variants `'(...)`, `'{...}` and `'[...]` to the -`SimpleExpr` productions. +Compared to the [Dotty reference grammar](../../internals/syntax.md) +there are the following syntax changes: - SimpleExpr ::= ... - | ‘'{’ BlockExprContents ‘}’ - | ‘'’ ‘(’ ExprsInParens ‘)’ - | ‘'’ ‘[’ Type ‘]’ + SimpleExpr ::= ... + | ‘'’ BlockExpr + | ‘'’ ‘[’ Type ‘]’ + | ‘$’ BlockExpr + SimpleType ::= ... + | ‘$’ BlockExpr -Syntax changes are given relative to the [Dotty reference -grammar](../../internals/syntax.md). +In addition, an identifier `$x` starting with a `$` that appears inside +a quoted expression or type is treated as a splice `${x}`. -An alternative syntax would treat `'` as a separate operator. This -would be attractive since it enables quoting single identifiers as -e.g. `'x` instead of `'(x)`. But it would clash with symbol -literals. So it could be done only if symbol literals were abolished. +In the future, an analogous rule will apply to quoted identifiers. I.e. `'x` +will expand everywhere to `'{x}`. However, we need to wait one language version with this +so that the competing legacy syntax of symbol literals can be phased out safely. ### Implementation in `dotc` @@ -668,7 +658,7 @@ The syntax of terms, values, and types is given as follows: (x: T) => t lambda t t application 't quote - ~t splice + $t splice Values v ::= (x: T) => t lambda 'u quote @@ -682,7 +672,7 @@ The syntax of terms, values, and types is given as follows: Typing rules are formulated using a stack of environments `Es`. Individual environments `E` consist as usual of variable bindings `x: T`. Environments can be combined using the two -combinators `'` and `~`. +combinators `'` and `$`. Environment E ::= () empty E, x: T @@ -692,7 +682,7 @@ combinators `'` and `~`. Es * Es combined Separator * ::= ' - ~ + $ The two environment combinators are both associative with left and right identity `()`. @@ -703,7 +693,7 @@ We define a small step reduction relation `-->` with the following rules: ((x: T) => t) v --> [x := v]t - ~('u) --> u + ${'u} --> u t1 --> t2 ----------------- @@ -715,7 +705,7 @@ is a context rule; it says that reduction is allowed in the hole `[ ]` position of an evaluation context. Evaluation contexts `e` and splice evaluation context `e_s` are defined syntactically as follows: - Eval context e ::= [ ] | e t | v e | 'e_s[~e] + Eval context e ::= [ ] | e t | v e | 'e_s[${e}] Splice context e_s ::= [ ] | (x: T) => e_s | e_s t | u e_s ### Typing rules @@ -726,12 +716,12 @@ cancel each other out: Es1 * Es2 |- t: T --------------------------- - Es1 ~ E1 ' E2 * Es2 |- t: T + Es1 $ E1 ' E2 * Es2 |- t: T Es1 * Es2 |- t: T --------------------------- - Es1 ' E1 ~ E2 * Es2 |- t: T + Es1 ' E1 $ E2 * Es2 |- t: T The lambda calculus fragment of the rules is standard, except that we use a stack of environments. The rules only interact with the topmost @@ -751,12 +741,12 @@ environment of the stack. --------------------------------- Es |- t1 t2: T -The rules for quotes and splices map between `expr T` and `T` by trading `'` and `~` between +The rules for quotes and splices map between `expr T` and `T` by trading `'` and `$` between environments and terms. - Es ~ () |- t: expr T + Es $ () |- t: expr T -------------------- - Es |- ~t: T + Es |- $t: T Es ' () |- t: T @@ -777,10 +767,10 @@ pattern matching. This opens new possibilities. For instance, here is a version of `power` that generates the multiplications directly if the exponent is statically known and falls back to the dynamic implementation of power otherwise. - - inline def power(n: Int, x: Double): Double = ~{ - '(n) match { - case Constant(n1) => powerCode(n1, '(x)) +```scala + inline def power(n: Int, x: Double): Double = ${ + 'n match { + case Constant(n1) => powerCode(n1, 'x) case _ => '{ dynamicPower(n, x) } } } @@ -789,35 +779,36 @@ implementation of power otherwise. if (n == 0) 1.0 else if (n % 2 == 0) dynamicPower(n / 2, x * x) else x * dynamicPower(n - 1, x) - +``` This assumes a `Constant` extractor that maps tree nodes representing constants to their values. -With the right extractors the "AsFunction" operation +With the right extractors, the "AsFunction" operation that maps expressions over functions to functions over expressions can be implemented in user code: - - implicit class AsFunction[T, U](f: Expr[T => U]) extends AnyVal { - def apply(x: Expr[T]): Expr[U] = - f match { - case Lambda(g) => g(x) - case _ => '((~f)(~x)) - } - +```scala + implied AsFunction1[T, U] for Conversion[Expr[T => U], Expr[T] => Expr[U]] { + def apply(f: Expr[T => U]): Expr[T] => Expr[U] = + (x: Expr[T]) => f match { + case Lambda(g) => g(x) + case _ => '{ ($f)($x) } + } + } +``` This assumes an extractor - +```scala object Lambda { def unapply[T, U](x: Expr[T => U]): Option[Expr[T] => Expr[U]] } - +``` Once we allow inspection of code via extractors, it’s tempting to also add constructors that create typed trees directly without going through quotes. Most likely, those constructors would work over `Expr` types which lack a known type argument. For instance, an `Apply` constructor could be typed as follows: - +```scala def Apply(fn: Expr[_], args: List[Expr[_]]): Expr[_] - +``` This would allow constructing applications from lists of arguments without having to match the arguments one-by-one with the corresponding formal parameter types of the function. We then need "at From 05e530988b5469469021d6c42dec6b6d95c3cefa Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Thu, 14 Feb 2019 10:10:33 +0100 Subject: [PATCH 02/26] Update bootstrap library to new syntax --- community-build/community-projects/minitest | 2 +- community-build/community-projects/scalatest | 2 +- community-build/community-projects/sourcecode | 2 +- community-build/community-projects/stdLib213 | 2 +- .../principled-meta-programming.md | 2 +- .../other-new-features/tasty-reflect.md | 2 +- .../src-bootstrapped/scala/StagedTuple.scala | 170 +++++++++--------- library/src-bootstrapped/scala/Tuple.scala | 38 ++-- .../scala/quoted/package.scala | 2 +- .../scala/tasty/reflect/utils/TreeUtils.scala | 7 +- library/src/scala/quoted/Liftable.scala | 2 +- .../reflect-select-constructor/assert_1.scala | 6 +- 12 files changed, 119 insertions(+), 118 deletions(-) diff --git a/community-build/community-projects/minitest b/community-build/community-projects/minitest index 58292b4ae89a..01ca3a595248 160000 --- a/community-build/community-projects/minitest +++ b/community-build/community-projects/minitest @@ -1 +1 @@ -Subproject commit 58292b4ae89a061a7e44bceb95983970be6fc639 +Subproject commit 01ca3a595248e99973aa46e07fb9bd1626306790 diff --git a/community-build/community-projects/scalatest b/community-build/community-projects/scalatest index f1147035fd11..8e87031d1674 160000 --- a/community-build/community-projects/scalatest +++ b/community-build/community-projects/scalatest @@ -1 +1 @@ -Subproject commit f1147035fd11830eaf658d323d8bf49531a95721 +Subproject commit 8e87031d16741022bac42d2562961ac9092ca91a diff --git a/community-build/community-projects/sourcecode b/community-build/community-projects/sourcecode index bed617b04c06..58f0d4d6c672 160000 --- a/community-build/community-projects/sourcecode +++ b/community-build/community-projects/sourcecode @@ -1 +1 @@ -Subproject commit bed617b04c066517fddd235c73f8b5db3bdc0950 +Subproject commit 58f0d4d6c67211337c795e2c208d261280cd5a3e diff --git a/community-build/community-projects/stdLib213 b/community-build/community-projects/stdLib213 index 98710d2160b4..caba95fa01c6 160000 --- a/community-build/community-projects/stdLib213 +++ b/community-build/community-projects/stdLib213 @@ -1 +1 @@ -Subproject commit 98710d2160b40c8302b7b5df1344c1e77bfd9cc6 +Subproject commit caba95fa01c6510d0681a4d79e97e79797327bc8 diff --git a/docs/docs/reference/other-new-features/principled-meta-programming.md b/docs/docs/reference/other-new-features/principled-meta-programming.md index 7dd5c39f9049..d1a667af9cea 100644 --- a/docs/docs/reference/other-new-features/principled-meta-programming.md +++ b/docs/docs/reference/other-new-features/principled-meta-programming.md @@ -783,7 +783,7 @@ implementation of power otherwise. This assumes a `Constant` extractor that maps tree nodes representing constants to their values. -With the right extractors, the "AsFunction" operation +With the right extractors, the "AsFunction" conversion that maps expressions over functions to functions over expressions can be implemented in user code: ```scala diff --git a/docs/docs/reference/other-new-features/tasty-reflect.md b/docs/docs/reference/other-new-features/tasty-reflect.md index 1f85e824199f..f7851ed52673 100644 --- a/docs/docs/reference/other-new-features/tasty-reflect.md +++ b/docs/docs/reference/other-new-features/tasty-reflect.md @@ -24,7 +24,7 @@ To provide reflection capabilities in macros we need to add an implicit paramete import scala.quoted._ import scala.tasty._ -inline def natConst(x: Int): Int = ~natConstImpl('(x)) +inline def natConst(x: Int): Int = ~natConstImpl('{x}) def natConstImpl(x: Expr[Int])(implicit reflection: Reflection): Expr[Int] = { import reflection._ diff --git a/library/src-bootstrapped/scala/StagedTuple.scala b/library/src-bootstrapped/scala/StagedTuple.scala index b64d39794b0a..c23d768e9e02 100644 --- a/library/src-bootstrapped/scala/StagedTuple.scala +++ b/library/src-bootstrapped/scala/StagedTuple.scala @@ -9,56 +9,56 @@ object StagedTuple { private final val specialize = true def toArrayStaged(tup: Expr[Tuple], size: Option[Int]): Expr[Array[Object]] = { - if (!specialize) '(dynamicToArray(~tup)) + if (!specialize) '{dynamicToArray($tup)} else size match { case Some(0) => - '($emptyArray) + '{empty$Array} case Some(1) => - tup.as[Tuple1[Object]].bind(t => '(Array((~t)._1))) + tup.as[Tuple1[Object]].bind(t => '{Array($t._1)}) case Some(2) => - tup.as[Tuple2[Object, Object]].bind(t => '(Array((~t)._1, (~t)._2))) + tup.as[Tuple2[Object, Object]].bind(t => '{Array($t._1, $t._2)}) case Some(3) => - tup.as[Tuple3[Object, Object, Object]].bind(t => '(Array((~t)._1, (~t)._2, (~t)._3))) + tup.as[Tuple3[Object, Object, Object]].bind(t => '{Array($t._1, $t._2, $t._3)}) case Some(4) => - tup.as[Tuple4[Object, Object, Object, Object]].bind(t => '(Array((~t)._1, (~t)._2, (~t)._3, (~t)._4))) + tup.as[Tuple4[Object, Object, Object, Object]].bind(t => '{Array($t._1, $t._2, $t._3, $t._4)}) case Some(n) if n <= $MaxSpecialized => - '($toArray(~tup, ~n.toExpr)) + '{to$Array($tup, ${ n.toExpr })} case Some(n) => - '((~tup.as[TupleXXL]).elems) + '{${ tup.as[TupleXXL] }.elems} case None => - '(dynamicToArray(~tup)) + '{dynamicToArray($tup)} } } def fromArrayStaged[T <: Tuple : Type](xs: Expr[Array[Object]], size: Option[Int]): Expr[T] = { - if (!specialize) '(dynamicFromArray[T](~xs)) + if (!specialize) '{dynamicFromArray[T]($xs)} else xs.bind { xs => val tup: Expr[Any] = size match { - case Some(0) => '() - case Some(1) => '(Tuple1( (~xs)(0))) - case Some(2) => '(Tuple2( (~xs)(0), (~xs)(1))) - case Some(3) => '(Tuple3( (~xs)(0), (~xs)(1), (~xs)(2))) - case Some(4) => '(Tuple4( (~xs)(0), (~xs)(1), (~xs)(2), (~xs)(3))) - case Some(5) => '(Tuple5( (~xs)(0), (~xs)(1), (~xs)(2), (~xs)(3), (~xs)(4))) - case Some(6) => '(Tuple6( (~xs)(0), (~xs)(1), (~xs)(2), (~xs)(3), (~xs)(4), (~xs)(5))) - case Some(7) => '(Tuple7( (~xs)(0), (~xs)(1), (~xs)(2), (~xs)(3), (~xs)(4), (~xs)(5), (~xs)(6))) - case Some(8) => '(Tuple8( (~xs)(0), (~xs)(1), (~xs)(2), (~xs)(3), (~xs)(4), (~xs)(5), (~xs)(6), (~xs)(7))) - case Some(9) => '(Tuple9( (~xs)(0), (~xs)(1), (~xs)(2), (~xs)(3), (~xs)(4), (~xs)(5), (~xs)(6), (~xs)(7), (~xs)(8))) - case Some(10) => '(Tuple10((~xs)(0), (~xs)(1), (~xs)(2), (~xs)(3), (~xs)(4), (~xs)(5), (~xs)(6), (~xs)(7), (~xs)(8), (~xs)(9))) - case Some(11) => '(Tuple11((~xs)(0), (~xs)(1), (~xs)(2), (~xs)(3), (~xs)(4), (~xs)(5), (~xs)(6), (~xs)(7), (~xs)(8), (~xs)(9), (~xs)(10))) - case Some(12) => '(Tuple12((~xs)(0), (~xs)(1), (~xs)(2), (~xs)(3), (~xs)(4), (~xs)(5), (~xs)(6), (~xs)(7), (~xs)(8), (~xs)(9), (~xs)(10), (~xs)(11))) - case Some(13) => '(Tuple13((~xs)(0), (~xs)(1), (~xs)(2), (~xs)(3), (~xs)(4), (~xs)(5), (~xs)(6), (~xs)(7), (~xs)(8), (~xs)(9), (~xs)(10), (~xs)(11), (~xs)(12))) - case Some(14) => '(Tuple14((~xs)(0), (~xs)(1), (~xs)(2), (~xs)(3), (~xs)(4), (~xs)(5), (~xs)(6), (~xs)(7), (~xs)(8), (~xs)(9), (~xs)(10), (~xs)(11), (~xs)(12), (~xs)(13))) - case Some(15) => '(Tuple15((~xs)(0), (~xs)(1), (~xs)(2), (~xs)(3), (~xs)(4), (~xs)(5), (~xs)(6), (~xs)(7), (~xs)(8), (~xs)(9), (~xs)(10), (~xs)(11), (~xs)(12), (~xs)(13), (~xs)(14))) - case Some(16) => '(Tuple16((~xs)(0), (~xs)(1), (~xs)(2), (~xs)(3), (~xs)(4), (~xs)(5), (~xs)(6), (~xs)(7), (~xs)(8), (~xs)(9), (~xs)(10), (~xs)(11), (~xs)(12), (~xs)(13), (~xs)(14), (~xs)(15))) - case Some(17) => '(Tuple17((~xs)(0), (~xs)(1), (~xs)(2), (~xs)(3), (~xs)(4), (~xs)(5), (~xs)(6), (~xs)(7), (~xs)(8), (~xs)(9), (~xs)(10), (~xs)(11), (~xs)(12), (~xs)(13), (~xs)(14), (~xs)(15), (~xs)(16))) - case Some(18) => '(Tuple18((~xs)(0), (~xs)(1), (~xs)(2), (~xs)(3), (~xs)(4), (~xs)(5), (~xs)(6), (~xs)(7), (~xs)(8), (~xs)(9), (~xs)(10), (~xs)(11), (~xs)(12), (~xs)(13), (~xs)(14), (~xs)(15), (~xs)(16), (~xs)(17))) - case Some(19) => '(Tuple19((~xs)(0), (~xs)(1), (~xs)(2), (~xs)(3), (~xs)(4), (~xs)(5), (~xs)(6), (~xs)(7), (~xs)(8), (~xs)(9), (~xs)(10), (~xs)(11), (~xs)(12), (~xs)(13), (~xs)(14), (~xs)(15), (~xs)(16), (~xs)(17), (~xs)(18))) - case Some(20) => '(Tuple20((~xs)(0), (~xs)(1), (~xs)(2), (~xs)(3), (~xs)(4), (~xs)(5), (~xs)(6), (~xs)(7), (~xs)(8), (~xs)(9), (~xs)(10), (~xs)(11), (~xs)(12), (~xs)(13), (~xs)(14), (~xs)(15), (~xs)(16), (~xs)(17), (~xs)(18), (~xs)(19))) - case Some(21) => '(Tuple21((~xs)(0), (~xs)(1), (~xs)(2), (~xs)(3), (~xs)(4), (~xs)(5), (~xs)(6), (~xs)(7), (~xs)(8), (~xs)(9), (~xs)(10), (~xs)(11), (~xs)(12), (~xs)(13), (~xs)(14), (~xs)(15), (~xs)(16), (~xs)(17), (~xs)(18), (~xs)(19), (~xs)(20))) - case Some(22) => '(Tuple22((~xs)(0), (~xs)(1), (~xs)(2), (~xs)(3), (~xs)(4), (~xs)(5), (~xs)(6), (~xs)(7), (~xs)(8), (~xs)(9), (~xs)(10), (~xs)(11), (~xs)(12), (~xs)(13), (~xs)(14), (~xs)(15), (~xs)(16), (~xs)(17), (~xs)(18), (~xs)(19), (~xs)(20), (~xs)(21))) - case Some(_) => '(TupleXXL(~xs)) - case None => '(dynamicFromArray[T](~xs)) + case Some(0) => '{} + case Some(1) => '{Tuple1( $xs(0))} + case Some(2) => '{Tuple2( $xs(0), $xs(1))} + case Some(3) => '{Tuple3( $xs(0), $xs(1), $xs(2))} + case Some(4) => '{Tuple4( $xs(0), $xs(1), $xs(2), $xs(3))} + case Some(5) => '{Tuple5( $xs(0), $xs(1), $xs(2), $xs(3), $xs(4))} + case Some(6) => '{Tuple6( $xs(0), $xs(1), $xs(2), $xs(3), $xs(4), $xs(5))} + case Some(7) => '{Tuple7( $xs(0), $xs(1), $xs(2), $xs(3), $xs(4), $xs(5), $xs(6))} + case Some(8) => '{Tuple8( $xs(0), $xs(1), $xs(2), $xs(3), $xs(4), $xs(5), $xs(6), $xs(7))} + case Some(9) => '{Tuple9( $xs(0), $xs(1), $xs(2), $xs(3), $xs(4), $xs(5), $xs(6), $xs(7), $xs(8))} + case Some(10) => '{Tuple10($xs(0), $xs(1), $xs(2), $xs(3), $xs(4), $xs(5), $xs(6), $xs(7), $xs(8), $xs(9))} + case Some(11) => '{Tuple11($xs(0), $xs(1), $xs(2), $xs(3), $xs(4), $xs(5), $xs(6), $xs(7), $xs(8), $xs(9), $xs(10))} + case Some(12) => '{Tuple12($xs(0), $xs(1), $xs(2), $xs(3), $xs(4), $xs(5), $xs(6), $xs(7), $xs(8), $xs(9), $xs(10), $xs(11))} + case Some(13) => '{Tuple13($xs(0), $xs(1), $xs(2), $xs(3), $xs(4), $xs(5), $xs(6), $xs(7), $xs(8), $xs(9), $xs(10), $xs(11), $xs(12))} + case Some(14) => '{Tuple14($xs(0), $xs(1), $xs(2), $xs(3), $xs(4), $xs(5), $xs(6), $xs(7), $xs(8), $xs(9), $xs(10), $xs(11), $xs(12), $xs(13))} + case Some(15) => '{Tuple15($xs(0), $xs(1), $xs(2), $xs(3), $xs(4), $xs(5), $xs(6), $xs(7), $xs(8), $xs(9), $xs(10), $xs(11), $xs(12), $xs(13), $xs(14))} + case Some(16) => '{Tuple16($xs(0), $xs(1), $xs(2), $xs(3), $xs(4), $xs(5), $xs(6), $xs(7), $xs(8), $xs(9), $xs(10), $xs(11), $xs(12), $xs(13), $xs(14), $xs(15))} + case Some(17) => '{Tuple17($xs(0), $xs(1), $xs(2), $xs(3), $xs(4), $xs(5), $xs(6), $xs(7), $xs(8), $xs(9), $xs(10), $xs(11), $xs(12), $xs(13), $xs(14), $xs(15), $xs(16))} + case Some(18) => '{Tuple18($xs(0), $xs(1), $xs(2), $xs(3), $xs(4), $xs(5), $xs(6), $xs(7), $xs(8), $xs(9), $xs(10), $xs(11), $xs(12), $xs(13), $xs(14), $xs(15), $xs(16), $xs(17))} + case Some(19) => '{Tuple19($xs(0), $xs(1), $xs(2), $xs(3), $xs(4), $xs(5), $xs(6), $xs(7), $xs(8), $xs(9), $xs(10), $xs(11), $xs(12), $xs(13), $xs(14), $xs(15), $xs(16), $xs(17), $xs(18))} + case Some(20) => '{Tuple20($xs(0), $xs(1), $xs(2), $xs(3), $xs(4), $xs(5), $xs(6), $xs(7), $xs(8), $xs(9), $xs(10), $xs(11), $xs(12), $xs(13), $xs(14), $xs(15), $xs(16), $xs(17), $xs(18), $xs(19))} + case Some(21) => '{Tuple21($xs(0), $xs(1), $xs(2), $xs(3), $xs(4), $xs(5), $xs(6), $xs(7), $xs(8), $xs(9), $xs(10), $xs(11), $xs(12), $xs(13), $xs(14), $xs(15), $xs(16), $xs(17), $xs(18), $xs(19), $xs(20))} + case Some(22) => '{Tuple22($xs(0), $xs(1), $xs(2), $xs(3), $xs(4), $xs(5), $xs(6), $xs(7), $xs(8), $xs(9), $xs(10), $xs(11), $xs(12), $xs(13), $xs(14), $xs(15), $xs(16), $xs(17), $xs(18), $xs(19), $xs(20), $xs(21))} + case Some(_) => '{TupleXXL($xs)} + case None => '{dynamicFromArray[T]($xs)} } tup.as[T] } @@ -66,109 +66,109 @@ object StagedTuple { def sizeStaged[Res <: Int : Type](tup: Expr[Tuple], size: Option[Int]): Expr[Res] = { val res = - if (!specialize) '(dynamicSize(~tup)) + if (!specialize) '{dynamicSize($tup)} else size match { case Some(n) => n.toExpr - case None => '(dynamicSize(~tup)) + case None => '{dynamicSize($tup)} } res.as[Res] } def headStaged[Tup <: NonEmptyTuple : Type](tup: Expr[Tup], size: Option[Int]): Expr[Head[Tup]] = { - if (!specialize) '(dynamicHead(~tup)) + if (!specialize) '{dynamicHead($tup)} else { val resVal = size match { case Some(1) => - '((~tup.as[Tuple1[_]])._1) + '{${ tup.as[Tuple1[_]] }._1} case Some(2) => - '((~tup.as[Tuple2[_, _]])._1) + '{${ tup.as[Tuple2[_, _]] }._1} case Some(3) => - '((~tup.as[Tuple3[_, _, _]])._1) + '{${ tup.as[Tuple3[_, _, _]]}._1} case Some(4) => - '((~tup.as[Tuple4[_, _, _, _]])._1) + '{${ tup.as[Tuple4[_, _, _, _]] }._1} case Some(n) if n > 4 && n <= $MaxSpecialized => - '((~tup.as[Product]).productElement(0)) + '{${ tup.as[Product] }.productElement(0)} case Some(n) if n > $MaxSpecialized => - '((~tup.as[TupleXXL]).elems(0)) + '{${tup.as[TupleXXL] }.elems(0)} case None => - '(dynamicHead(~tup)) + '{dynamicHead($tup)} } resVal.as[Head[Tup]] } } def tailStaged[Tup <: NonEmptyTuple : Type](tup: Expr[Tup], size: Option[Int]): Expr[Tail[Tup]] = { - if (!specialize) '(dynamicTail[Tup](~tup)) + if (!specialize) '{dynamicTail[Tup]($tup)} else { val res = size match { case Some(1) => - '() + '{} case Some(2) => - tup.as[Tuple2[_, _]].bind(t => '(Tuple1((~t)._2))) + tup.as[Tuple2[_, _]].bind(t => '{Tuple1($t._2)}) case Some(3) => - tup.as[Tuple3[_, _, _]].bind(t => '(Tuple2((~t)._2, (~t)._3))) + tup.as[Tuple3[_, _, _]].bind(t => '{Tuple2($t._2, $t._3)}) case Some(4) => - tup.as[Tuple4[_, _, _, _]].bind(t => '(Tuple3((~t)._2, (~t)._3, (~t)._4))) + tup.as[Tuple4[_, _, _, _]].bind(t => '{Tuple3($t._2, $t._3, $t._4)}) case Some(5) => - tup.as[Tuple5[_, _, _, _, _]].bind(t => '(Tuple4((~t)._2, (~t)._3, (~t)._4, (~t)._5))) + tup.as[Tuple5[_, _, _, _, _]].bind(t => '{Tuple4($t._2, $t._3, $t._4, $t._5)}) case Some(n) if n > 5 => val arr = toArrayStaged(tup, size) - fromArrayStaged('((~arr).tail) , Some(n - 1)) + fromArrayStaged('{ $arr.tail }, Some(n - 1)) case None => - '(dynamicTail(~tup)) + '{dynamicTail($tup)} } res.as[Tail[Tup]] } } def applyStaged[Tup <: NonEmptyTuple : Type, N <: Int : Type](tup: Expr[Tup], size: Option[Int], n: Expr[N], nValue: Option[Int]): Expr[Elem[Tup, N]] = { - if (!specialize) '(dynamicApply(~tup, ~n)) + if (!specialize) '{dynamicApply($tup, $n)} else { def fallbackApply(): Expr[Elem[Tup, N]] = nValue match { case Some(n) => quoted.QuoteError("index out of bounds: " + n) - case None => '(dynamicApply(~tup, ~n)) + case None => '{dynamicApply($tup, $n)} } val res = size match { case Some(1) => val t = tup.as[Tuple1[_]] nValue match { - case Some(0) => '((~t)._1) + case Some(0) => '{$t._1} case _ => fallbackApply() } case Some(2) => val t = tup.as[Tuple2[_, _]] nValue match { - case Some(0) => '((~t)._1) - case Some(1) => '((~t)._2) + case Some(0) => '{$t._1} + case Some(1) => '{$t._2} case _ => fallbackApply() } case Some(3) => val t = tup.as[Tuple3[_, _, _]] nValue match { - case Some(0) => '((~t)._1) - case Some(1) => '((~t)._2) - case Some(2) => '((~t)._3) + case Some(0) => '{$t._1} + case Some(1) => '{$t._2} + case Some(2) => '{$t._3} case _ => fallbackApply() } case Some(4) => val t = tup.as[Tuple4[_, _, _, _]] nValue match { - case Some(0) => '((~t)._1) - case Some(1) => '((~t)._2) - case Some(2) => '((~t)._3) - case Some(3) => '((~t)._4) + case Some(0) => '{$t._1} + case Some(1) => '{$t._2} + case Some(2) => '{$t._3} + case Some(3) => '{$t._4} case _ => fallbackApply() } case Some(s) if s > 4 && s <= $MaxSpecialized => val t = tup.as[Product] nValue match { - case Some(n) if n >= 0 && n < s => '((~t).productElement(~n.toExpr)) + case Some(n) if n >= 0 && n < s => '{$t.productElement(${ n.toExpr })} case _ => fallbackApply() } case Some(s) if s > $MaxSpecialized => val t = tup.as[TupleXXL] nValue match { - case Some(n) if n >= 0 && n < s => '((~t).elems(~n.toExpr)) + case Some(n) if n >= 0 && n < s => '{$t.elems(${ n.toExpr })} case _ => fallbackApply() } case _ => fallbackApply() @@ -178,50 +178,50 @@ object StagedTuple { } def stagedCons[T <: Tuple & Singleton : Type, H : Type](self: Expr[T], x: Expr[H], tailSize: Option[Int]): Expr[H *: T] = - if (!specialize) '(dynamic_*:[T, H](~self, ~x)) + if (!specialize) '{dynamic_*:[T, H]($self, $x)} else { val res = tailSize match { case Some(0) => - '(Tuple1(~x)) + '{Tuple1($x)} case Some(1) => - self.as[Tuple1[_]].bind(t => '(Tuple2(~x, (~t)._1))) + self.as[Tuple1[_]].bind(t => '{Tuple2($x, $t._1)}) case Some(2) => - self.as[Tuple2[_, _]].bind(t => '(Tuple3(~x, (~t)._1, (~t)._2))) + self.as[Tuple2[_, _]].bind(t => '{Tuple3($x, $t._1, $t._2)}) case Some(3) => - self.as[Tuple3[_, _, _]].bind(t => '(Tuple4(~x, (~t)._1, (~t)._2, (~t)._3))) + self.as[Tuple3[_, _, _]].bind(t => '{Tuple4($x, $t._1, $t._2, $t._3)}) case Some(4) => - self.as[Tuple4[_, _, _, _]].bind(t => '(Tuple5(~x, (~t)._1, (~t)._2, (~t)._3, (~t)._4))) + self.as[Tuple4[_, _, _, _]].bind(t => '{Tuple5($x, $t._1, $t._2, $t._3, $t._4)}) case Some(n) => - fromArrayStaged[H *: T]('($consArray(~x, ~toArrayStaged(self, tailSize))), Some(n + 1)) + fromArrayStaged[H *: T]('{cons$Array($x, ${ toArrayStaged(self, tailSize) })}, Some(n + 1)) case _ => - '(dynamic_*:[T, H](~self, ~x)) + '{dynamic_*:[T, H]($self, $x)} } res.as[H *: T] } def stagedConcat[Self <: Tuple & Singleton : Type, That <: Tuple & Singleton : Type](self: Expr[Self], selfSize: Option[Int], that: Expr[That], thatSize: Option[Int]): Expr[Concat[Self, That]] = { - if (!specialize) '(dynamic_++[Self, That](~self, ~that)) + if (!specialize) '{dynamic_++[Self, That]($self, $that)} else { def genericConcat(xs: Expr[Tuple], ys: Expr[Tuple]): Expr[Tuple] = - fromArrayStaged[Tuple]('((~toArrayStaged(xs, None)) ++ (~toArrayStaged(ys, None))), None) + fromArrayStaged[Tuple]('{${ toArrayStaged(xs, None) } ++ ${ toArrayStaged(ys, None) }}, None) val res = selfSize match { case Some(0) => that case Some(1) => if (thatSize.contains(0)) self - else stagedCons(that, '((~self).asInstanceOf[Tuple1[_]]._1), thatSize) + else stagedCons(that, '{$self.asInstanceOf[Tuple1[_]]._1}, thatSize) case Some(2) => val self2 = self.as[Tuple2[_, _]] thatSize match { case Some(0) => self case Some(1) => self2.bind { t => - that.as[Tuple1[_]].bind(u => '(Tuple3((~t)._1, (~t)._2, (~u)._1))) + that.as[Tuple1[_]].bind(u => '{Tuple3($t._1, $t._2, $u._1)}) } case Some(2) => self2.bind { t => - that.as[Tuple2[_, _]].bind(u => '(Tuple4((~t)._1, (~t)._2, (~u)._1, (~u)._2))) + that.as[Tuple2[_, _]].bind(u => '{Tuple4($t._1, $t._2, $u._1, $u._2)}) } case _ => genericConcat(self, that) @@ -232,7 +232,7 @@ object StagedTuple { case Some(0) => self case Some(1) => self2.bind { t => - that.as[Tuple1[_]].bind(u => '(Tuple4((~t)._1, (~t)._2, (~t)._3, (~u)._1))) + that.as[Tuple1[_]].bind(u => '{Tuple4($t._1, $t._2, $t._3, $u._1)}) } case _ => genericConcat(self, that) @@ -241,7 +241,7 @@ object StagedTuple { if (thatSize.contains(0)) self else genericConcat(self, that) case None => - '(dynamic_++(~self, ~that)) + '{dynamic_++($self, $that)} } res.as[Concat[Self, That]] } @@ -249,11 +249,11 @@ object StagedTuple { private implicit class ExprOps[U: Type](expr: Expr[U]) { - def as[T: Type]: Expr[T] = '{ (~expr).asInstanceOf[T] } + def as[T: Type]: Expr[T] = '{ $expr.asInstanceOf[T] } def bind[T: Type](in: Expr[U] => Expr[T]): Expr[T] = '{ - val t: U = (~expr) - ~(in('(t))) + val t: U = $expr + ${in('{t})} } } diff --git a/library/src-bootstrapped/scala/Tuple.scala b/library/src-bootstrapped/scala/Tuple.scala index 07b524050612..f6823e954d1f 100644 --- a/library/src-bootstrapped/scala/Tuple.scala +++ b/library/src-bootstrapped/scala/Tuple.scala @@ -10,7 +10,7 @@ sealed trait Tuple extends Any { if (stageIt) stagedToArray else inline constValueOpt[BoundedSize[this.type]] match { case Some(0) => - $emptyArray + empty$Array case Some(1) => val t = asInstanceOf[Tuple1[Object]] Array(t._1) @@ -24,7 +24,7 @@ sealed trait Tuple extends Any { val t = asInstanceOf[Tuple4[Object, Object, Object, Object]] Array(t._1, t._2, t._3, t._4) case Some(n) if n <= $MaxSpecialized => - $toArray(this, n) + to$Array(this, n) case Some(n) => asInstanceOf[TupleXXL].elems case None => @@ -32,7 +32,7 @@ sealed trait Tuple extends Any { } inline def stagedToArray: Array[Object] = - ~StagedTuple.toArrayStaged('(this), constValueOpt[BoundedSize[this.type]]) + ${ StagedTuple.toArrayStaged('{this}, constValueOpt[BoundedSize[this.type]]) } inline def *: [H] (x: H): H *: this.type = if (stageIt) stagedCons[H](x) @@ -53,14 +53,14 @@ sealed trait Tuple extends Any { val t = asInstanceOf[Tuple4[_, _, _, _]] Tuple5(x, t._1, t._2, t._3, t._4).asInstanceOf[Result] case Some(n) => - fromArray[Result]($consArray(x, toArray)) + fromArray[Result](cons$Array(x, toArray)) case _ => dynamic_*:[this.type, H](this, x) } } inline def stagedCons[H] (x: H): H *: this.type = - ~StagedTuple.stagedCons('(this), '(x), constValueOpt[BoundedSize[this.type]]) + ${ StagedTuple.stagedCons('{this}, '{x}, constValueOpt[BoundedSize[this.type]]) } inline def ++(that: Tuple): Concat[this.type, that.type] = if (stageIt) stagedConcat(that) @@ -104,8 +104,8 @@ sealed trait Tuple extends Any { } inline def stagedConcat(that: Tuple): Concat[this.type, that.type] = - ~StagedTuple.stagedConcat('(this), constValueOpt[BoundedSize[this.type]], - '(that), constValueOpt[BoundedSize[that.type]]) + ${ StagedTuple.stagedConcat('{this}, constValueOpt[BoundedSize[this.type]], + '{that}, constValueOpt[BoundedSize[that.type]]) } inline def genericConcat[T <: Tuple](xs: Tuple, ys: Tuple): Tuple = fromArray[T](xs.toArray ++ ys.toArray) @@ -121,7 +121,7 @@ sealed trait Tuple extends Any { } inline def stagedSize: Size[this.type] = - ~StagedTuple.sizeStaged[Size[this.type]]('(this), constValueOpt[BoundedSize[this.type]]) + ${ StagedTuple.sizeStaged[Size[this.type]]('{this}, constValueOpt[BoundedSize[this.type]]) } } object Tuple { @@ -167,9 +167,9 @@ object Tuple { private[scala] type BoundedSize[X] = BoundedSizeRecur[X, 23] - val $emptyArray = Array[Object]() + val empty$Array = Array[Object]() - def $toArray(xs: Tuple, n: Int) = { + def to$Array(xs: Tuple, n: Int) = { val arr = new Array[Object](n) var i = 0 var it = xs.asInstanceOf[Product].productIterator @@ -180,7 +180,7 @@ object Tuple { arr } - def $consArray[H](x: H, elems: Array[Object]): Array[Object] = { + def cons$Array[H](x: H, elems: Array[Object]): Array[Object] = { val elems1 = new Array[Object](elems.length + 1) elems1(0) = x.asInstanceOf[Object] System.arraycopy(elems, 0, elems1, 1, elems.length) @@ -217,7 +217,7 @@ object Tuple { } inline def stagedFromArray[T <: Tuple](xs: Array[Object]): T = - ~StagedTuple.fromArrayStaged[T]('(xs), constValueOpt[BoundedSize[this.type]]) + ${ StagedTuple.fromArrayStaged[T]('{xs}, constValueOpt[BoundedSize[this.type]]) } def dynamicFromArray[T <: Tuple](xs: Array[Object]): T = xs.length match { case 0 => ().asInstanceOf[T] @@ -248,7 +248,7 @@ object Tuple { def dynamicToArray(self: Tuple): Array[Object] = (self: Any) match { case self: Unit => - $emptyArray + empty$Array case self: Tuple1[_] => val t = self.asInstanceOf[Tuple1[Object]] Array(t._1) @@ -283,7 +283,7 @@ object Tuple { case self: Tuple4[_, _, _, _] => Tuple5(x, self._1, self._2, self._3, self._4).asInstanceOf[Result] case _ => - dynamicFromArray[Result]($consArray(x, dynamicToArray(self))) + dynamicFromArray[Result](cons$Array(x, dynamicToArray(self))) } } @@ -340,7 +340,7 @@ sealed trait NonEmptyTuple extends Tuple { } inline def stagedHead: Head[this.type] = - ~StagedTuple.headStaged[this.type]('(this), constValueOpt[BoundedSize[this.type]]) + ${ StagedTuple.headStaged[this.type]('{this}, constValueOpt[BoundedSize[this.type]]) } inline def tail: Tail[this.type] = if (stageIt) stagedTail @@ -369,7 +369,7 @@ sealed trait NonEmptyTuple extends Tuple { } inline def stagedTail: Tail[this.type] = - ~StagedTuple.tailStaged[this.type]('(this), constValueOpt[BoundedSize[this.type]]) + ${ StagedTuple.tailStaged[this.type]('{this}, constValueOpt[BoundedSize[this.type]]) } inline def fallbackApply(n: Int) = inline constValueOpt[n.type] match { @@ -429,9 +429,9 @@ sealed trait NonEmptyTuple extends Tuple { } inline def stagedApply(n: Int): Elem[this.type, n.type] = - ~StagedTuple.applyStaged[this.type, n.type]( - '(this), constValueOpt[Size[this.type]], - '(n), constValueOpt[n.type]) + ${ StagedTuple.applyStaged[this.type, n.type]( + '{this}, constValueOpt[Size[this.type]], + '{n}, constValueOpt[n.type]) } } object NonEmptyTuple { diff --git a/library/src-bootstrapped/scala/quoted/package.scala b/library/src-bootstrapped/scala/quoted/package.scala index f7ece4905368..7334ac3d0677 100644 --- a/library/src-bootstrapped/scala/quoted/package.scala +++ b/library/src-bootstrapped/scala/quoted/package.scala @@ -10,7 +10,7 @@ package object quoted { def toExprOfList(implicit ev: Type[T]): Expr[List[T]] = { def rec(list: List[Expr[T]]): Expr[List[T]] = list match { case x :: xs => '{ (~x) :: (~rec(xs)) } - case Nil => '(Nil) + case Nil => '{Nil} } rec(list) } diff --git a/library/src-bootstrapped/scala/tasty/reflect/utils/TreeUtils.scala b/library/src-bootstrapped/scala/tasty/reflect/utils/TreeUtils.scala index ccc2bf6a3a82..3bc96e6e0e2f 100644 --- a/library/src-bootstrapped/scala/tasty/reflect/utils/TreeUtils.scala +++ b/library/src-bootstrapped/scala/tasty/reflect/utils/TreeUtils.scala @@ -14,12 +14,13 @@ trait TreeUtils { implicit val rhsTpe: quoted.Type[T] = rhs.tpe.seal.asInstanceOf[quoted.Type[T]] val rhsExpr = rhs.seal[T] val expr = '{ - val x = ~rhsExpr - ~{ - val id = ('(x)).unseal.asInstanceOf[Term.Ident] + val x = $rhsExpr + ${ + val id = ('x).unseal.asInstanceOf[Term.Ident] body(id).seal[Any] } } expr.unseal } + } diff --git a/library/src/scala/quoted/Liftable.scala b/library/src/scala/quoted/Liftable.scala index 871fde9ee6c0..e56e3bc594d8 100644 --- a/library/src/scala/quoted/Liftable.scala +++ b/library/src/scala/quoted/Liftable.scala @@ -3,7 +3,7 @@ package scala.quoted import scala.runtime.quoted.Unpickler.liftedExpr /** A typeclass for types that can be turned to `quoted.Expr[T]` - * without going through an explicit `'(...)` operation. + * without going through an explicit `'{...}` operation. */ abstract class Liftable[T] { def toExpr(x: T): Expr[T] diff --git a/tests/run-with-compiler/reflect-select-constructor/assert_1.scala b/tests/run-with-compiler/reflect-select-constructor/assert_1.scala index 15416a9a544d..1a34880b00db 100644 --- a/tests/run-with-compiler/reflect-select-constructor/assert_1.scala +++ b/tests/run-with-compiler/reflect-select-constructor/assert_1.scala @@ -3,7 +3,7 @@ import scala.tasty._ object scalatest { - inline def assert(condition: => Boolean): Unit = ~assertImpl('(condition), '("")) + inline def assert(condition: => Boolean): Unit = ${ assertImpl('condition, '{""}) } def assertImpl(cond: Expr[Boolean], clue: Expr[Any])(implicit refl: Reflection): Expr[Unit] = { import refl._ @@ -22,7 +22,7 @@ object scalatest { val l = left.seal[Any] val r = right.seal[Any] val b = result.seal[Boolean] - val code = '{ scala.Predef.assert(~b) } + val code = '{ scala.Predef.assert($b) } code.unseal } } @@ -36,7 +36,7 @@ object scalatest { val l = left.seal[Any] val r = right.seal[Any] val b = result.seal[Boolean] - val code = '{ scala.Predef.assert(~b) } + val code = '{ scala.Predef.assert($b) } code.unseal } } From 3257b9d0a29da3700027f311677894906b29b40a Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Thu, 14 Feb 2019 10:13:17 +0100 Subject: [PATCH 03/26] Update tests to new syntax --- bench/tests/power-macro/PowerMacro.scala | 6 +- compiler/test-resources/repl/i5551 | 2 +- tests/disabled/run/i4803d/App_2.scala | 2 +- tests/disabled/run/i4803d/Macro_1.scala | 6 +- .../run/xml-interpolation-3/XmlQuote_1.scala | 4 +- .../quote-run-in-macro-1/quoted_1.scala | 2 +- .../quote-run-in-macro-2/quoted_1.scala | 2 +- tests/neg/i4044a.scala | 8 +-- tests/neg/i4044b.scala | 6 +- tests/neg/i4350.scala | 2 +- tests/neg/i4433.scala | 6 +- tests/neg/i4493-b.scala | 4 +- tests/neg/i4493.scala | 4 +- tests/neg/i4774b.scala | 6 +- tests/neg/i4890.scala | 2 +- .../Macro_1.scala | 2 +- tests/neg/inline-option/Macro_1.scala | 2 +- tests/neg/quote-0.scala | 12 ++-- tests/neg/quote-MacroOverride.scala | 2 +- tests/neg/quote-complex-top-splice.scala | 6 +- tests/neg/quote-error-2/Macro_1.scala | 6 +- tests/neg/quote-error/Macro_1.scala | 4 +- tests/neg/quote-exception/Macro_1.scala | 4 +- tests/neg/quote-interpolator-core-old.scala | 12 ++-- tests/neg/quote-macro-2-splices.scala | 2 +- tests/neg/quote-macro-complex-arg-0.scala | 4 +- tests/neg/quote-macro-splice.scala | 4 +- tests/neg/quote-pcp-in-arg.scala | 2 +- tests/neg/quote-splice-interpret-1.scala | 6 +- tests/neg/quote-spliceNonStaged.scala | 2 +- tests/neg/quote-this.scala | 6 +- tests/neg/splice-in-top-level-splice-1.scala | 4 +- tests/neg/splice-in-top-level-splice-2.scala | 4 +- tests/neg/tasty-macro-assert/quoted_1.scala | 6 +- tests/pending/run/patmat-exprs.scala | 8 +-- tests/pos-with-compiler/quote-0.scala | 14 ++-- .../quote-assert/quoted_1.scala | 2 +- .../quote-assert/quoted_2.scala | 4 +- tests/pos/i3898/quoted_1.scala | 4 +- tests/pos/i3898b/quoted_1.scala | 4 +- tests/pos/i3898c/quoted_1.scala | 4 +- tests/pos/i3912-1/i3912_1.scala | 2 +- tests/pos/i3912-2/i3912_1.scala | 2 +- tests/pos/i3912-3/i3912_1.scala | 2 +- tests/pos/i4023/Macro_1.scala | 2 +- tests/pos/i4023b/Macro_1.scala | 2 +- tests/pos/i4023c/Macro_1.scala | 4 +- tests/pos/i4350.scala | 2 +- tests/pos/i4380b.scala | 4 +- tests/pos/i4396a.scala | 2 +- tests/pos/i4493-c.scala | 4 +- tests/pos/i4514.scala | 4 +- tests/pos/i4734/Macro_1.scala | 4 +- tests/pos/i4773.scala | 2 +- tests/pos/i4774a.scala | 4 +- tests/pos/i4774c.scala | 2 +- tests/pos/i4774d.scala | 2 +- tests/pos/i4846.scala | 2 +- tests/pos/i4891.scala | 2 +- tests/pos/macro-with-array/Macro_1.scala | 46 ++++++------- tests/pos/macro-with-type/Macro_1.scala | 2 +- tests/pos/power-macro/Macro_1.scala | 8 +-- tests/pos/quote-1.scala | 6 +- tests/pos/quote-lift-inline-params-b.scala | 4 +- .../quote-lift-inline-params/Macro_1.scala | 4 +- tests/pos/quote-lift.scala | 2 +- tests/pos/quote-liftable.scala | 16 ++--- tests/pos/quote-nested-object/Macro_1.scala | 8 +-- tests/pos/quote-non-static-macro.scala | 2 +- tests/pos/quote-this.scala | 18 +++--- tests/pos/spliceTest.scala | 14 ---- tests/pos/t4579.scala | 12 ++-- .../tasty-definitions-2/Macro_1.scala | 2 +- .../tasty-definitions-3/Macro_1.scala | 2 +- .../tasty-extractors-owners/quoted_1.scala | 4 +- .../Yretain-trees/tasty-load-tree-1.check | 2 +- .../tasty-load-tree-1/quoted_1.scala | 4 +- .../Yretain-trees/tasty-load-tree-2.check | 2 +- .../tasty-load-tree-2/quoted_1.scala | 4 +- .../staged-streams_1.scala | 6 +- tests/run-with-compiler/i3823-b.scala | 2 +- tests/run-with-compiler/i3823-c.scala | 2 +- tests/run-with-compiler/i3823.scala | 2 +- tests/run-with-compiler/i3847-b.scala | 4 +- tests/run-with-compiler/i3847.scala | 4 +- tests/run-with-compiler/i3876-b.scala | 2 +- tests/run-with-compiler/i3876-c.scala | 2 +- tests/run-with-compiler/i3876-d.scala | 2 +- tests/run-with-compiler/i3876.scala | 2 +- tests/run-with-compiler/i3946.scala | 2 +- tests/run-with-compiler/i4044a.scala | 2 +- tests/run-with-compiler/i4044b.scala | 4 +- tests/run-with-compiler/i4044d.scala | 4 +- tests/run-with-compiler/i4044e.scala | 4 +- tests/run-with-compiler/i4044f.scala | 10 +-- tests/run-with-compiler/i4350.scala | 2 +- tests/run-with-compiler/i4591.scala | 2 +- tests/run-with-compiler/i5144.scala | 4 +- tests/run-with-compiler/i5144b.scala | 4 +- tests/run-with-compiler/i5152.scala | 4 +- .../run-with-compiler/quote-ackermann-1.scala | 2 +- tests/run-with-compiler/quote-fun-app-1.scala | 6 +- .../quote-function-applied-to.scala | 44 ++++++------- .../quote-impure-by-name/quoted_1.scala | 4 +- .../quote-inline-function/quoted_1.scala | 8 +-- tests/run-with-compiler/quote-lambda.scala | 2 +- tests/run-with-compiler/quote-lib.scala | 26 ++++---- tests/run-with-compiler/quote-nested-1.scala | 2 +- tests/run-with-compiler/quote-nested-2.scala | 4 +- tests/run-with-compiler/quote-nested-3.scala | 4 +- tests/run-with-compiler/quote-nested-5.scala | 4 +- tests/run-with-compiler/quote-run-2.scala | 14 ++-- tests/run-with-compiler/quote-run-many.scala | 2 +- .../quote-run-staged-interpreter.scala | 6 +- .../run-with-compiler/quote-show-blocks.scala | 6 +- .../quote-two-captured-ref.scala | 6 +- tests/run-with-compiler/quote-type-tags.scala | 22 +++---- .../quote-unrolled-foreach.scala | 32 +++++----- tests/run-with-compiler/quote-var.scala | 6 +- .../run-with-compiler/shonan-hmm-simple.scala | 40 ++++++------ .../shonan-hmm/Complex.scala | 6 +- .../shonan-hmm/Lifters.scala | 12 ++-- .../run-with-compiler/shonan-hmm/MVmult.scala | 64 +++++++++---------- tests/run-with-compiler/shonan-hmm/Ring.scala | 10 +-- tests/run-with-compiler/shonan-hmm/Test.scala | 4 +- .../shonan-hmm/UnrolledExpr.scala | 2 +- .../run-with-compiler/shonan-hmm/VecOp.scala | 2 +- .../run-with-compiler/shonan-hmm/VecROp.scala | 6 +- .../run-with-compiler/shonan-hmm/Vmults.scala | 8 +-- .../quoted_1.scala | 24 +++---- .../tasty-unsafe-let/quoted_1.scala | 2 +- tests/run/Course-2002-07.check | 8 +-- tests/run/Course-2002-07.scala | 8 +-- tests/run/f-interpolation-1/FQuote_1.scala | 8 +-- .../gestalt-optional-staging/Macro_1.scala | 10 +-- .../Macro_1.scala | 32 +++++----- tests/run/i4431/quoted_1.scala | 2 +- tests/run/i4455/Macro_1.scala | 4 +- tests/run/i4492/quoted_1.scala | 2 +- tests/run/i4515/Macro_1.scala | 4 +- tests/run/i4515b/Macro_1.scala | 2 +- tests/run/i4734/Macro_1.scala | 14 ++-- tests/run/i4735/Macro_1.scala | 14 ++-- tests/run/i4803/App_2.scala | 2 +- tests/run/i4803/Macro_1.scala | 6 +- tests/run/i4803b/App_2.scala | 2 +- tests/run/i4803b/Macro_1.scala | 4 +- tests/run/i4803c/App_2.scala | 4 +- tests/run/i4803c/Macro_1.scala | 4 +- tests/run/i4803e/App_2.scala | 2 +- tests/run/i4803f/App_2.scala | 2 +- tests/run/i4803f/Macro_1.scala | 6 +- tests/run/i4947e/Test_2.scala | 2 +- tests/run/i4947f/Macro_1.scala | 2 +- tests/run/i5119/Macro_1.scala | 2 +- tests/run/i5119b/Macro_1.scala | 2 +- tests/run/i5386.scala | 2 +- tests/run/i5533/Macro_1.scala | 4 +- tests/run/i5533b/Macro_1.scala | 2 +- tests/run/i5536/Macro_1.scala | 2 +- tests/run/i5606.scala | 8 +-- .../Macro_1.scala | 8 +-- tests/run/inline-option/Macro_1.scala | 2 +- tests/run/quote-and-splice/Macros_1.scala | 16 ++--- tests/run/quote-change-owner/Macro_1.scala | 2 +- tests/run/quote-compile-constants.scala | 16 ++--- tests/run/quote-force/quoted_1.scala | 6 +- .../quote-indexed-map-by-name/quoted_1.scala | 4 +- tests/run/quote-sep-comp-2/Test_2.scala | 2 +- tests/run/quote-sep-comp/Macro_1.scala | 2 +- tests/run/quote-simple-hole.scala | 8 +-- tests/run/quote-simple-macro/quoted_1.scala | 4 +- .../run/quote-unrolled-foreach/quoted_1.scala | 14 ++-- tests/run/reflect-select-copy/assert_1.scala | 2 +- tests/run/t6111.scala | 2 +- tests/run/t6888.scala | 8 +-- tests/run/tasty-argument-tree-1.check | 22 +++---- .../run/tasty-argument-tree-1/quoted_1.scala | 6 +- tests/run/tasty-custom-show/quoted_1.scala | 4 +- tests/run/tasty-definitions-1/quoted_1.scala | 4 +- tests/run/tasty-eval/quoted_1.scala | 2 +- tests/run/tasty-extractors-1.check | 14 ++-- tests/run/tasty-extractors-1/quoted_1.scala | 6 +- tests/run/tasty-extractors-2.check | 2 +- tests/run/tasty-extractors-2/quoted_1.scala | 6 +- tests/run/tasty-extractors-3/quoted_1.scala | 4 +- .../quoted_1.scala | 12 ++-- .../run/tasty-extractors-types/quoted_1.scala | 4 +- .../Macro_1.scala | 2 +- tests/run/tasty-indexed-map/quoted_1.scala | 4 +- tests/run/tasty-interpolation-1/Macro.scala | 18 +++--- tests/run/tasty-linenumber-2/quoted_1.scala | 4 +- tests/run/tasty-linenumber/quoted_1.scala | 4 +- tests/run/tasty-location/quoted_1.scala | 6 +- tests/run/tasty-macro-assert/quoted_1.scala | 8 +-- tests/run/tasty-macro-const/quoted_1.scala | 2 +- .../run/tasty-original-source/Macros_1.scala | 4 +- tests/run/tasty-positioned/quoted_1.scala | 6 +- tests/run/tasty-seal-method/quoted_1.scala | 16 ++--- tests/run/tasty-subtyping/quoted_1.scala | 4 +- tests/run/tasty-tree-map/quoted_1.scala | 2 +- tests/run/tasty-typeof/Macro_1.scala | 34 +++++----- .../run/xml-interpolation-1/XmlQuote_1.scala | 8 +-- .../run/xml-interpolation-2/XmlQuote_1.scala | 6 +- .../run/xml-interpolation-3/XmlQuote_1.scala | 4 +- tests/untried/neg/t997.scala | 4 +- 206 files changed, 661 insertions(+), 675 deletions(-) delete mode 100644 tests/pos/spliceTest.scala diff --git a/bench/tests/power-macro/PowerMacro.scala b/bench/tests/power-macro/PowerMacro.scala index 74147d0293d5..aca9c4838284 100644 --- a/bench/tests/power-macro/PowerMacro.scala +++ b/bench/tests/power-macro/PowerMacro.scala @@ -2,11 +2,11 @@ import scala.quoted.Expr object PowerMacro { - inline def power(inline n: Long, x: Double) = ~powerCode(n, '(x)) + inline def power(inline n: Long, x: Double) = ~powerCode(n, '{x}) def powerCode(n: Long, x: Expr[Double]): Expr[Double] = - if (n == 0) '(1.0) - else if (n % 2 == 0) '{ val y = ~x * ~x; ~powerCode(n / 2, '(y)) } + if (n == 0) '{1.0} + else if (n % 2 == 0) '{ val y = ~x * ~x; ~powerCode(n / 2, '{y}) } else '{ ~x * ~powerCode(n - 1, x) } } diff --git a/compiler/test-resources/repl/i5551 b/compiler/test-resources/repl/i5551 index 4e5a0a186a5e..85564f4b1029 100644 --- a/compiler/test-resources/repl/i5551 +++ b/compiler/test-resources/repl/i5551 @@ -3,7 +3,7 @@ scala> import scala.quoted._ scala> def assertImpl(expr: Expr[Boolean]) = '{ if !(~expr) then throw new AssertionError("failed assertion")} def assertImpl(expr: quoted.Expr[Boolean]): quoted.Expr[Unit] -scala> inline def assert(expr: => Boolean): Unit = ~ assertImpl('(expr)) +scala> inline def assert(expr: => Boolean): Unit = ~ assertImpl('{expr}) def assert(expr: => Boolean): Unit scala> assert(0 == 0) diff --git a/tests/disabled/run/i4803d/App_2.scala b/tests/disabled/run/i4803d/App_2.scala index deb7b1151384..9a4926c8c6d7 100644 --- a/tests/disabled/run/i4803d/App_2.scala +++ b/tests/disabled/run/i4803d/App_2.scala @@ -11,7 +11,7 @@ object Test { } inline def power2(x: Double) = { - inline def power(x: Double, inline n: Long) = ~PowerMacro.powerCode('(x), n) + inline def power(x: Double, inline n: Long) = ~PowerMacro.powerCode('{x}, n) power(x, 2) } } diff --git a/tests/disabled/run/i4803d/Macro_1.scala b/tests/disabled/run/i4803d/Macro_1.scala index 681f3b2fac63..b90f101eecf7 100644 --- a/tests/disabled/run/i4803d/Macro_1.scala +++ b/tests/disabled/run/i4803d/Macro_1.scala @@ -2,7 +2,7 @@ import scala.quoted._ object PowerMacro { def powerCode(x: Expr[Double], n: Long): Expr[Double] = - if (n == 0) '(1.0) - else if (n % 2 == 0) '{ val y = ~x * ~x; ~powerCode('(y), n / 2) } - else '{ ~x * ~powerCode(x, n - 1) } + if (n == 0) '{1.0} + else if (n % 2 == 0) '{ val y = $x * $x; ~powerCode('{y}, n / 2) } + else '{ $x * ~powerCode(x, n - 1) } } diff --git a/tests/disabled/run/xml-interpolation-3/XmlQuote_1.scala b/tests/disabled/run/xml-interpolation-3/XmlQuote_1.scala index f99da7d01204..9091d2987bd3 100644 --- a/tests/disabled/run/xml-interpolation-3/XmlQuote_1.scala +++ b/tests/disabled/run/xml-interpolation-3/XmlQuote_1.scala @@ -9,11 +9,11 @@ object XmlQuote { implicit object SCOps { inline def xml(this inline ctx: StringContext)(args: => Any*): Xml = - ~XmlQuote.impl(ctx, '(args)) + ${XmlQuote.impl(ctx, '{args})} } def impl(receiver: StringContext, args: Expr[Seq[Any]]): Expr[Xml] = { val string = receiver.parts.mkString("??") - '(new Xml(~string.toExpr, (~args).toList)) + '{new Xml(${string.toExpr}, ($args).toList)} } } diff --git a/tests/neg-with-compiler/quote-run-in-macro-1/quoted_1.scala b/tests/neg-with-compiler/quote-run-in-macro-1/quoted_1.scala index a9daf7d26556..2546a09b1055 100644 --- a/tests/neg-with-compiler/quote-run-in-macro-1/quoted_1.scala +++ b/tests/neg-with-compiler/quote-run-in-macro-1/quoted_1.scala @@ -3,7 +3,7 @@ import scala.quoted._ import scala.quoted.Toolbox.Default._ object Macros { - inline def foo(i: => Int): Int = ~fooImpl('(i)) + inline def foo(i: => Int): Int = ~fooImpl('{i}) def fooImpl(i: Expr[Int]): Expr[Int] = { val y: Int = i.run y.toExpr diff --git a/tests/neg-with-compiler/quote-run-in-macro-2/quoted_1.scala b/tests/neg-with-compiler/quote-run-in-macro-2/quoted_1.scala index a9daf7d26556..2546a09b1055 100644 --- a/tests/neg-with-compiler/quote-run-in-macro-2/quoted_1.scala +++ b/tests/neg-with-compiler/quote-run-in-macro-2/quoted_1.scala @@ -3,7 +3,7 @@ import scala.quoted._ import scala.quoted.Toolbox.Default._ object Macros { - inline def foo(i: => Int): Int = ~fooImpl('(i)) + inline def foo(i: => Int): Int = ~fooImpl('{i}) def fooImpl(i: Expr[Int]): Expr[Int] = { val y: Int = i.run y.toExpr diff --git a/tests/neg/i4044a.scala b/tests/neg/i4044a.scala index daa64fce9fac..29ec5b53e00e 100644 --- a/tests/neg/i4044a.scala +++ b/tests/neg/i4044a.scala @@ -2,12 +2,12 @@ import scala.quoted._ class Test { - val a = '(1) + val a = '{1} '{ a // error - ~a - '(~a) // error - '( '(~a) ) // error + $a + '{$a} // error + '{ '{$a} } // error } } diff --git a/tests/neg/i4044b.scala b/tests/neg/i4044b.scala index cc44b6fd8a1e..5431b0bc8a6f 100644 --- a/tests/neg/i4044b.scala +++ b/tests/neg/i4044b.scala @@ -4,13 +4,13 @@ class Test { '{ - val b = '(3) + val b = '{3} '{ b // error ~(b) - ~('(b)) // error - '( '(~b) ) // error + ~('{b}) // error + '{ '{$b} } // error } } diff --git a/tests/neg/i4350.scala b/tests/neg/i4350.scala index 968a293424b2..fb40aca02715 100644 --- a/tests/neg/i4350.scala +++ b/tests/neg/i4350.scala @@ -1,5 +1,5 @@ import scala.quoted.Type class Foo[T] { - '(null.asInstanceOf[T]) // error + '{null.asInstanceOf[T]} // error } diff --git a/tests/neg/i4433.scala b/tests/neg/i4433.scala index 1c7eb18d9785..6641fa19849e 100644 --- a/tests/neg/i4433.scala +++ b/tests/neg/i4433.scala @@ -1,7 +1,7 @@ object Foo { - inline def g(inline p: Int => Boolean): Boolean = ~{ // error - if(p(5)) '(true) - else '(false) + inline def g(inline p: Int => Boolean): Boolean = ${ // error + if(p(5)) '{true} + else '{false} } } diff --git a/tests/neg/i4493-b.scala b/tests/neg/i4493-b.scala index 0eab22187f22..aae0ba99230a 100644 --- a/tests/neg/i4493-b.scala +++ b/tests/neg/i4493-b.scala @@ -1,7 +1,7 @@ class Index[K] object Index { - inline def succ[K](x: K): Unit = ~{ // error + inline def succ[K](x: K): Unit = ${ // error implicit val t: quoted.Type[K] = '[K] - '(new Index[K]) + '{new Index[K]} } } diff --git a/tests/neg/i4493.scala b/tests/neg/i4493.scala index 929d13c9e45e..74efc5c99a8a 100644 --- a/tests/neg/i4493.scala +++ b/tests/neg/i4493.scala @@ -1,7 +1,7 @@ class Index[K] object Index { - inline def succ[K]: Unit = ~{ // error + inline def succ[K]: Unit = ${ // error implicit val t: quoted.Type[K] = '[K] - '(new Index[K]) + '{new Index[K]} } } diff --git a/tests/neg/i4774b.scala b/tests/neg/i4774b.scala index 517aa02f9823..3d62fd3deacc 100644 --- a/tests/neg/i4774b.scala +++ b/tests/neg/i4774b.scala @@ -3,9 +3,9 @@ import scala.quoted._ object Test { def loop[T](x: Expr[T])(implicit t: Type[T]): Expr[T] = '{ - val y: ~t = ~x; - ~loop[~t]( // error - '(y) + val y: $t = $x; + ~loop[$t]( // error + '{y} ) } } diff --git a/tests/neg/i4890.scala b/tests/neg/i4890.scala index 2e44839b03ad..54a738f5486d 100644 --- a/tests/neg/i4890.scala +++ b/tests/neg/i4890.scala @@ -3,6 +3,6 @@ import scala.quoted._ object Test { def toExpr(x: Option[String]): Expr[String] = x match { case Some(s) => - '(s) // error + '{s} // error } } diff --git a/tests/neg/inline-macro-staged-interpreter/Macro_1.scala b/tests/neg/inline-macro-staged-interpreter/Macro_1.scala index 3e67577a3874..0da02a108c29 100644 --- a/tests/neg/inline-macro-staged-interpreter/Macro_1.scala +++ b/tests/neg/inline-macro-staged-interpreter/Macro_1.scala @@ -28,6 +28,6 @@ trait Op2[T] { trait Plus2[T] extends Op2[T] object Plus2 { implicit case object IPlus extends Plus2[Int] { - def apply(x: Expr[Int], y: Expr[Int]): Expr[Int] = '(~x + ~y) + def apply(x: Expr[Int], y: Expr[Int]): Expr[Int] = '{$x + $y} } } diff --git a/tests/neg/inline-option/Macro_1.scala b/tests/neg/inline-option/Macro_1.scala index e78b1987f58c..280adb79224c 100644 --- a/tests/neg/inline-option/Macro_1.scala +++ b/tests/neg/inline-option/Macro_1.scala @@ -4,6 +4,6 @@ import scala.quoted._ object Macro { def impl(opt: Option[Int]): Expr[Int] = opt match { case Some(i) => i.toExpr - case None => '(-1) + case None => '{-1} } } \ No newline at end of file diff --git a/tests/neg/quote-0.scala b/tests/neg/quote-0.scala index e6eae3dfe802..5f4299d10682 100644 --- a/tests/neg/quote-0.scala +++ b/tests/neg/quote-0.scala @@ -4,22 +4,22 @@ class Test { val x: Int = 0 - '{ '(x + 1) // error: wrong staging level + '{ '{x + 1} // error: wrong staging level - '((y: Expr[Int]) => ~y ) // error: wrong staging level + '{(y: Expr[Int]) => $y } // error: wrong staging level } - '(x + 1) // error: wrong staging level + '{x + 1} // error: wrong staging level - '((y: Expr[Int]) => ~y ) // error: wrong staging level + '{(y: Expr[Int]) => $y } // error: wrong staging level def f[T](t: Type[T], x: Expr[T]) = '{ - val z2 = ~x // error // error: wrong staging level + val z2 = $x // error // error: wrong staging level } def g[T](implicit t: Type[T], x: Expr[T]) = '{ - val z2 = ~x // ok + val z2 = $x // ok } } diff --git a/tests/neg/quote-MacroOverride.scala b/tests/neg/quote-MacroOverride.scala index cfc0a7ebb374..8467bb1d71db 100644 --- a/tests/neg/quote-MacroOverride.scala +++ b/tests/neg/quote-MacroOverride.scala @@ -6,7 +6,7 @@ object Test { } object B extends A { - inline def f() = ~('()) // error: may not override + inline def f() = ~('{}) // error: may not override override def g() = () // error: may not override } diff --git a/tests/neg/quote-complex-top-splice.scala b/tests/neg/quote-complex-top-splice.scala index 6b0c57a2e51f..2b65baf8d3fb 100644 --- a/tests/neg/quote-complex-top-splice.scala +++ b/tests/neg/quote-complex-top-splice.scala @@ -4,7 +4,7 @@ import scala.quoted._ object Test { - inline def foo1: Unit = ~{ // error + inline def foo1: Unit = ${ // error val x = 1 impl(x) } @@ -19,11 +19,11 @@ object Test { 3 }) - inline def foo4: Unit = ~{ // error + inline def foo4: Unit = ${ // error println("foo4") impl(1) } - def impl(i: Int): Expr[Unit] = '() + def impl(i: Int): Expr[Unit] = '{} } diff --git a/tests/neg/quote-error-2/Macro_1.scala b/tests/neg/quote-error-2/Macro_1.scala index 0cce8284f871..f6507f10e49c 100644 --- a/tests/neg/quote-error-2/Macro_1.scala +++ b/tests/neg/quote-error-2/Macro_1.scala @@ -1,12 +1,12 @@ import quoted._ object Macro_1 { - inline def foo(inline b: Boolean): Unit = ~fooImpl(b) + inline def foo(inline b: Boolean): Unit = ${ fooImpl(b) } def fooImpl(b: Boolean): Expr[Unit] = - '(println(~msg(b))) + '{println(${msg(b)})} def msg(b: Boolean): Expr[String] = - if (b) '("foo(true)") + if (b) '{"foo(true)"} else QuoteError("foo cannot be called with false") } diff --git a/tests/neg/quote-error/Macro_1.scala b/tests/neg/quote-error/Macro_1.scala index d6fbeb9a9ed9..5713a4e3ec2e 100644 --- a/tests/neg/quote-error/Macro_1.scala +++ b/tests/neg/quote-error/Macro_1.scala @@ -1,8 +1,8 @@ import quoted._ object Macro_1 { - inline def foo(inline b: Boolean): Unit = ~fooImpl(b) + inline def foo(inline b: Boolean): Unit = ${fooImpl(b)} def fooImpl(b: Boolean): Expr[Unit] = - if (b) '(println("foo(true)")) + if (b) '{println("foo(true)")} else QuoteError("foo cannot be called with false") } diff --git a/tests/neg/quote-exception/Macro_1.scala b/tests/neg/quote-exception/Macro_1.scala index cd477085e822..721b9d1d97cf 100644 --- a/tests/neg/quote-exception/Macro_1.scala +++ b/tests/neg/quote-exception/Macro_1.scala @@ -1,8 +1,8 @@ import quoted._ object Macro_1 { - inline def foo(inline b: Boolean): Unit = ~fooImpl(b) + inline def foo(inline b: Boolean): Unit = ${fooImpl(b)} def fooImpl(b: Boolean): Expr[Unit] = - if (b) '(println("foo(true)")) + if (b) '{println("foo(true)")} else ??? } diff --git a/tests/neg/quote-interpolator-core-old.scala b/tests/neg/quote-interpolator-core-old.scala index 43eeef3ff95f..6ea1662deef8 100644 --- a/tests/neg/quote-interpolator-core-old.scala +++ b/tests/neg/quote-interpolator-core-old.scala @@ -5,21 +5,21 @@ import scala.quoted._ object FInterpolation { implicit class FInterpolatorHelper(val sc: StringContext) extends AnyVal { - inline def ff(arg1: Any): String = ~fInterpolation(sc, Seq('(arg1))) // error: Inline macro method must be a static method - inline def ff(arg1: Any, arg2: Any): String = ~fInterpolation(sc, Seq('(arg1), '(arg2))) // error: Inline macro method must be a static method - inline def ff(arg1: Any, arg2: Any, arg3: Any): String = ~fInterpolation(sc, Seq('(arg1), '(arg2), '(arg3))) // error: Inline macro method must be a static method + inline def ff(arg1: Any): String = ${fInterpolation(sc, Seq('{arg1}))} // error: Inline macro method must be a static method + inline def ff(arg1: Any, arg2: Any): String = ${fInterpolation(sc, Seq('{arg1}, '{arg2}))} // error: Inline macro method must be a static method + inline def ff(arg1: Any, arg2: Any, arg3: Any): String = ${fInterpolation(sc, Seq('{arg1}, '{arg2}, '{arg3}))} // error: Inline macro method must be a static method // ... } private def liftSeq(args: Seq[Expr[Any]]): Expr[Seq[Any]] = args match { - case x :: xs => '{ (~x) +: ~(liftSeq(xs)) } - case Nil => '(Seq(): Seq[Any]) + case x :: xs => '{ ($x) +: ${liftSeq(xs)} } + case Nil => '{Seq(): Seq[Any]} } def fInterpolation(sc: StringContext, args: Seq[Expr[Any]]): Expr[String] = { val str: Expr[String] = sc.parts.mkString("").toExpr val args1: Expr[Seq[Any]] = liftSeq(args) - '{ (~str).format(~args1: _*) } + '{ $str.format($args1: _*) } } def hello = "hello" diff --git a/tests/neg/quote-macro-2-splices.scala b/tests/neg/quote-macro-2-splices.scala index 30667b3e35d8..5280fb1f6b7b 100644 --- a/tests/neg/quote-macro-2-splices.scala +++ b/tests/neg/quote-macro-2-splices.scala @@ -7,5 +7,5 @@ object Macro { else ~bar(false) } - def bar(b: Boolean): Expr[Int] = if (b) '(1) else '(0) + def bar(b: Boolean): Expr[Int] = if (b) '{1} else '{0} } diff --git a/tests/neg/quote-macro-complex-arg-0.scala b/tests/neg/quote-macro-complex-arg-0.scala index 7afe76ae0fd9..6692590dfc0a 100644 --- a/tests/neg/quote-macro-complex-arg-0.scala +++ b/tests/neg/quote-macro-complex-arg-0.scala @@ -1,6 +1,6 @@ import scala.quoted._ object Macros { - inline def foo(inline i: Int, dummy: Int, j: Int): Int = ~bar(i + 1, '(j)) // error: i + 1 is not a parameter or field reference - def bar(x: Int, y: Expr[Int]): Expr[Int] = '{ ~x.toExpr + ~y } + inline def foo(inline i: Int, dummy: Int, j: Int): Int = ~bar(i + 1, '{j}) // error: i + 1 is not a parameter or field reference + def bar(x: Int, y: Expr[Int]): Expr[Int] = '{ ~{x.toExpr} + $y } } diff --git a/tests/neg/quote-macro-splice.scala b/tests/neg/quote-macro-splice.scala index e854a76a77f7..5747f521e235 100644 --- a/tests/neg/quote-macro-splice.scala +++ b/tests/neg/quote-macro-splice.scala @@ -14,11 +14,11 @@ object Test { inline def foo3: Int = { // error val a = 1 - ~impl('(a)) + ~impl('{a}) } inline def foo4: Int = { // error - ~impl('(1)) + ~impl('{1}) 1 } diff --git a/tests/neg/quote-pcp-in-arg.scala b/tests/neg/quote-pcp-in-arg.scala index c4c49b06b00c..70e2a163bd58 100644 --- a/tests/neg/quote-pcp-in-arg.scala +++ b/tests/neg/quote-pcp-in-arg.scala @@ -1,6 +1,6 @@ import scala.quoted._ object Foo { - inline def foo(x: Int): Int = ~bar('{ '(x); x }) // error + inline def foo(x: Int): Int = ~bar('{ '{x}; x }) // error def bar(i: Expr[Int]): Expr[Int] = i } diff --git a/tests/neg/quote-splice-interpret-1.scala b/tests/neg/quote-splice-interpret-1.scala index 2113ad9f6c2d..1735d6093015 100644 --- a/tests/neg/quote-splice-interpret-1.scala +++ b/tests/neg/quote-splice-interpret-1.scala @@ -2,8 +2,8 @@ import scala.quoted._ object Macros { - inline def isZero(inline n: Int): Boolean = ~{ // error - if (n == 0) '(true) - else '(false) + inline def isZero(inline n: Int): Boolean = ${ // error + if (n == 0) '{true} + else '{false} } } diff --git a/tests/neg/quote-spliceNonStaged.scala b/tests/neg/quote-spliceNonStaged.scala index b328aabac7b9..fe93e73a2bf2 100644 --- a/tests/neg/quote-spliceNonStaged.scala +++ b/tests/neg/quote-spliceNonStaged.scala @@ -3,5 +3,5 @@ import scala.quoted._ object Quotes_1 { def printHello: Expr[Unit] = '{ println("Hello") } - ~printHello // error + $printHello // error } diff --git a/tests/neg/quote-this.scala b/tests/neg/quote-this.scala index b9b2d0034ea3..320de6cebc45 100644 --- a/tests/neg/quote-this.scala +++ b/tests/neg/quote-this.scala @@ -12,11 +12,11 @@ class Foo { } inline def i(): Unit = ~Foo.impl[Any]('{ - '(this) // error + '{this} // error }) inline def j(that: Foo): Unit = ~Foo.impl[Any]('{ - '(that) // error + '{that} // error }) inline def k(): Unit = ~Foo.impl[Any](this) // error @@ -25,5 +25,5 @@ class Foo { } object Foo { - def impl[T](x: Any): Expr[Unit] = '() + def impl[T](x: Any): Expr[Unit] = '{} } diff --git a/tests/neg/splice-in-top-level-splice-1.scala b/tests/neg/splice-in-top-level-splice-1.scala index 6f7f80514561..c5ba06579320 100644 --- a/tests/neg/splice-in-top-level-splice-1.scala +++ b/tests/neg/splice-in-top-level-splice-1.scala @@ -1,7 +1,7 @@ import scala.quoted._ object Foo { - inline def foo(): Int = ~bar(~x) // error - def x: Expr[Int] = '(1) + inline def foo(): Int = ~bar($x) // error + def x: Expr[Int] = '{1} def bar(i: Int): Expr[Int] = i.toExpr } diff --git a/tests/neg/splice-in-top-level-splice-2.scala b/tests/neg/splice-in-top-level-splice-2.scala index 85e60baae56e..a839f02f0bd8 100644 --- a/tests/neg/splice-in-top-level-splice-2.scala +++ b/tests/neg/splice-in-top-level-splice-2.scala @@ -1,6 +1,6 @@ import scala.quoted._ object Foo { - inline def foo(): Int = ~(~x) // error - def x: Expr[Expr[Int]] = '( '(1) ) + inline def foo(): Int = ~($x) // error + def x: Expr[Expr[Int]] = '{ '{1} } } diff --git a/tests/neg/tasty-macro-assert/quoted_1.scala b/tests/neg/tasty-macro-assert/quoted_1.scala index aff13eaf145c..d6a2b7297341 100644 --- a/tests/neg/tasty-macro-assert/quoted_1.scala +++ b/tests/neg/tasty-macro-assert/quoted_1.scala @@ -12,7 +12,7 @@ object Asserts { object Ops inline def macroAssert(cond: => Boolean): Unit = - ~impl('(cond)) + ${impl('{cond})} def impl(cond: Expr[Boolean])(implicit reflect: Reflection): Expr[Unit] = { import reflect._ @@ -34,9 +34,9 @@ object Asserts { tree match { case Term.Inlined(_, Nil, Term.Apply(Term.Select(OpsTree(left), op), right :: Nil)) => - '(assertTrue(~left.seal[Boolean])) // Buggy code. To generate the errors + '{assertTrue(${left.seal[Boolean]})} // Buggy code. To generate the errors case _ => - '(assertTrue(~cond)) + '{assertTrue($cond)} } } diff --git a/tests/pending/run/patmat-exprs.scala b/tests/pending/run/patmat-exprs.scala index 7ca5fd30633f..78e1811169bc 100644 --- a/tests/pending/run/patmat-exprs.scala +++ b/tests/pending/run/patmat-exprs.scala @@ -430,8 +430,8 @@ trait Pattern { case class Div[T](left: Expr[T], right: Expr[T]) (implicit num: NumericOps[T]) extends TwoArg[T] { - // [f(x) / g(x)]' = [f(x) * 1 / g(x)]' = f'(x) * 1 / g(x) + f(x) * [1 / g(x)]' = - // f'(x) / g(x) + f(x) * [-1 / g(x) ^ 2] * g'(x) = (f'(x) * g(x) - f(x) * g'(x)) / g(x)^2 + // [f(x) / g(x)]' = [f(x) * 1 / g(x)]' = f'{x} * 1 / g(x) + f(x) * [1 / g(x)]' = + // f'{x} / g(x) + f(x) * [-1 / g(x) ^ 2] * g'{x} = (f'{x} * g(x) - f(x) * g'{x}) / g(x)^2 def derivative(v: Var[T]) = Div( Sub( @@ -449,7 +449,7 @@ trait Pattern { case class Inv[T](expr: Expr[T])(implicit num: NumericOps[T]) extends OneArg[T] { - // [1 / f(x)]' = - f'(x) / f(x) ^ 2 + // [1 / f(x)]' = - f'{x} / f(x) ^ 2 def derivative(v: Var[T]) = Neg(Div(expr.derivative(v), Sqr(expr))) def eval(f: Any => Any) = num.div(num.one, expr.eval(f)) def mapArgs(f: EndoFunction[Expr[_]]) = Inv(f(expr)) @@ -458,7 +458,7 @@ trait Pattern { } case class Sqr[T](expr: Expr[T])(implicit num: NumericOps[T]) extends OneArg[T] { - // [f(x) ^ 2]' = 2 * f(x) * f'(x) + // [f(x) ^ 2]' = 2 * f(x) * f'{x} def derivative(v: Var[T]) = Mul(Mul(Const(num.two), expr), expr.derivative(v)) def eval(f: Any => Any) = num.sqr(expr.eval(f)) def mapArgs(f: EndoFunction[Expr[_]]) = Sqr(f(expr)) diff --git a/tests/pos-with-compiler/quote-0.scala b/tests/pos-with-compiler/quote-0.scala index 5d0f908f6602..5f3adfa81744 100644 --- a/tests/pos-with-compiler/quote-0.scala +++ b/tests/pos-with-compiler/quote-0.scala @@ -5,20 +5,20 @@ import scala.quoted.Toolbox.Default._ object Macros { inline def assert(expr: => Boolean): Unit = - ~assertImpl('(expr)) + ~assertImpl('{expr}) def assertImpl(expr: Expr[Boolean]) = - '{ if !(~expr) then throw new AssertionError(s"failed assertion: ${~showExpr(expr)}") } + '{ if !($expr) then throw new AssertionError(s"failed assertion: ${~showExpr(expr)}") } def showExpr[T](expr: Expr[T]): Expr[String] = expr.toString.toExpr - inline def power(inline n: Int, x: Double) = ~powerCode(n, '(x)) + inline def power(inline n: Int, x: Double) = ~powerCode(n, '{x}) def powerCode(n: Int, x: Expr[Double]): Expr[Double] = - if (n == 0) '(1.0) + if (n == 0) '{1.0} else if (n == 1) x - else if (n % 2 == 0) '{ { val y = ~x * ~x; ~powerCode(n / 2, '(y)) } } - else '{ ~x * ~powerCode(n - 1, x) } + else if (n % 2 == 0) '{ { val y = $x * $x; ~powerCode(n / 2, '{y}) } } + else '{ $x * ~powerCode(n - 1, x) } } class Test { @@ -29,7 +29,7 @@ class Test { val x = 1 assert(x != 0) - ~assertImpl('(x != 0)) + ~assertImpl('{x != 0}) val y = math.sqrt(2.0) diff --git a/tests/pos-with-compiler/quote-assert/quoted_1.scala b/tests/pos-with-compiler/quote-assert/quoted_1.scala index 7cb0e73f5bc4..3f7bc8c69109 100644 --- a/tests/pos-with-compiler/quote-assert/quoted_1.scala +++ b/tests/pos-with-compiler/quote-assert/quoted_1.scala @@ -2,5 +2,5 @@ import scala.quoted._ object Macros { def assertImpl(expr: Expr[Boolean]) = - '{ if !(~expr) then throw new AssertionError(s"failed assertion: ${~expr}") } + '{ if !($expr) then throw new AssertionError(s"failed assertion: ${$expr}") } } diff --git a/tests/pos-with-compiler/quote-assert/quoted_2.scala b/tests/pos-with-compiler/quote-assert/quoted_2.scala index 45a955b0648f..1b7f35fd7a25 100644 --- a/tests/pos-with-compiler/quote-assert/quoted_2.scala +++ b/tests/pos-with-compiler/quote-assert/quoted_2.scala @@ -5,14 +5,14 @@ import Macros._ object Test { inline def assert(expr: => Boolean): Unit = - ~ assertImpl('(expr)) + ~ assertImpl('{expr}) val program = '{ val x = 1 assert(x != 0) - ~assertImpl('(x != 0)) + ~assertImpl('{x != 0}) } program.run diff --git a/tests/pos/i3898/quoted_1.scala b/tests/pos/i3898/quoted_1.scala index 61fa38781138..6b30fce3910d 100644 --- a/tests/pos/i3898/quoted_1.scala +++ b/tests/pos/i3898/quoted_1.scala @@ -1,5 +1,5 @@ import scala.quoted._ object Macro { - inline def ff(args: Any*): String = ~impl('(args)) - def impl(args: Expr[Seq[Any]]): Expr[String] = '("") + inline def ff(args: Any*): String = ~impl('{args}) + def impl(args: Expr[Seq[Any]]): Expr[String] = '{""} } diff --git a/tests/pos/i3898b/quoted_1.scala b/tests/pos/i3898b/quoted_1.scala index fb2072ab4cb9..3d0f8a2f26d7 100644 --- a/tests/pos/i3898b/quoted_1.scala +++ b/tests/pos/i3898b/quoted_1.scala @@ -1,5 +1,5 @@ import scala.quoted._ object Macro { - inline def ff(x: Int, inline y: Int): String = ~impl('(x)) - def impl(x: Expr[Int]): Expr[String] = '("") + inline def ff(x: Int, inline y: Int): String = ~impl('{x}) + def impl(x: Expr[Int]): Expr[String] = '{""} } diff --git a/tests/pos/i3898c/quoted_1.scala b/tests/pos/i3898c/quoted_1.scala index fb2072ab4cb9..3d0f8a2f26d7 100644 --- a/tests/pos/i3898c/quoted_1.scala +++ b/tests/pos/i3898c/quoted_1.scala @@ -1,5 +1,5 @@ import scala.quoted._ object Macro { - inline def ff(x: Int, inline y: Int): String = ~impl('(x)) - def impl(x: Expr[Int]): Expr[String] = '("") + inline def ff(x: Int, inline y: Int): String = ~impl('{x}) + def impl(x: Expr[Int]): Expr[String] = '{""} } diff --git a/tests/pos/i3912-1/i3912_1.scala b/tests/pos/i3912-1/i3912_1.scala index 80faaf976743..998a9c159756 100644 --- a/tests/pos/i3912-1/i3912_1.scala +++ b/tests/pos/i3912-1/i3912_1.scala @@ -3,5 +3,5 @@ import scala.quoted._ object Macros { inline def foo(): Int = { ~impl() } - def impl(): Expr[Int] = '(1) + def impl(): Expr[Int] = '{1} } \ No newline at end of file diff --git a/tests/pos/i3912-2/i3912_1.scala b/tests/pos/i3912-2/i3912_1.scala index e3d1ba91df37..10702302c413 100644 --- a/tests/pos/i3912-2/i3912_1.scala +++ b/tests/pos/i3912-2/i3912_1.scala @@ -3,5 +3,5 @@ import scala.quoted._ object Macros { inline def foo2(): Unit = ~impl() - def impl(): Expr[Int] = '(1) + def impl(): Expr[Int] = '{1} } \ No newline at end of file diff --git a/tests/pos/i3912-3/i3912_1.scala b/tests/pos/i3912-3/i3912_1.scala index a544cfd26282..187dd90ff551 100644 --- a/tests/pos/i3912-3/i3912_1.scala +++ b/tests/pos/i3912-3/i3912_1.scala @@ -7,5 +7,5 @@ object Macros { } } - def impl(): Expr[Int] = '(1) + def impl(): Expr[Int] = '{1} } \ No newline at end of file diff --git a/tests/pos/i4023/Macro_1.scala b/tests/pos/i4023/Macro_1.scala index b51c1de87b2e..546b28fb9a76 100644 --- a/tests/pos/i4023/Macro_1.scala +++ b/tests/pos/i4023/Macro_1.scala @@ -1,5 +1,5 @@ import scala.quoted._ object Macro { - inline def ff[T: Type](x: T): T = ~impl('(x)) + inline def ff[T: Type](x: T): T = ${ impl('{x}) } def impl[T](x: Expr[T]): Expr[T] = x } diff --git a/tests/pos/i4023b/Macro_1.scala b/tests/pos/i4023b/Macro_1.scala index e440b4e1923a..7fbb9f6429d8 100644 --- a/tests/pos/i4023b/Macro_1.scala +++ b/tests/pos/i4023b/Macro_1.scala @@ -1,5 +1,5 @@ import scala.quoted._ object Macro { inline def ff[T](implicit t: Type[T]): Int = ~impl[T] - def impl[T]: Expr[Int] = '(4) + def impl[T]: Expr[Int] = '{4} } diff --git a/tests/pos/i4023c/Macro_1.scala b/tests/pos/i4023c/Macro_1.scala index 5888856ff83e..eda769b8dd8f 100644 --- a/tests/pos/i4023c/Macro_1.scala +++ b/tests/pos/i4023c/Macro_1.scala @@ -1,5 +1,5 @@ import scala.quoted._ object Macro { - inline def ff[T](x: T): T = ~impl('(x))('[T]) - def impl[T](x: Expr[T])(implicit t: Type[T]): Expr[T] = '{ (~x): ~t } + inline def ff[T](x: T): T = ${ impl('{x})('[T]) } + def impl[T](x: Expr[T])(implicit t: Type[T]): Expr[T] = '{ $x: $t } } diff --git a/tests/pos/i4350.scala b/tests/pos/i4350.scala index 7c6a82145cc9..46616bbcff10 100644 --- a/tests/pos/i4350.scala +++ b/tests/pos/i4350.scala @@ -1,5 +1,5 @@ import scala.quoted.Type class Foo[T: Type] { - '(null.asInstanceOf[T]) + '{null.asInstanceOf[T]} } diff --git a/tests/pos/i4380b.scala b/tests/pos/i4380b.scala index b305780e0843..ab8fff08c9fd 100644 --- a/tests/pos/i4380b.scala +++ b/tests/pos/i4380b.scala @@ -1,8 +1,8 @@ import scala.quoted._ object Test { - def step(k: (String => Expr[Unit])): Expr[Unit] = '() + def step(k: (String => Expr[Unit])): Expr[Unit] = '{} def meth(): Unit = '{ - (i: Int) => ~step(el => '() ) + (i: Int) => ~step(el => '{} ) } } diff --git a/tests/pos/i4396a.scala b/tests/pos/i4396a.scala index 0a69f685f986..294783b91eec 100644 --- a/tests/pos/i4396a.scala +++ b/tests/pos/i4396a.scala @@ -1,3 +1,3 @@ class Test { - '(Option(4) match { case Some(a) => a; case None => 1 }) + '{ Option(4) match { case Some(a) => a; case None => 1 }} } \ No newline at end of file diff --git a/tests/pos/i4493-c.scala b/tests/pos/i4493-c.scala index 08327e5fa81a..3ced80d53e22 100644 --- a/tests/pos/i4493-c.scala +++ b/tests/pos/i4493-c.scala @@ -1,6 +1,6 @@ class Index[K] object Index { - inline def succ[K]: Unit = ~{ - '(new Index[K]) + inline def succ[K]: Unit = ${ + '{new Index[K]} } } diff --git a/tests/pos/i4514.scala b/tests/pos/i4514.scala index 0da1e9af33f7..b7922db64445 100644 --- a/tests/pos/i4514.scala +++ b/tests/pos/i4514.scala @@ -1,4 +1,4 @@ object Foo { - inline def foo[X](x: X): Unit = ~fooImpl('(x)) - def fooImpl[X: quoted.Type](x: X): quoted.Expr[Unit] = '() + inline def foo[X](x: X): Unit = ~fooImpl('{x}) + def fooImpl[X: quoted.Type](x: X): quoted.Expr[Unit] = '{} } diff --git a/tests/pos/i4734/Macro_1.scala b/tests/pos/i4734/Macro_1.scala index ecc8357c3d4b..03bd4117dc01 100644 --- a/tests/pos/i4734/Macro_1.scala +++ b/tests/pos/i4734/Macro_1.scala @@ -3,10 +3,10 @@ import scala.quoted._ object Macros { inline def unrolledForeach(f: Int => Int): Int = - ~unrolledForeachImpl('(f)) + ~unrolledForeachImpl('{f}) def unrolledForeachImpl(f: Expr[Int => Int]): Expr[Int] = '{ val size: Int = 5 - (~f)(3) + ($f)(3) } } diff --git a/tests/pos/i4773.scala b/tests/pos/i4773.scala index b829f25c0e33..5dbccb5b7b19 100644 --- a/tests/pos/i4773.scala +++ b/tests/pos/i4773.scala @@ -2,6 +2,6 @@ import scala.quoted._ object Foo { inline def foo2(): Unit = ~foo2Impl() - def foo2Impl(): Expr[Unit] = '() + def foo2Impl(): Expr[Unit] = '{} inline def foo(): Unit = foo2() } diff --git a/tests/pos/i4774a.scala b/tests/pos/i4774a.scala index 6a1f6ec0588e..4f1535272a20 100644 --- a/tests/pos/i4774a.scala +++ b/tests/pos/i4774a.scala @@ -3,7 +3,7 @@ import scala.quoted._ object Test { def loop[T](x: Expr[T])(implicit t: Type[T]): Expr[T] = '{ - val y: ~t = ~x - ~loop('(y)) + val y: $t = $x + ~loop('{y}) } } diff --git a/tests/pos/i4774c.scala b/tests/pos/i4774c.scala index 8282616259d3..55be40815fdd 100644 --- a/tests/pos/i4774c.scala +++ b/tests/pos/i4774c.scala @@ -2,5 +2,5 @@ import scala.quoted._ object Test { - def loop[T](x: Expr[T])(implicit t: Type[T]): Expr[T] = '{ val y = ~x; ~loop('(y)) } + def loop[T](x: Expr[T])(implicit t: Type[T]): Expr[T] = '{ val y = $x; ~loop('{y}) } } diff --git a/tests/pos/i4774d.scala b/tests/pos/i4774d.scala index 2a17e34b4f8f..bc945397f11b 100644 --- a/tests/pos/i4774d.scala +++ b/tests/pos/i4774d.scala @@ -3,5 +3,5 @@ import scala.quoted._ object Test { def loop[T](x: Expr[T])(implicit t: Type[T]): Expr[T] = - '{ val y: T = ~x; ~loop('(y)) } + '{ val y: T = $x; ~loop('{y}) } } diff --git a/tests/pos/i4846.scala b/tests/pos/i4846.scala index c97c21777218..53c5c64e4d9f 100644 --- a/tests/pos/i4846.scala +++ b/tests/pos/i4846.scala @@ -1,6 +1,6 @@ import scala.quoted._ object Test { - inline def foo(inline x: Int): Int = ~fooImpl(x, '(x), '( '(x) ), '( '( '(x) ) )) + inline def foo(inline x: Int): Int = ~fooImpl(x, '{x}, '{ '{x} }, '{ '{ '{x} } }) def fooImpl(a: Int, b: Expr[Int], c: Expr[Expr[Int]], d: Expr[Expr[Expr[Int]]]): Expr[Int] = ??? } diff --git a/tests/pos/i4891.scala b/tests/pos/i4891.scala index e59e57968765..cf2189093280 100644 --- a/tests/pos/i4891.scala +++ b/tests/pos/i4891.scala @@ -1,5 +1,5 @@ import scala.quoted._ object Test { - def foo: Expr[Option[String]] = '(None) + def foo: Expr[Option[String]] = '{None} } diff --git a/tests/pos/macro-with-array/Macro_1.scala b/tests/pos/macro-with-array/Macro_1.scala index a115aa3dc036..a0fb439faca5 100644 --- a/tests/pos/macro-with-array/Macro_1.scala +++ b/tests/pos/macro-with-array/Macro_1.scala @@ -1,29 +1,29 @@ object Macro { - inline def foo0(i: Int): Unit = ~{ '() } - inline def foo1(arr: Array[Boolean]): Unit = ~{ '() } - inline def foo2(arr: Array[Byte]): Unit = ~{ '() } - inline def foo3(arr: Array[Short]): Unit = ~{ '() } - inline def foo4(arr: Array[Int]): Unit = ~{ '() } - inline def foo5(arr: Array[Long]): Unit = ~{ '() } - inline def foo6(arr: Array[Float]): Unit = ~{ '() } - inline def foo7(arr: Array[Double]): Unit = ~{ '() } - inline def foo8(arr: Array[Char]): Unit = ~{ '() } - inline def foo9(arr: Array[Object]): Unit = ~{ '() } - inline def foo10(arr: Array[String]): Unit = ~{ '() } - inline def foo11[T](arr: Array[T]): Unit = ~{ '() } - inline def foo12(arr: Array[Array[Int]]): Unit = ~{ '() } - inline def foo13(arr: Array[Array[String]]): Unit = ~{ '() } - inline def foo14(arr: Array[Array[Array[Int]]]): Unit = ~{ '() } - inline def foo15(arr: Array[Any]): Unit = ~{ '() } - inline def foo16(arr: Array[AnyVal]): Unit = ~{ '() } - inline def foo17(arr: Array[AnyRef]): Unit = ~{ '() } - inline def foo18(arr: Array[Foo]): Unit = ~{ '() } - inline def foo19(arr: Array[Macro.type]): Unit = ~{ '() } - inline def foo20(arr: Array[Bar]): Unit = ~{ '() } - inline def foo21(arr: Array[Baz.type]): Unit = ~{ '() } - inline def foo22(arr: Array[Foo#A]): Unit = ~{ '() } + inline def foo0(i: Int): Unit = ${ '{} } + inline def foo1(arr: Array[Boolean]): Unit = ${ '{} } + inline def foo2(arr: Array[Byte]): Unit = ${ '{} } + inline def foo3(arr: Array[Short]): Unit = ${ '{} } + inline def foo4(arr: Array[Int]): Unit = ${ '{} } + inline def foo5(arr: Array[Long]): Unit = ${ '{} } + inline def foo6(arr: Array[Float]): Unit = ${ '{} } + inline def foo7(arr: Array[Double]): Unit = ${ '{} } + inline def foo8(arr: Array[Char]): Unit = ${ '{} } + inline def foo9(arr: Array[Object]): Unit = ${ '{} } + inline def foo10(arr: Array[String]): Unit = ${ '{} } + inline def foo11[T](arr: Array[T]): Unit = ${ '{} } + inline def foo12(arr: Array[Array[Int]]): Unit = ${ '{} } + inline def foo13(arr: Array[Array[String]]): Unit = ${ '{} } + inline def foo14(arr: Array[Array[Array[Int]]]): Unit = ${ '{} } + inline def foo15(arr: Array[Any]): Unit = ${ '{} } + inline def foo16(arr: Array[AnyVal]): Unit = ${ '{} } + inline def foo17(arr: Array[AnyRef]): Unit = ${ '{} } + inline def foo18(arr: Array[Foo]): Unit = ${ '{} } + inline def foo19(arr: Array[Macro.type]): Unit = ${ '{} } + inline def foo20(arr: Array[Bar]): Unit = ${ '{} } + inline def foo21(arr: Array[Baz.type]): Unit = ${ '{} } + inline def foo22(arr: Array[Foo#A]): Unit = ${ '{} } class Bar object Baz diff --git a/tests/pos/macro-with-type/Macro_1.scala b/tests/pos/macro-with-type/Macro_1.scala index f6da5bf47794..72eb9fee3978 100644 --- a/tests/pos/macro-with-type/Macro_1.scala +++ b/tests/pos/macro-with-type/Macro_1.scala @@ -1,5 +1,5 @@ import scala.quoted._ object Macro { inline def ff: Unit = ~impl('[Int]) - def impl(t: Type[Int]): Expr[Unit] = '() + def impl(t: Type[Int]): Expr[Unit] = '{} } diff --git a/tests/pos/power-macro/Macro_1.scala b/tests/pos/power-macro/Macro_1.scala index e279c7efd180..59b7f7731b09 100644 --- a/tests/pos/power-macro/Macro_1.scala +++ b/tests/pos/power-macro/Macro_1.scala @@ -3,10 +3,10 @@ import scala.quoted.Expr object PowerMacro { - inline def power(inline n: Long, x: Double) = ~powerCode(n, '(x)) + inline def power(inline n: Long, x: Double) = ~powerCode(n, '{x}) def powerCode(n: Long, x: Expr[Double]): Expr[Double] = - if (n == 0) '(1.0) - else if (n % 2 == 0) '{ { val y = ~x * ~x; ~powerCode(n / 2, '(y)) } } - else '{ ~x * ~powerCode(n - 1, x) } + if (n == 0) '{1.0} + else if (n % 2 == 0) '{ { val y = $x * $x; ~powerCode(n / 2, '{y}) } } + else '{ $x * ~powerCode(n - 1, x) } } diff --git a/tests/pos/quote-1.scala b/tests/pos/quote-1.scala index 669a0037b6bf..006c0562dbee 100644 --- a/tests/pos/quote-1.scala +++ b/tests/pos/quote-1.scala @@ -4,13 +4,13 @@ object Test { def f[T](x: Expr[T])(implicit t: Type[T]) = '{ val y: t.unary_~ = x.unary_~ - val z = ~x + val z = $x } - f('(2))('[Int]) + f('{2})('[Int]) f('{ true })('[Boolean]) def g(es: Expr[String], t: Type[String]) = - f('{ (~es + "!") :: Nil })('[List[~t]]) + f('{ ($es + "!") :: Nil })('[List[$t]]) } diff --git a/tests/pos/quote-lift-inline-params-b.scala b/tests/pos/quote-lift-inline-params-b.scala index 8bfed3e7436a..49507ffa9d27 100644 --- a/tests/pos/quote-lift-inline-params-b.scala +++ b/tests/pos/quote-lift-inline-params-b.scala @@ -1,7 +1,7 @@ import scala.quoted.Expr import quoted.Liftable.{IntIsLiftable => _} object Macro { - inline def foo(inline n: Int): Int = ~{ - '(n) + inline def foo(inline n: Int): Int = ${ + '{n} } } \ No newline at end of file diff --git a/tests/pos/quote-lift-inline-params/Macro_1.scala b/tests/pos/quote-lift-inline-params/Macro_1.scala index 953cff392ca2..19c8b65384e1 100644 --- a/tests/pos/quote-lift-inline-params/Macro_1.scala +++ b/tests/pos/quote-lift-inline-params/Macro_1.scala @@ -1,7 +1,7 @@ import scala.quoted.Expr object Macro { import quoted.Liftable.{IntIsLiftable => _} - inline def foo(inline n: Int): Int = ~{ - '(n) + inline def foo(inline n: Int): Int = ${ + '{n} } } \ No newline at end of file diff --git a/tests/pos/quote-lift.scala b/tests/pos/quote-lift.scala index 1ec60672d34d..716631a6bace 100644 --- a/tests/pos/quote-lift.scala +++ b/tests/pos/quote-lift.scala @@ -9,7 +9,7 @@ object Test { '{ ~IntIsLiftable.toExpr(1) } - '{ ~1.toExpr } + '{ ${1.toExpr} } } diff --git a/tests/pos/quote-liftable.scala b/tests/pos/quote-liftable.scala index 2edb101fdaa9..8b031f208498 100644 --- a/tests/pos/quote-liftable.scala +++ b/tests/pos/quote-liftable.scala @@ -4,23 +4,23 @@ object Test { implicit def IntIsLiftable: Liftable[Int] = new { def toExpr(n: Int): Expr[Int] = n match { - case Int.MinValue => '(Int.MinValue) - case _ if n < 0 => '(-(~toExpr(n))) - case 0 => '(0) - case _ if n % 2 == 0 => '( ~toExpr(n / 2) * 2) - case _ => '( ~toExpr(n / 2) * 2 + 1) + case Int.MinValue => '{Int.MinValue} + case _ if n < 0 => '{- ${toExpr(n)}} + case 0 => '{0} + case _ if n % 2 == 0 => '{ ${toExpr(n / 2)} * 2 } + case _ => '{ ${toExpr(n / 2)} * 2 + 1 } } } implicit def BooleanIsLiftable: Liftable[Boolean] = new { implicit def toExpr(b: Boolean) = - if (b) '(true) else '(false) + if (b) '{true} else '{false} } implicit def ListIsLiftable[T: Liftable: Type]: Liftable[List[T]] = new { def toExpr(xs: List[T]): Expr[List[T]] = xs match { - case x :: xs1 => '{ ~implicitly[Liftable[T]].toExpr(x) :: ~toExpr(xs1) } - case Nil => '(Nil: List[T]) + case x :: xs1 => '{ ${ implicitly[Liftable[T]].toExpr(x) } :: ${ toExpr(xs1) } } + case Nil => '{Nil: List[T]} } } diff --git a/tests/pos/quote-nested-object/Macro_1.scala b/tests/pos/quote-nested-object/Macro_1.scala index a24a6dd3f376..34e59e4e09d1 100644 --- a/tests/pos/quote-nested-object/Macro_1.scala +++ b/tests/pos/quote-nested-object/Macro_1.scala @@ -6,19 +6,19 @@ object Macro { object Implementation { - inline def plus(inline n: Int, m: Int): Int = ~plus(n, '(m)) + inline def plus(inline n: Int, m: Int): Int = ~plus(n, '{m}) def plus(n: Int, m: Expr[Int]): Expr[Int] = if (n == 0) m - else '{ ~n.toExpr + ~m } + else '{ ~{n.toExpr} + $m } object Implementation2 { - inline def plus(inline n: Int, m: Int): Int = ~plus(n, '(m)) + inline def plus(inline n: Int, m: Int): Int = ~plus(n, '{m}) def plus(n: Int, m: Expr[Int]): Expr[Int] = if (n == 0) m - else '{ ~n.toExpr + ~m } + else '{ ${n.toExpr} + $m } } } diff --git a/tests/pos/quote-non-static-macro.scala b/tests/pos/quote-non-static-macro.scala index a6043b2d10f1..706c4ee59fc6 100644 --- a/tests/pos/quote-non-static-macro.scala +++ b/tests/pos/quote-non-static-macro.scala @@ -14,5 +14,5 @@ object Foo { object Quox { inline def foo: Unit = ~Foo.impl } - def impl: Expr[Unit] = '() + def impl: Expr[Unit] = '{} } diff --git a/tests/pos/quote-this.scala b/tests/pos/quote-this.scala index 2472188ce2b3..197d3e44e31b 100644 --- a/tests/pos/quote-this.scala +++ b/tests/pos/quote-this.scala @@ -1,28 +1,28 @@ import scala.quoted._ class Foo { - def a: Expr[Int] = '(1) + def a: Expr[Int] = '{1} def b: Expr[Int] = '{ - ~this.a + ${ this.a } } - def d: Expr[Expr[Int]] = '{ '(1) } + def d: Expr[Expr[Int]] = '{ '{1} } def e: Expr[Expr[Int]] = '{ - '( ~(~this.d) ) + '{${${this.d}}} } def foo[T](x: T): T = x def f = '{ - ~foo[this.type](this).a + ${ foo[this.type](this).a } } - inline def g(): Unit = ~Foo.impl[this.type](1) - inline def h(): Unit = ~Foo.impl[Any]('(this)) - inline def i(that: Foo): Unit = ~Foo.impl[that.type](1) + inline def g(): Unit = ${ Foo.impl[this.type](1) } + inline def h(): Unit = ${ Foo.impl[Any]('{this}) } + inline def i(that: Foo): Unit = ${ Foo.impl[that.type](1) } } object Foo { - def impl[T](x: Any): Expr[Unit] = '() + def impl[T](x: Any): Expr[Unit] = '{} } diff --git a/tests/pos/spliceTest.scala b/tests/pos/spliceTest.scala deleted file mode 100644 index c04afdcecb57..000000000000 --- a/tests/pos/spliceTest.scala +++ /dev/null @@ -1,14 +0,0 @@ -class Expr[T] { - def unary_~ : T = ??? -} -class Type[T] { - type unary_~ = T -} -object Test { - - def f[T](t: Type[T], x: Expr[T]) = { - val y: t.unary_~ = x.unary_~ - val z: ~t = ~x - } - -} diff --git a/tests/pos/t4579.scala b/tests/pos/t4579.scala index 500ffae40200..5f6d6d12a3aa 100644 --- a/tests/pos/t4579.scala +++ b/tests/pos/t4579.scala @@ -7,7 +7,7 @@ class LispTokenizer(s: String) extends Iterator[String] { private var i = 0; - private def isDelimiter(ch: Char) = ch <= ' ' || ch == '(' || ch == ')' + private def isDelimiter(ch: Char) = ch <= ' ' || ch == '{' || ch == '}' def hasNext: Boolean = { while (i < s.length() && s.charAt(i) <= ' ') i += 1 i < s.length() @@ -459,11 +459,11 @@ class LispUser(lisp: Lisp) { Console.println(lisp2string(string2lisp("(lambda (x) (+ (* x x) 1))"))); Console.println(); - Console.println("( '(1 2 3)) = " + evaluate(" (quote(1 2 3))")); - Console.println("(car '(1 2 3)) = " + evaluate("(car (quote(1 2 3)))")); - Console.println("(cdr '(1 2 3)) = " + evaluate("(cdr (quote(1 2 3)))")); - Console.println("(null? '(2 3)) = " + evaluate("(null? (quote(2 3)))")); - Console.println("(null? '()) = " + evaluate("(null? (quote()))")); + Console.println("( '{1 2 3}) = " + evaluate(" (quote(1 2 3))")); + Console.println("(car '{1 2 3}) = " + evaluate("(car (quote(1 2 3)))")); + Console.println("(cdr '{1 2 3}) = " + evaluate("(cdr (quote(1 2 3)))")); + Console.println("(null? '{2 3}) = " + evaluate("(null? (quote(2 3)))")); + Console.println("(null? '{}) = " + evaluate("(null? (quote()))")); Console.println(); Console.println("faculty(10) = " + evaluate( diff --git a/tests/run-custom-args/Yretain-trees/tasty-definitions-2/Macro_1.scala b/tests/run-custom-args/Yretain-trees/tasty-definitions-2/Macro_1.scala index dd9aa5a6d917..1ce3115c1f19 100644 --- a/tests/run-custom-args/Yretain-trees/tasty-definitions-2/Macro_1.scala +++ b/tests/run-custom-args/Yretain-trees/tasty-definitions-2/Macro_1.scala @@ -4,7 +4,7 @@ import scala.tasty._ object Foo { inline def inspectBody(i: => Int): String = - ~inspectBodyImpl('(i)) + ${ inspectBodyImpl('{i}) } def inspectBodyImpl(x: Expr[Int])(implicit reflect: Reflection): Expr[String] = { import reflect._ diff --git a/tests/run-custom-args/Yretain-trees/tasty-definitions-3/Macro_1.scala b/tests/run-custom-args/Yretain-trees/tasty-definitions-3/Macro_1.scala index 6cef0ad48ab5..5c8a70abad71 100644 --- a/tests/run-custom-args/Yretain-trees/tasty-definitions-3/Macro_1.scala +++ b/tests/run-custom-args/Yretain-trees/tasty-definitions-3/Macro_1.scala @@ -4,7 +4,7 @@ import scala.tasty._ object Foo { inline def inspectBody(i: => Int): String = - ~inspectBodyImpl('(i)) + ${ inspectBodyImpl('{i}) } def inspectBodyImpl(x: Expr[Int])(implicit reflect: Reflection): Expr[String] = { import reflect._ diff --git a/tests/run-custom-args/Yretain-trees/tasty-extractors-owners/quoted_1.scala b/tests/run-custom-args/Yretain-trees/tasty-extractors-owners/quoted_1.scala index 29e8aac4c1b8..65f98e5806f7 100644 --- a/tests/run-custom-args/Yretain-trees/tasty-extractors-owners/quoted_1.scala +++ b/tests/run-custom-args/Yretain-trees/tasty-extractors-owners/quoted_1.scala @@ -5,7 +5,7 @@ import scala.tasty._ object Macros { implicit inline def printOwners[T](x: => T): Unit = - ~impl('(x)) + ~impl('{x}) def impl[T](x: Expr[T])(implicit reflect: Reflection): Expr[Unit] = { import reflect._ @@ -42,7 +42,7 @@ object Macros { val tree = x.unseal output.traverseTree(tree) - '(print(~buff.result().toExpr)) + '{print(${buff.result().toExpr})} } } diff --git a/tests/run-custom-args/Yretain-trees/tasty-load-tree-1.check b/tests/run-custom-args/Yretain-trees/tasty-load-tree-1.check index fa4dada79aef..042dfe094ee8 100644 --- a/tests/run-custom-args/Yretain-trees/tasty-load-tree-1.check +++ b/tests/run-custom-args/Yretain-trees/tasty-load-tree-1.check @@ -1,2 +1,2 @@ DefDef("foo", Nil, Nil, TypeTree.Ident("Int"), Some(Term.Apply(Term.Select(Term.Literal(Constant.Int(1)), "+"), List(Term.Literal(Constant.Int(2)))))) -ValDef("bar", TypeTree.Ident("Int"), Some(Term.Apply(Term.Select(Term.Literal(Constant.Int(2)), "+"), List(Term.Literal(Constant.Int(3)))))) +NO DEFINTION diff --git a/tests/run-custom-args/Yretain-trees/tasty-load-tree-1/quoted_1.scala b/tests/run-custom-args/Yretain-trees/tasty-load-tree-1/quoted_1.scala index 23d98063465b..c367f49666aa 100644 --- a/tests/run-custom-args/Yretain-trees/tasty-load-tree-1/quoted_1.scala +++ b/tests/run-custom-args/Yretain-trees/tasty-load-tree-1/quoted_1.scala @@ -5,7 +5,7 @@ import scala.tasty._ object Foo { inline def inspectBody(i: => Int): String = - ~inspectBodyImpl('(i)) + ~inspectBodyImpl('{i}) def inspectBodyImpl(x: Expr[Int])(implicit reflect: Reflection): Expr[String] = { import reflect._ @@ -14,7 +14,7 @@ object Foo { case IsClassSymbol(sym) => sym.tree.show.toExpr case IsDefSymbol(sym) => sym.tree.show.toExpr case IsValSymbol(sym) => sym.tree.show.toExpr - case _ => '("NO DEFINTION") + case _ => '{"NO DEFINTION"} } x.unseal match { diff --git a/tests/run-custom-args/Yretain-trees/tasty-load-tree-2.check b/tests/run-custom-args/Yretain-trees/tasty-load-tree-2.check index fa4dada79aef..042dfe094ee8 100644 --- a/tests/run-custom-args/Yretain-trees/tasty-load-tree-2.check +++ b/tests/run-custom-args/Yretain-trees/tasty-load-tree-2.check @@ -1,2 +1,2 @@ DefDef("foo", Nil, Nil, TypeTree.Ident("Int"), Some(Term.Apply(Term.Select(Term.Literal(Constant.Int(1)), "+"), List(Term.Literal(Constant.Int(2)))))) -ValDef("bar", TypeTree.Ident("Int"), Some(Term.Apply(Term.Select(Term.Literal(Constant.Int(2)), "+"), List(Term.Literal(Constant.Int(3)))))) +NO DEFINTION diff --git a/tests/run-custom-args/Yretain-trees/tasty-load-tree-2/quoted_1.scala b/tests/run-custom-args/Yretain-trees/tasty-load-tree-2/quoted_1.scala index 5729eb2822ec..5b76aa58918f 100644 --- a/tests/run-custom-args/Yretain-trees/tasty-load-tree-2/quoted_1.scala +++ b/tests/run-custom-args/Yretain-trees/tasty-load-tree-2/quoted_1.scala @@ -5,7 +5,7 @@ import scala.tasty._ object Foo { inline def inspectBody(i: => Int): String = - ~inspectBodyImpl('(i)) + ~inspectBodyImpl('{i}) def inspectBodyImpl(x: Expr[Int])(implicit reflect: Reflection): Expr[String] = { import reflect._ @@ -14,7 +14,7 @@ object Foo { case IsClassSymbol(sym) => sym.tree.show.toExpr case IsDefSymbol(sym) => sym.tree.show.toExpr case IsValSymbol(sym) => sym.tree.show.toExpr - case _ => '("NO DEFINTION") + case _ => '{"NO DEFINTION"} } x.unseal match { diff --git a/tests/run-with-compiler-custom-args/staged-streams_1.scala b/tests/run-with-compiler-custom-args/staged-streams_1.scala index 775b2856541d..42948d34b45f 100644 --- a/tests/run-with-compiler-custom-args/staged-streams_1.scala +++ b/tests/run-with-compiler-custom-args/staged-streams_1.scala @@ -17,7 +17,7 @@ object Test { var x = ~init ~body( new Var[T] { - def get: Expr[T] = '(x) + def get: Expr[T] = '{x} def update(e: Expr[T]): Expr[Unit] = '{ x = ~e } } ) @@ -508,7 +508,7 @@ object Test { var el = ~current.get val f: Unit => Unit = ~nadv.get f(()) - ~k('(el)) + ~k('{el}) } } @@ -606,7 +606,7 @@ object Test { '{ val el = (~arr).apply(~i.get) ~i.update('{ ~i.get + 1 }) - ~k('(el)) + ~k('{el}) } } diff --git a/tests/run-with-compiler/i3823-b.scala b/tests/run-with-compiler/i3823-b.scala index cdb5c4eb3bd9..51f13b739e6f 100644 --- a/tests/run-with-compiler/i3823-b.scala +++ b/tests/run-with-compiler/i3823-b.scala @@ -5,6 +5,6 @@ object Test { def f[T](x: Expr[T])(implicit t: Type[T]) = '{ val z: t.unary_~ = ~x } - println(f('(2))(Type.IntTag).show) + println(f('{2})(Type.IntTag).show) } } \ No newline at end of file diff --git a/tests/run-with-compiler/i3823-c.scala b/tests/run-with-compiler/i3823-c.scala index 976ac729987f..df1009cd5857 100644 --- a/tests/run-with-compiler/i3823-c.scala +++ b/tests/run-with-compiler/i3823-c.scala @@ -5,7 +5,7 @@ object Test { def f[T](x: Expr[T])(implicit t: Type[T]) = '{ val z = ~x } - println(f('(2))(Type.IntTag).show) + println(f('{2})(Type.IntTag).show) } } diff --git a/tests/run-with-compiler/i3823.scala b/tests/run-with-compiler/i3823.scala index dc593a1e1715..111de3c0e232 100644 --- a/tests/run-with-compiler/i3823.scala +++ b/tests/run-with-compiler/i3823.scala @@ -5,6 +5,6 @@ object Test { def f[T: Type](x: Expr[T])(t: Type[T]) = '{ val z: t.unary_~ = ~x } - println(f('(2))('[Int]).show) + println(f('{2})('[Int]).show) } } \ No newline at end of file diff --git a/tests/run-with-compiler/i3847-b.scala b/tests/run-with-compiler/i3847-b.scala index 370322f5f071..926e1d8c1068 100644 --- a/tests/run-with-compiler/i3847-b.scala +++ b/tests/run-with-compiler/i3847-b.scala @@ -6,7 +6,7 @@ object Arrays { implicit def ArrayIsLiftable[T: Liftable](implicit t: Type[T]): Liftable[Array[List[T]]] = { new Liftable[Array[List[T]]] { def toExpr(arr: Array[List[T]]): Expr[Array[List[T]]] = '{ - new Array[List[~t]](~arr.length.toExpr) + new Array[List[${t]](${arr.length.toExpr}}) // TODO add elements } } @@ -16,7 +16,7 @@ object Arrays { object Test { def main(args: Array[String]): Unit = { import Arrays._ - implicit val ct: Expr[ClassTag[Int]] = '(ClassTag.Int) + implicit val ct: Expr[ClassTag[Int]] = '{ClassTag.Int} val arr: Expr[Array[List[Int]]] = Array[List[Int]](List(1, 2, 3)).toExpr println(arr.show) } diff --git a/tests/run-with-compiler/i3847.scala b/tests/run-with-compiler/i3847.scala index 43a3efb5d573..e15c215fb63c 100644 --- a/tests/run-with-compiler/i3847.scala +++ b/tests/run-with-compiler/i3847.scala @@ -6,7 +6,7 @@ object Arrays { implicit def ArrayIsLiftable[T: Liftable](implicit t: Type[T], ct: Expr[ClassTag[T]]): Liftable[Array[T]] = { new Liftable[Array[T]] { def toExpr(arr: Array[T]): Expr[Array[T]] = '{ - new Array[~t](~arr.length.toExpr)(~ct) + new Array[${t](${arr.length.toExpr}})(~ct) // TODO add elements } } @@ -16,7 +16,7 @@ object Arrays { object Test { def main(args: Array[String]): Unit = { import Arrays._ - implicit val ct: Expr[ClassTag[Int]] = '(ClassTag.Int) + implicit val ct: Expr[ClassTag[Int]] = '{ClassTag.Int} val arr: Expr[Array[Int]] = Array[Int](1, 2, 3).toExpr println(arr.show) } diff --git a/tests/run-with-compiler/i3876-b.scala b/tests/run-with-compiler/i3876-b.scala index fc89db875075..c252c9d84dfa 100644 --- a/tests/run-with-compiler/i3876-b.scala +++ b/tests/run-with-compiler/i3876-b.scala @@ -4,7 +4,7 @@ object Test { def main(args: Array[String]): Unit = { implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make - val x: Expr[Int] = '(3) + val x: Expr[Int] = '{3} val f2: Expr[Int => Int] = '{ def f(x: Int): Int = x + x diff --git a/tests/run-with-compiler/i3876-c.scala b/tests/run-with-compiler/i3876-c.scala index 6e3b5213f081..061bf3a985f4 100644 --- a/tests/run-with-compiler/i3876-c.scala +++ b/tests/run-with-compiler/i3876-c.scala @@ -4,7 +4,7 @@ object Test { def main(args: Array[String]): Unit = { implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make - val x: Expr[Int] = '(3) + val x: Expr[Int] = '{3} val f3: Expr[Int => Int] = '{ val f: (x: Int) => Int = x => x + x diff --git a/tests/run-with-compiler/i3876-d.scala b/tests/run-with-compiler/i3876-d.scala index c3c2bec7a70a..7629b6a5c349 100644 --- a/tests/run-with-compiler/i3876-d.scala +++ b/tests/run-with-compiler/i3876-d.scala @@ -4,7 +4,7 @@ object Test { def main(args: Array[String]): Unit = { implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make - val x: Expr[Int] = '(3) + val x: Expr[Int] = '{3} val f4: Expr[Int => Int] = '{ inlineLambda diff --git a/tests/run-with-compiler/i3876.scala b/tests/run-with-compiler/i3876.scala index 67324b9518f1..3f1d5363c718 100644 --- a/tests/run-with-compiler/i3876.scala +++ b/tests/run-with-compiler/i3876.scala @@ -4,7 +4,7 @@ object Test { def main(args: Array[String]): Unit = { implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make - val x: Expr[Int] = '(3) + val x: Expr[Int] = '{3} val f: Expr[Int => Int] = '{ (x: Int) => x + x } println(f(x).run) diff --git a/tests/run-with-compiler/i3946.scala b/tests/run-with-compiler/i3946.scala index 6a3108b2b298..12e129884a3d 100644 --- a/tests/run-with-compiler/i3946.scala +++ b/tests/run-with-compiler/i3946.scala @@ -4,7 +4,7 @@ object Test { def main(args: Array[String]): Unit = { implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make - val u: Expr[Unit] = '() + val u: Expr[Unit] = '{} println(u.show) println(u.run) } diff --git a/tests/run-with-compiler/i4044a.scala b/tests/run-with-compiler/i4044a.scala index fc05dbcb8ed9..b89f7456d632 100644 --- a/tests/run-with-compiler/i4044a.scala +++ b/tests/run-with-compiler/i4044a.scala @@ -3,7 +3,7 @@ import scala.quoted.Toolbox.Default._ class Foo { def foo: Unit = { - val e: Expr[Int] = '(3) + val e: Expr[Int] = '{3} val q = '{ ~( '{ ~e } ) } println(q.show) } diff --git a/tests/run-with-compiler/i4044b.scala b/tests/run-with-compiler/i4044b.scala index 66a57073e9ff..bf5955838acd 100644 --- a/tests/run-with-compiler/i4044b.scala +++ b/tests/run-with-compiler/i4044b.scala @@ -13,7 +13,7 @@ object VarRef { ~body( new VarRef { def update(e: Expr[T]): Expr[Unit] = '{ x = ~e } - def expr: Expr[T] = '(x) + def expr: Expr[T] = '{x} } ) } @@ -22,7 +22,7 @@ object VarRef { object Test { def main(args: Array[String]): Unit = { - val q = VarRef('(4))(varRef => '{ ~varRef.update('(3)); ~varRef.expr }) + val q = VarRef('{4})(varRef => '{ ~varRef.update('{3}); ~varRef.expr }) println(q.show) } } diff --git a/tests/run-with-compiler/i4044d.scala b/tests/run-with-compiler/i4044d.scala index b1afb942253e..74f425456d66 100644 --- a/tests/run-with-compiler/i4044d.scala +++ b/tests/run-with-compiler/i4044d.scala @@ -3,10 +3,10 @@ import scala.quoted.Toolbox.Default._ class Foo { def foo: Unit = { - val a: Expr[Int] = '(3) + val a: Expr[Int] = '{3} val q: Expr[Int] = '{ val b = 3 - ~{ + ${ println("evaluating inner quote") '{ b + ~a diff --git a/tests/run-with-compiler/i4044e.scala b/tests/run-with-compiler/i4044e.scala index 8e7ea90d6e67..dcd0cc5ea77f 100644 --- a/tests/run-with-compiler/i4044e.scala +++ b/tests/run-with-compiler/i4044e.scala @@ -3,8 +3,8 @@ import scala.quoted.Toolbox.Default._ class Foo { def foo: Unit = { - val e: Expr[Int] = '(3) - val f: Expr[Int] = '(5) + val e: Expr[Int] = '{3} + val f: Expr[Int] = '{5} val t: Type[Int] = '[Int] val q = '{ ~( '{ (~e + ~f).asInstanceOf[~t] } ) } println(q.show) diff --git a/tests/run-with-compiler/i4044f.scala b/tests/run-with-compiler/i4044f.scala index 59330937e8fb..26c0abf5c88b 100644 --- a/tests/run-with-compiler/i4044f.scala +++ b/tests/run-with-compiler/i4044f.scala @@ -3,15 +3,15 @@ import scala.quoted.Toolbox.Default._ class Foo { def foo: Unit = { - val e: Expr[Int] = '(3) - val f: Expr[Int] = '(5) + val e: Expr[Int] = '{3} + val f: Expr[Int] = '{5} def foo(x: Expr[Int], y: Expr[Int]): Expr[Int] = '{ ~x + ~y } val q = '{ val e1 = ~e val f1 = ~f - ~{ - val u = '(2) - foo('{e1 + ~u}, '(f1)) + ${ + val u = '{2} + foo('{e1 + ~u}, '{f1}) } } println(q.show) diff --git a/tests/run-with-compiler/i4350.scala b/tests/run-with-compiler/i4350.scala index 6edf550a44bf..1521e1b301ae 100644 --- a/tests/run-with-compiler/i4350.scala +++ b/tests/run-with-compiler/i4350.scala @@ -3,7 +3,7 @@ import scala.quoted.Toolbox.Default._ import scala.quoted.Type class Foo[T: Type] { - def q = '((null: Any).asInstanceOf[T]) + def q = '{(null: Any).asInstanceOf[T]} } object Test { diff --git a/tests/run-with-compiler/i4591.scala b/tests/run-with-compiler/i4591.scala index cfad307c2bfc..079a9da26243 100644 --- a/tests/run-with-compiler/i4591.scala +++ b/tests/run-with-compiler/i4591.scala @@ -9,7 +9,7 @@ object Test { } def main(args: Array[String]): Unit = { - foo('(Option(9))).run + foo('{Option(9)}).run } } diff --git a/tests/run-with-compiler/i5144.scala b/tests/run-with-compiler/i5144.scala index 122e060aa754..8bb1dc05cefe 100644 --- a/tests/run-with-compiler/i5144.scala +++ b/tests/run-with-compiler/i5144.scala @@ -3,10 +3,10 @@ import scala.quoted._ object Test { implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make - def eval1(ff: Expr[Int => Int]): Expr[Int] = '((~ff)(42)) + def eval1(ff: Expr[Int => Int]): Expr[Int] = '{$ff(42)} def peval1(): Expr[Unit] = '{ - def f(x: Int): Int = ~eval1('(f)) + def f(x: Int): Int = ${eval1('{f})} } def main(args: Array[String]): Unit = { diff --git a/tests/run-with-compiler/i5144b.scala b/tests/run-with-compiler/i5144b.scala index f616374decb8..716bcf49ac75 100644 --- a/tests/run-with-compiler/i5144b.scala +++ b/tests/run-with-compiler/i5144b.scala @@ -3,10 +3,10 @@ import scala.quoted._ object Test { implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make - def eval1(ff: Expr[Int => Int]): Expr[Int] = ff('(42)) + def eval1(ff: Expr[Int => Int]): Expr[Int] = ff('{42}) def peval1(): Expr[Unit] = '{ - def f(x: Int): Int = ~eval1('(f)) + def f(x: Int): Int = ~eval1('{f}) } def main(args: Array[String]): Unit = { diff --git a/tests/run-with-compiler/i5152.scala b/tests/run-with-compiler/i5152.scala index f115bc609974..218ffff8e2ab 100644 --- a/tests/run-with-compiler/i5152.scala +++ b/tests/run-with-compiler/i5152.scala @@ -3,10 +3,10 @@ import scala.quoted._ object Test { implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make - def eval1(ff: Expr[Int => Int]): Expr[Int => Int] = '(identity) + def eval1(ff: Expr[Int => Int]): Expr[Int => Int] = '{identity} def peval1(): Expr[Unit] = '{ - lazy val f: Int => Int = ~eval1('((y: Int) => f(y))) + lazy val f: Int => Int = ${eval1('{(y: Int) => f(y)})} } def main(args: Array[String]): Unit = { diff --git a/tests/run-with-compiler/quote-ackermann-1.scala b/tests/run-with-compiler/quote-ackermann-1.scala index 0e45816631e7..abb10434f648 100644 --- a/tests/run-with-compiler/quote-ackermann-1.scala +++ b/tests/run-with-compiler/quote-ackermann-1.scala @@ -15,7 +15,7 @@ object Test { def ackermann(m: Int): Expr[Int => Int] = { if (m == 0) '{ n => n + 1 } else '{ n => - def `ackermann(m-1)`(n: Int): Int = ~ackermann(m - 1)('(n)) // Expr[Int => Int] applied to Expr[Int] + def `ackermann(m-1)`(n: Int): Int = ~ackermann(m - 1)('{n}) // Expr[Int => Int] applied to Expr[Int] def `ackermann(m)`(n: Int): Int = if (n == 0) `ackermann(m-1)`(1) else `ackermann(m-1)`(`ackermann(m)`(n - 1)) `ackermann(m)`(n) diff --git a/tests/run-with-compiler/quote-fun-app-1.scala b/tests/run-with-compiler/quote-fun-app-1.scala index cd61c6d95b65..02fdbaf0b9ee 100644 --- a/tests/run-with-compiler/quote-fun-app-1.scala +++ b/tests/run-with-compiler/quote-fun-app-1.scala @@ -10,8 +10,8 @@ object Test { println(f(43)) } - def f1: Expr[Int => Int] = '{ n => ~f2('(n)) } - def f2: Expr[Int => Int] = '{ n => ~f3('(n)) } - def f3: Expr[Int => Int] = '{ n => ~f4('(n)) } + def f1: Expr[Int => Int] = '{ n => ~f2('{n}) } + def f2: Expr[Int => Int] = '{ n => ~f3('{n}) } + def f3: Expr[Int => Int] = '{ n => ~f4('{n}) } def f4: Expr[Int => Int] = '{ n => n } } diff --git a/tests/run-with-compiler/quote-function-applied-to.scala b/tests/run-with-compiler/quote-function-applied-to.scala index faac3dfec8a6..fa381cea8eff 100644 --- a/tests/run-with-compiler/quote-function-applied-to.scala +++ b/tests/run-with-compiler/quote-function-applied-to.scala @@ -4,28 +4,28 @@ import scala.quoted.Toolbox.Default._ object Test { def main(args: Array[String]): Unit = { println(('{ () => x(0) }).apply().show) - println(('{ (x1: Int) => x1 }).apply('(x(1))).show) - println(('{ (x1: Int, x2: Int) => x1 + x2 }).apply('(x(1)), '(x(2))).show) - println(('{ (x1: Int, x2: Int, x3: Int) => x1 + x2 + x3 }).apply('(x(1)), '(x(2)), '(x(3))).show) - println(('{ (x1: Int, x2: Int, x3: Int, x4: Int) => x1 + x2 + x3 + x4 }).apply('(x(1)), '(x(2)), '(x(3)), '(x(4))).show) - println(('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int) => x1 + x2 + x3 + x4 + x5 }).apply('(x(1)), '(x(2)), '(x(3)), '(x(4)), '(x(5))).show) - println(('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int) => x1 + x2 + x3 + x4 + x5 + x6 }).apply('(x(1)), '(x(2)), '(x(3)), '(x(4)), '(x(5)), '(x(6))).show) - println(('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 }).apply('(x(1)), '(x(2)), '(x(3)), '(x(4)), '(x(5)), '(x(6)), '(x(7))).show) - println(('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 }).apply('(x(1)), '(x(2)), '(x(3)), '(x(4)), '(x(5)), '(x(6)), '(x(7)), '(x(8))).show) - println(('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 }).apply('(x(1)), '(x(2)), '(x(3)), '(x(4)), '(x(5)), '(x(6)), '(x(7)), '(x(8)), '(x(9))).show) - println(('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 }).apply('(x(1)), '(x(2)), '(x(3)), '(x(4)), '(x(5)), '(x(6)), '(x(7)), '(x(8)), '(x(9)), '(x(10))).show) - println(('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 }).apply('(x(1)), '(x(2)), '(x(3)), '(x(4)), '(x(5)), '(x(6)), '(x(7)), '(x(8)), '(x(9)), '(x(10)), '(x(11))).show) - println(('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 }).apply('(x(1)), '(x(2)), '(x(3)), '(x(4)), '(x(5)), '(x(6)), '(x(7)), '(x(8)), '(x(9)), '(x(10)), '(x(11)), '(x(12))).show) - println(('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 }).apply('(x(1)), '(x(2)), '(x(3)), '(x(4)), '(x(5)), '(x(6)), '(x(7)), '(x(8)), '(x(9)), '(x(10)), '(x(11)), '(x(12)), '(x(13))).show) - println(('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 }).apply('(x(1)), '(x(2)), '(x(3)), '(x(4)), '(x(5)), '(x(6)), '(x(7)), '(x(8)), '(x(9)), '(x(10)), '(x(11)), '(x(12)), '(x(13)), '(x(14))).show) - println(('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 }).apply('(x(1)), '(x(2)), '(x(3)), '(x(4)), '(x(5)), '(x(6)), '(x(7)), '(x(8)), '(x(9)), '(x(10)), '(x(11)), '(x(12)), '(x(13)), '(x(14)), '(x(15))).show) - println(('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 }).apply('(x(1)), '(x(2)), '(x(3)), '(x(4)), '(x(5)), '(x(6)), '(x(7)), '(x(8)), '(x(9)), '(x(10)), '(x(11)), '(x(12)), '(x(13)), '(x(14)), '(x(15)), '(x(16))).show) - println(('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 }).apply('(x(1)), '(x(2)), '(x(3)), '(x(4)), '(x(5)), '(x(6)), '(x(7)), '(x(8)), '(x(9)), '(x(10)), '(x(11)), '(x(12)), '(x(13)), '(x(14)), '(x(15)), '(x(16)), '(x(17))).show) - println(('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 + x18 }).apply('(x(1)), '(x(2)), '(x(3)), '(x(4)), '(x(5)), '(x(6)), '(x(7)), '(x(8)), '(x(9)), '(x(10)), '(x(11)), '(x(12)), '(x(13)), '(x(14)), '(x(15)), '(x(16)), '(x(17)), '(x(18))).show) - println(('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 + x18 + x19 }).apply('(x(1)), '(x(2)), '(x(3)), '(x(4)), '(x(5)), '(x(6)), '(x(7)), '(x(8)), '(x(9)), '(x(10)), '(x(11)), '(x(12)), '(x(13)), '(x(14)), '(x(15)), '(x(16)), '(x(17)), '(x(18)), '(x(19))).show) - println(('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int, x20: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 + x18 + x19 + x20 }).apply('(x(1)), '(x(2)), '(x(3)), '(x(4)), '(x(5)), '(x(6)), '(x(7)), '(x(8)), '(x(9)), '(x(10)), '(x(11)), '(x(12)), '(x(13)), '(x(14)), '(x(15)), '(x(16)), '(x(17)), '(x(18)), '(x(19)), '(x(20))).show) - println(('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int, x20: Int, x21: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 + x18 + x19 + x20 + x21 }).apply('(x(1)), '(x(2)), '(x(3)), '(x(4)), '(x(5)), '(x(6)), '(x(7)), '(x(8)), '(x(9)), '(x(10)), '(x(11)), '(x(12)), '(x(13)), '(x(14)), '(x(15)), '(x(16)), '(x(17)), '(x(18)), '(x(19)), '(x(20)), '(x(21))).show) - println(('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int, x20: Int, x21: Int, x22: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 + x18 + x19 + x20 + x21 + x22 }).apply('(x(1)), '(x(2)), '(x(3)), '(x(4)), '(x(5)), '(x(6)), '(x(7)), '(x(8)), '(x(9)), '(x(10)), '(x(11)), '(x(12)), '(x(13)), '(x(14)), '(x(15)), '(x(16)), '(x(17)), '(x(18)), '(x(19)), '(x(20)), '(x(21)), '(x(22))).show) + println(('{ (x1: Int) => x1 }).apply('{x(1)}).show) + println(('{ (x1: Int, x2: Int) => x1 + x2 }).apply('{x(1)}, '{x(2)}).show) + println(('{ (x1: Int, x2: Int, x3: Int) => x1 + x2 + x3 }).apply('{x(1)}, '{x(2)}, '{x(3)}).show) + println(('{ (x1: Int, x2: Int, x3: Int, x4: Int) => x1 + x2 + x3 + x4 }).apply('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}).show) + println(('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int) => x1 + x2 + x3 + x4 + x5 }).apply('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}).show) + println(('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int) => x1 + x2 + x3 + x4 + x5 + x6 }).apply('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}).show) + println(('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 }).apply('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}).show) + println(('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 }).apply('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}).show) + println(('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 }).apply('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}).show) + println(('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 }).apply('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}).show) + println(('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 }).apply('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}).show) + println(('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 }).apply('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}).show) + println(('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 }).apply('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}).show) + println(('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 }).apply('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}).show) + println(('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 }).apply('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}).show) + println(('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 }).apply('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}).show) + println(('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 }).apply('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}, '{x(17)}).show) + println(('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 + x18 }).apply('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}, '{x(17)}, '{x(18)}).show) + println(('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 + x18 + x19 }).apply('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}, '{x(17)}, '{x(18)}, '{x(19)}).show) + println(('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int, x20: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 + x18 + x19 + x20 }).apply('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}, '{x(17)}, '{x(18)}, '{x(19)}, '{x(20)}).show) + println(('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int, x20: Int, x21: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 + x18 + x19 + x20 + x21 }).apply('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}, '{x(17)}, '{x(18)}, '{x(19)}, '{x(20)}, '{x(21)}).show) + println(('{ (x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int, x20: Int, x21: Int, x22: Int) => x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 + x18 + x19 + x20 + x21 + x22 }).apply('{x(1)}, '{x(2)}, '{x(3)}, '{x(4)}, '{x(5)}, '{x(6)}, '{x(7)}, '{x(8)}, '{x(9)}, '{x(10)}, '{x(11)}, '{x(12)}, '{x(13)}, '{x(14)}, '{x(15)}, '{x(16)}, '{x(17)}, '{x(18)}, '{x(19)}, '{x(20)}, '{x(21)}, '{x(22)}).show) } def x(i: Int): Int = i diff --git a/tests/run-with-compiler/quote-impure-by-name/quoted_1.scala b/tests/run-with-compiler/quote-impure-by-name/quoted_1.scala index 4eb0b86d8541..da6f367e8d86 100644 --- a/tests/run-with-compiler/quote-impure-by-name/quoted_1.scala +++ b/tests/run-with-compiler/quote-impure-by-name/quoted_1.scala @@ -9,10 +9,10 @@ object Index { implicit def zero[K, T]: Index[K, (K, T)] = new Index("0") - implicit inline def succ[K, H, T](implicit prev: => Index[K, T]): Index[K, (H, T)] = ~succImpl('(prev))('[K], '[H], '[T]) + implicit inline def succ[K, H, T](implicit prev: => Index[K, T]): Index[K, (H, T)] = ~succImpl('{prev})('[K], '[H], '[T]) def succImpl[K, H, T](prev: Expr[Index[K, T]])(implicit k: Type[K], h: Type[H], t: Type[T]): Expr[Index[K, (H, T)]] = { val value = s"1 + {${prev.show}}" - '(new Index(~value.toExpr)) + '{new Index(${value.toExpr})} } } \ No newline at end of file diff --git a/tests/run-with-compiler/quote-inline-function/quoted_1.scala b/tests/run-with-compiler/quote-inline-function/quoted_1.scala index a982c7eb3e16..01c4b654d4f8 100644 --- a/tests/run-with-compiler/quote-inline-function/quoted_1.scala +++ b/tests/run-with-compiler/quote-inline-function/quoted_1.scala @@ -4,19 +4,19 @@ import scala.quoted.Toolbox.Default._ object Macros { - inline def foreach1(start: Int, end: Int, f: Int => Unit): String = ~impl('(start), '(end), '(f)) - inline def foreach2(start: Int, end: Int, f: => Int => Unit): String = ~impl('(start), '(end), '(f)) + inline def foreach1(start: Int, end: Int, f: Int => Unit): String = ~impl('{start}, '{end}, '{f}) + inline def foreach2(start: Int, end: Int, f: => Int => Unit): String = ~impl('{start}, '{end}, '{f}) def impl(start: Expr[Int], end: Expr[Int], f: Expr[Int => Unit]): Expr[String] = { val res = '{ var i = ~start val j = ~end while (i < j) { - ~f.apply('(i)) + ~f.apply('{i}) i += 1 } do { - ~f.apply('(i)) + ~f.apply('{i}) i += 1 } while (i < j) } diff --git a/tests/run-with-compiler/quote-lambda.scala b/tests/run-with-compiler/quote-lambda.scala index 91a871ab1bc8..fcae39d63d68 100644 --- a/tests/run-with-compiler/quote-lambda.scala +++ b/tests/run-with-compiler/quote-lambda.scala @@ -2,6 +2,6 @@ import scala.quoted._ object Test { def main(args: Array[String]): Unit = { - '{ (x: Int) => ~('(x)) } + '{ (x: Int) => ~('{x}) } } } diff --git a/tests/run-with-compiler/quote-lib.scala b/tests/run-with-compiler/quote-lib.scala index 08178e3d58f8..5b81ffc10009 100644 --- a/tests/run-with-compiler/quote-lib.scala +++ b/tests/run-with-compiler/quote-lib.scala @@ -13,14 +13,14 @@ object Test { def main(args: Array[String]): Unit = { implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make - val liftedUnit: Expr[Unit] = '() + val liftedUnit: Expr[Unit] = '{} - letVal('(1))(a => '{ ~a + 1 }).show - letLazyVal('(1))(a => '{ ~a + 1 }).show - letDef('(1))(a => '{ ~a + 1 }).show + letVal('{1})(a => '{ ~a + 1 }).show + letLazyVal('{1})(a => '{ ~a + 1 }).show + letDef('{1})(a => '{ ~a + 1 }).show - liftedWhile('(true))('{ println(1) }).show - liftedDoWhile('{ println(1) })('(true)).show + liftedWhile('{true})('{ println(1) }).show + liftedDoWhile('{ println(1) })('{true}).show val t1: Expr[Tuple1[Int]] = Tuple1(4).toExpr val t2: Expr[(Int, Int)] = (2, 3).toExpr @@ -54,17 +54,17 @@ package liftable { object Units { implicit def UnitIsLiftable: Liftable[Unit] = new Liftable[Unit] { - def toExpr(x: Unit): Expr[Unit] = '() + def toExpr(x: Unit): Expr[Unit] = '{} } } object Lets { def letVal[T, U: Type](expr: Expr[T])(body: Expr[T] => Expr[U])(implicit t: Type[T]): Expr[U] = - '{ val letVal: ~t = ~expr; ~body('(letVal)) } + '{ val letVal: ~t = ~expr; ~body('{letVal}) } def letLazyVal[T, U: Type](expr: Expr[T])(body: Expr[T] => Expr[U])(implicit t: Type[T]): Expr[U] = - '{ lazy val letLazyVal: ~t = ~expr; ~body('(letLazyVal)) } + '{ lazy val letLazyVal: ~t = ~expr; ~body('{letLazyVal}) } def letDef[T, U: Type](expr: Expr[T])(body: Expr[T] => Expr[U])(implicit t: Type[T]): Expr[U] = - '{ def letDef: ~t = ~expr; ~body('(letDef)) } + '{ def letDef: ~t = ~expr; ~body('{letDef}) } } object Loops { @@ -87,7 +87,7 @@ package liftable { implicit def Tuple3IsLiftable[T1: Liftable, T2: Liftable, T3: Liftable](implicit t1: Type[T1], t2: Type[T2], t3: Type[T3]): Liftable[(T1, T2, T3)] = new Liftable[(T1, T2, T3)] { def toExpr(x: (T1, T2, T3)): Expr[(T1, T2, T3)] = - '{ Tuple3[~t1, ~t2, ~t3](~x._1.toExpr, ~x._2.toExpr, ~x._3.toExpr) } + '{ Tuple3[${t1, ~t2, ~t3](~x._1.toExpr, ~x._2.toExpr, ~x._3.toExpr}) } } @@ -122,8 +122,8 @@ package liftable { case Nil => acc } def unrolledForeach(f: Expr[T => Unit]): Expr[Unit] = list match { - case x :: xs => '{ (~f).apply(~x.toExpr); ~xs.unrolledForeach(f) } - case Nil => '() + case x :: xs => '{ (${f).apply(${x.toExpr}}); ~xs.unrolledForeach(f) } + case Nil => '{} } } diff --git a/tests/run-with-compiler/quote-nested-1.scala b/tests/run-with-compiler/quote-nested-1.scala index 5adc94754bea..9233eb750db1 100644 --- a/tests/run-with-compiler/quote-nested-1.scala +++ b/tests/run-with-compiler/quote-nested-1.scala @@ -3,7 +3,7 @@ import scala.quoted.Toolbox.Default._ object Test { def main(args: Array[String]): Unit = { - val q = '{ '(3) } + val q = '{ '{3} } println(q.show) } } diff --git a/tests/run-with-compiler/quote-nested-2.scala b/tests/run-with-compiler/quote-nested-2.scala index da69d4cf707c..d5e98e708727 100644 --- a/tests/run-with-compiler/quote-nested-2.scala +++ b/tests/run-with-compiler/quote-nested-2.scala @@ -4,8 +4,8 @@ import scala.quoted.Toolbox.Default._ object Test { def main(args: Array[String]): Unit = { val q = '{ - val a = '(4) - '(~a) + val a = '{4} + '{~a} } println(q.show) diff --git a/tests/run-with-compiler/quote-nested-3.scala b/tests/run-with-compiler/quote-nested-3.scala index 02170e2acd0b..e745d3b16ef5 100644 --- a/tests/run-with-compiler/quote-nested-3.scala +++ b/tests/run-with-compiler/quote-nested-3.scala @@ -7,8 +7,8 @@ object Test { val q = '{ type T = String val x = "foo" - ~{ - val y = '(x) + ${ + val y = '{x} '{ val z: T = ~y } } x diff --git a/tests/run-with-compiler/quote-nested-5.scala b/tests/run-with-compiler/quote-nested-5.scala index 902c2ae885b1..3ab1defddf42 100644 --- a/tests/run-with-compiler/quote-nested-5.scala +++ b/tests/run-with-compiler/quote-nested-5.scala @@ -4,9 +4,9 @@ import scala.quoted.Toolbox.Default._ object Test { def main(args: Array[String]): Unit = { val q = '{ - val a = '(4) + val a = '{4} ~('{ - '(~a) + '{~a} }) } diff --git a/tests/run-with-compiler/quote-run-2.scala b/tests/run-with-compiler/quote-run-2.scala index 7febe1ded44d..8dac1fbfac17 100644 --- a/tests/run-with-compiler/quote-run-2.scala +++ b/tests/run-with-compiler/quote-run-2.scala @@ -8,15 +8,15 @@ object Test { implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make def powerCode(n: Int, x: Expr[Double]): Expr[Double] = - if (n == 0) '(1.0) + if (n == 0) '{1.0} else if (n == 1) x - else if (n % 2 == 0) '{ { val y = ~x * ~x; ~powerCode(n / 2, '(y)) } } + else if (n % 2 == 0) '{ { val y = ~x * ~x; ~powerCode(n / 2, '{y}) } } else '{ ~x * ~powerCode(n - 1, x) } - println(powerCode(0, '(5)).show) - println(powerCode(1, '(5)).show) - println(powerCode(2, '(5)).show) - println(powerCode(3, '(5)).show) - println(powerCode(22, '(5)).show) + println(powerCode(0, '{5}).show) + println(powerCode(1, '{5}).show) + println(powerCode(2, '{5}).show) + println(powerCode(3, '{5}).show) + println(powerCode(22, '{5}).show) } } diff --git a/tests/run-with-compiler/quote-run-many.scala b/tests/run-with-compiler/quote-run-many.scala index 2a661d493df2..cabc6b8e96fc 100644 --- a/tests/run-with-compiler/quote-run-many.scala +++ b/tests/run-with-compiler/quote-run-many.scala @@ -5,7 +5,7 @@ object Test { implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make def expr(i: Int) = '{ - val a = 3 + ~i.toExpr + val a = 3 + ${i.toExpr} 2 + a } for (i <- 0 to 200) diff --git a/tests/run-with-compiler/quote-run-staged-interpreter.scala b/tests/run-with-compiler/quote-run-staged-interpreter.scala index 9af5dcde96a1..915418cd1552 100644 --- a/tests/run-with-compiler/quote-run-staged-interpreter.scala +++ b/tests/run-with-compiler/quote-run-staged-interpreter.scala @@ -15,11 +15,11 @@ object Test { def compile(e: Exp, env: Map[String, Expr[Int]], keepLets: Boolean): Expr[Int] = { def compileImpl(e: Exp, env: Map[String, Expr[Int]]): Expr[Int] = e match { case Num(n) => n.toExpr - case Plus(e1, e2) => '(~compileImpl(e1, env) + ~compileImpl(e2, env)) + case Plus(e1, e2) => '{${compileImpl(e1, env)} + ${compileImpl(e2, env)}} case Var(x) => env(x) case Let(x, e, body) => if (keepLets) - '{ val y = ~compileImpl(e, env); ~compileImpl(body, env + (x -> '(y))) } + '{ val y = ${compileImpl(e, env)}; ${compileImpl(body, env + (x -> '{y})} } else compileImpl(body, env + (x -> compileImpl(e, env))) } @@ -31,7 +31,7 @@ object Test { val exp = Plus(Plus(Num(2), Var("x")), Num(4)) val letExp = Let("x", Num(3), exp) - val res1 = '{ (x: Int) => ~compile(exp, Map("x" -> '(x)), false) } + val res1 = '{ (x: Int) => ${compile(exp, Map("x" -> '{x}), false)} } println(res1.show) diff --git a/tests/run-with-compiler/quote-show-blocks.scala b/tests/run-with-compiler/quote-show-blocks.scala index cf0eef3f38c6..3db9dffbb471 100644 --- a/tests/run-with-compiler/quote-show-blocks.scala +++ b/tests/run-with-compiler/quote-show-blocks.scala @@ -6,16 +6,16 @@ object Test { def a(n: Int, x: Expr[Unit]): Expr[Unit] = if (n == 0) x - else a(n - 1, '{ println(~n.toExpr); ~x }) + else a(n - 1, '{ println(${n.toExpr}); ~x }) - println(a(5, '()).show) + println(a(5, '{}).show) def b(n: Int, x: Expr[Unit]): Expr[Unit] = if (n == 0) x else b(n - 1, '{ ~x; println(~n.toExpr) }) - println(b(5, '()).show) + println(b(5, '{}).show) } } diff --git a/tests/run-with-compiler/quote-two-captured-ref.scala b/tests/run-with-compiler/quote-two-captured-ref.scala index ce652e35c846..aea5a10a2c5b 100644 --- a/tests/run-with-compiler/quote-two-captured-ref.scala +++ b/tests/run-with-compiler/quote-two-captured-ref.scala @@ -6,10 +6,10 @@ object Test { val q = '{ val x = 1 - println(~{ + println(${ println(1) - val a = '(x) - val b = '(x) + val a = '{x} + val b = '{x} '{ ~a + ~b } }) } diff --git a/tests/run-with-compiler/quote-type-tags.scala b/tests/run-with-compiler/quote-type-tags.scala index aeab7a9938fd..dc33751495d3 100644 --- a/tests/run-with-compiler/quote-type-tags.scala +++ b/tests/run-with-compiler/quote-type-tags.scala @@ -5,18 +5,18 @@ object Test { implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make def asof[T: Type, U](x: Expr[T], t: Type[U]): Expr[U] = - '((~x).asInstanceOf[~t]) + '{$x.asInstanceOf[$t]} - println(asof('(), '[Unit]).show) - println(asof('(true), '[Boolean]).show) - println(asof('(0.toByte), '[Byte]).show) - println(asof('( 'a' ), '[Char]).show) - println(asof('(1.toShort), '[Short]).show) - println(asof('(2), '[Int]).show) - println(asof('(3L), '[Long]).show) - println(asof('(4f), '[Float]).show) - println(asof('(5d), '[Double]).show) + println(asof('{}, '[Unit]).show) + println(asof('{true}, '[Boolean]).show) + println(asof('{0.toByte}, '[Byte]).show) + println(asof('{ 'a' }, '[Char]).show) + println(asof('{1.toShort}, '[Short]).show) + println(asof('{2}, '[Int]).show) + println(asof('{3L}, '[Long]).show) + println(asof('{4f}, '[Float]).show) + println(asof('{5d}, '[Double]).show) - println(asof('(5d), '[Boolean]).show) // Will clearly fail at runtime but the code can be generated + println(asof('{5d}, '[Boolean]).show) // Will clearly fail at runtime but the code can be generated } } diff --git a/tests/run-with-compiler/quote-unrolled-foreach.scala b/tests/run-with-compiler/quote-unrolled-foreach.scala index f81697147c96..13e5a391bbe9 100644 --- a/tests/run-with-compiler/quote-unrolled-foreach.scala +++ b/tests/run-with-compiler/quote-unrolled-foreach.scala @@ -5,27 +5,27 @@ object Test { implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make def main(args: Array[String]): Unit = { - val code1 = '{ (arr: Array[Int], f: Int => Unit) => ~foreach1('(arr), '(f)) } + val code1 = '{ (arr: Array[Int], f: Int => Unit) => ${ foreach1('{arr}, '{f}) } println(code1.show) println() - val code1Tpe = '{ (arr: Array[String], f: String => Unit) => ~foreach1Tpe1('(arr), '(f)) } + val code1Tpe = '{ (arr: Array[String], f: String => Unit) => ${ foreach1Tpe1('{arr}, '{f}) } } println(code1Tpe.show) println() - val code1Tpe2 = '{ (arr: Array[String], f: String => Unit) => ~foreach1Tpe1('(arr), '(f)) } + val code1Tpe2 = '{ (arr: Array[String], f: String => Unit) => ${ foreach1Tpe1('{arr}, '{f}) } } println(code1Tpe2.show) println() - val code2 = '{ (arr: Array[Int]) => ~foreach1('(arr), '(i => System.out.println(i))) } + val code2 = '{ (arr: Array[Int]) => ${ foreach1('{arr}, '{i => System.out.println(i)}) } } println(code2.show) println() - val code3 = '{ (arr: Array[Int], f: Int => Unit) => ~foreach3('(arr), '(f)) } + val code3 = '{ (arr: Array[Int], f: Int => Unit) => ${ foreach3('{arr}, '{f}) } } println(code3.show) println() - val code4 = '{ (arr: Array[Int], f: Int => Unit) => ~foreach4('(arr), '(f), 4) } + val code4 = '{ (arr: Array[Int], f: Int => Unit) => ${ foreach4('{arr}, '{f}, 4) } } println(code4.show) println() @@ -35,8 +35,8 @@ object Test { def printAll(arr: Array[Int]) = '{ - val arr1 = ~arr.toExpr - ~foreach1('(arr1), '(x => println(x))) + val arr1 = ${ arr.toExpr } + ${ foreach1('{arr1}, '{x => println(x)}) } } println(printAll(Array(1, 3, 4, 5)).show) @@ -44,11 +44,11 @@ object Test { } def foreach1(arrRef: Expr[Array[Int]], f: Expr[Int => Unit]): Expr[Unit] = '{ - val size = (~arrRef).length + val size = ($arrRef).length var i = 0 while (i < size) { - val element: Int = (~arrRef)(i) - (~f)(element) + val element: Int = ($arrRef)(i) + ($f)(element) i += 1 } } @@ -78,7 +78,7 @@ object Test { var i = 0 while (i < size) { val element = (~arrRef)(i) - ~f('(element)) // Use AppliedFuntion + ~f('{element}) // Use AppliedFuntion i += 1 } } @@ -110,16 +110,16 @@ object Test { def foreach4(arrRef: Expr[Array[Int]], f: Expr[Int => Unit], unrollSize: Int): Expr[Unit] = '{ val size = (~arrRef).length var i = 0 - if (size % ~unrollSize.toExpr != 0) throw new Exception("...") // for simplicity of the implementation + if (size % ${unrollSize.toExpr} != 0) throw new Exception("...") // for simplicity of the implementation while (i < size) { ~foreachInRange(0, unrollSize)(j => '{ (~f)((~arrRef)(i + ~j.toExpr)) }) - i += ~unrollSize.toExpr + i += ${unrollSize.toExpr} } } implicit object ArrayIntIsLiftable extends Liftable[Array[Int]] { override def toExpr(x: Array[Int]): Expr[Array[Int]] = '{ - val array = new Array[Int](~x.length.toExpr) + val array = new Array[Int](${x.length.toExpr}) ~foreachInRange(0, x.length)(i => '{ array(~i.toExpr) = ~x(i).toExpr}) array } @@ -128,7 +128,7 @@ object Test { def foreachInRange(start: Int, end: Int)(f: Int => Expr[Unit]): Expr[Unit] = { @tailrec def unroll(i: Int, acc: Expr[Unit]): Expr[Unit] = if (i < end) unroll(i + 1, '{ ~acc; ~f(i) }) else acc - if (start < end) unroll(start + 1, f(start)) else '() + if (start < end) unroll(start + 1, f(start)) else '{} } } diff --git a/tests/run-with-compiler/quote-var.scala b/tests/run-with-compiler/quote-var.scala index e19d5992c471..f882567d63aa 100644 --- a/tests/run-with-compiler/quote-var.scala +++ b/tests/run-with-compiler/quote-var.scala @@ -12,7 +12,7 @@ object Test { var x = ~init ~body( new Var { - def get: Expr[String] = '(x) + def get: Expr[String] = '{x} def update(e: Expr[String]): Expr[Unit] = '{ x = ~e } } ) @@ -20,9 +20,9 @@ object Test { } - def test1(): Expr[String] = Var('("abc")) { x => + def test1(): Expr[String] = Var('{"abc"}) { x => '{ - ~x.update('("xyz")) + ~x.update('{"xyz"}) ~x.get } } diff --git a/tests/run-with-compiler/shonan-hmm-simple.scala b/tests/run-with-compiler/shonan-hmm-simple.scala index a0b67ab62177..a372fc0543d8 100644 --- a/tests/run-with-compiler/shonan-hmm-simple.scala +++ b/tests/run-with-compiler/shonan-hmm-simple.scala @@ -17,11 +17,11 @@ class RingInt extends Ring[Int] { } class RingIntExpr extends Ring[Expr[Int]] { - val zero = '(0) - val one = '(1) - val add = (x, y) => '(~x + ~y) - val sub = (x, y) => '(~x - ~y) - val mul = (x, y) => '(~x * ~y) + val zero = '{0} + val one = '{1} + val add = (x, y) => '{$x + $y} + val sub = (x, y) => '{$x - $y} + val mul = (x, y) => '{$x * $y} } class RingComplex[U](u: Ring[U]) extends Ring[Complex[U]] { @@ -71,7 +71,7 @@ case class Complex[T](re: T, im: T) object Complex { implicit def isLiftable[T: Type: Liftable]: Liftable[Complex[T]] = new Liftable[Complex[T]] { - def toExpr(comp: Complex[T]): Expr[Complex[T]] = '(Complex(~comp.re.toExpr, ~comp.im.toExpr)) + def toExpr(comp: Complex[T]): Expr[Complex[T]] = '{Complex(${comp.re.toExpr}, ${comp.im.toExpr})} } } @@ -99,10 +99,10 @@ class StaticVecOps[T] extends VecOps[Int, T] { class ExprVecOps[T: Type] extends VecOps[Expr[Int], Expr[T]] { val reduce: ((Expr[T], Expr[T]) => Expr[T], Expr[T], Vec[Expr[Int], Expr[T]]) => Expr[T] = (plus, zero, vec) => '{ - var sum = ~zero + var sum = $zero var i = 0 - while (i < ~vec.size) { - sum = ~{ plus('(sum), vec.get('(i))) } + while (i < ${vec.size}) { + sum = ${ plus('{sum}, vec.get('{i})) } i += 1 } sum @@ -154,10 +154,10 @@ object Test { val resCode2: Expr[(Array[Int], Array[Int]) => Int] = '{ (arr1, arr2) => if (arr1.length != arr2.length) throw new Exception("...") - ~{ + ${ blasExprIntExpr.dot( - new Vec('(arr1.size), i => '(arr1(~i))), - new Vec('(arr2.size), i => '(arr2(~i))) + new Vec('{arr1.size}, i => '{arr1($i)}), + new Vec('{arr2.size}, i => '{arr2($i)}) ) } } @@ -177,10 +177,10 @@ object Test { val blasExprIntPVExpr = new Blas1(new RingPV[Int](new RingInt, new RingIntExpr), new StaticVecOps) val resCode4: Expr[Array[Int] => Int] = '{ arr => - if (arr.length != ~vec2.size.toExpr) throw new Exception("...") - ~{ + if (arr.length != ${vec2.size.toExpr}) throw new Exception("...") + ${ blasExprIntPVExpr.dot( - new Vec(vec2.size, i => Dyn('(arr(~i.toExpr)))), + new Vec(vec2.size, i => Dyn('{arr(${i.toExpr})})), vec2.map(i => Sta(i)) ).expr } @@ -194,13 +194,13 @@ object Test { val blasExprComplexPVInt = new Blas1[Int, Complex[PV[Int]]](new RingComplex(new RingPV[Int](new RingInt, new RingIntExpr)), new StaticVecOps) val resCode5: Expr[Array[Complex[Int]] => Complex[Int]] = '{ arr => - if (arr.length != ~cmpxVec2.size.toExpr) throw new Exception("...") - ~{ + if (arr.length != ${cmpxVec2.size.toExpr}) throw new Exception("...") + ${ val cpx = blasExprComplexPVInt.dot( - new Vec(cmpxVec2.size, i => Complex(Dyn('(arr(~i.toExpr).re)), Dyn('(arr(~i.toExpr).im)))), + new Vec(cmpxVec2.size, i => Complex(Dyn('{arr(${i.toExpr}).re}), Dyn('{arr(${i.toExpr}).im}))), new Vec(cmpxVec2.size, i => Complex(Sta(cmpxVec2.get(i).re), Sta(cmpxVec2.get(i).im))) ) - '(Complex(~cpx.re.expr, ~cpx.im.expr)) + '{Complex(${cpx.re.expr}, ${cpx.im.expr})} } } println(resCode5.show) @@ -212,7 +212,7 @@ object Test { val dotIntOptExpr = new Blas1(RingPVInt, new StaticVecOps).dot // will generate the code '{ ((arr: scala.Array[scala.Int]) => arr.apply(1).+(arr.apply(3))) } val staticVec = Vec[Int, PV[Int]](5, i => Sta((i % 2))) - val code = '{(arr: Array[Int]) => ~dotIntOptExpr(Vec(5, i => Dyn('(arr(~i.toExpr)))), staticVec).expr } + val code = '{(arr: Array[Int]) => ${dotIntOptExpr(Vec(5, i => Dyn('{arr(${i.toExpr})})), staticVec).expr} } println(code.show) println() } diff --git a/tests/run-with-compiler/shonan-hmm/Complex.scala b/tests/run-with-compiler/shonan-hmm/Complex.scala index da3490b6f228..b73e0bbfade0 100644 --- a/tests/run-with-compiler/shonan-hmm/Complex.scala +++ b/tests/run-with-compiler/shonan-hmm/Complex.scala @@ -5,11 +5,11 @@ case class Complex[T](re: T, im: T) object Complex { implicit def complexIsLiftable[T: Type: Liftable]: Liftable[Complex[T]] = new Liftable { - def toExpr(c: Complex[T]): Expr[Complex[T]] = '{ Complex(~c.re.toExpr, ~c.im.toExpr) } + def toExpr(c: Complex[T]): Expr[Complex[T]] = '{ Complex(${c.re.toExpr}, ${c.im.toExpr}) } } - def of_complex_expr(x: Expr[Complex[Int]]): Complex[Expr[Int]] = Complex('((~x).re), '((~x).im)) - def of_expr_complex(x: Complex[Expr[Int]]): Expr[Complex[Int]] = '(Complex(~x.re, ~x.im)) + def of_complex_expr(x: Expr[Complex[Int]]): Complex[Expr[Int]] = Complex('{$x.re}, '{$x.im}) + def of_expr_complex(x: Complex[Expr[Int]]): Expr[Complex[Int]] = '{Complex(${x.re}, ${x.im})} } \ No newline at end of file diff --git a/tests/run-with-compiler/shonan-hmm/Lifters.scala b/tests/run-with-compiler/shonan-hmm/Lifters.scala index e852085b2d0c..3098391df61f 100644 --- a/tests/run-with-compiler/shonan-hmm/Lifters.scala +++ b/tests/run-with-compiler/shonan-hmm/Lifters.scala @@ -7,22 +7,22 @@ import scala.quoted._ object Lifters { implicit def ClassTagIsLiftable[T : Type](implicit ct: ClassTag[T]): Liftable[ClassTag[T]] = - ct => '(ClassTag(~ct.runtimeClass.toExpr)) + ct => '{ClassTag(${ct.runtimeClass.toExpr})} implicit def ArrayIsLiftable[T : Type: ClassTag](implicit l: Liftable[T]): Liftable[Array[T]] = arr => '{ - val array = new Array[T](~arr.length.toExpr)(~implicitly[ClassTag[T]].toExpr) - ~initArray(arr, '(array)) + val array = new Array[T](${arr.length.toExpr})(${implicitly[ClassTag[T]].toExpr}) + ${initArray(arr, '{array})} } implicit def IntArrayIsLiftable: Liftable[Array[Int]] = arr => '{ - val array = new Array[Int](~arr.length.toExpr) - ~initArray(arr, '(array)) + val array = new Array[Int](${arr.length.toExpr}) + ${initArray(arr, '{array})} } private def initArray[T : Liftable : Type](arr: Array[T], array: Expr[Array[T]]): Expr[Array[T]] = { UnrolledExpr.block( arr.zipWithIndex.map { - case (x, i) => '{ (~array)(~i.toExpr) = ~x.toExpr } + case (x, i) => '{ $array(${i.toExpr}) = ${x.toExpr} } }.toList, array) } diff --git a/tests/run-with-compiler/shonan-hmm/MVmult.scala b/tests/run-with-compiler/shonan-hmm/MVmult.scala index a476c1919831..149aadd80b98 100644 --- a/tests/run-with-compiler/shonan-hmm/MVmult.scala +++ b/tests/run-with-compiler/shonan-hmm/MVmult.scala @@ -26,10 +26,10 @@ object MVmult { (vout, a, v) => { val n = vout.length val m = v.length - ~{ - val vout_ = OVec('(n), (i, x: Expr[Int]) => '(vout(~i) = ~x)) - val a_ = Vec('(n), (i: Expr[Int]) => Vec('(m), (j: Expr[Int]) => '{ a(~i)(~j) } )) - val v_ = Vec('(m), (i: Expr[Int]) => '(v(~i))) + ${ + val vout_ = OVec('{n}, (i, x: Expr[Int]) => '{vout($i) = $x}) + val a_ = Vec('{n}, (i: Expr[Int]) => Vec('{m}, (j: Expr[Int]) => '{ a($i)($j) } )) + val v_ = Vec('{m}, (i: Expr[Int]) => '{v($i)}) val MV = new MVmult[Expr[Int], Expr[Int], Expr[Unit]](RingIntExpr, new VecRDyn) MV.mvmult(vout_, a_, v_) @@ -41,12 +41,12 @@ object MVmult { val MV = new MVmult[Int, Expr[Int], Expr[Unit]](RingIntExpr, new VecRStaDim(RingIntExpr)) '{ (vout, a, v) => { - if (~n.toExpr != vout.length) throw new IndexOutOfBoundsException(~n.toString.toExpr) - if (~m.toExpr != v.length) throw new IndexOutOfBoundsException(~m.toString.toExpr) - ~{ - val vout_ = OVec(n, (i, x: Expr[Int]) => '(vout(~i.toExpr) = ~x)) - val a_ = Vec(n, i => Vec(m, j => '{ a(~i.toExpr)(~j.toExpr) } )) - val v_ = Vec(m, i => '(v(~i.toExpr))) + if (${n.toExpr} != vout.length) throw new IndexOutOfBoundsException(${n.toString.toExpr}) + if (${m.toExpr} != v.length) throw new IndexOutOfBoundsException(${m.toString.toExpr}) + ${ + val vout_ = OVec(n, (i, x: Expr[Int]) => '{vout(${i.toExpr}) = $x}) + val a_ = Vec(n, i => Vec(m, j => '{ a(${i.toExpr})(${j.toExpr}) } )) + val v_ = Vec(m, i => '{v(${i.toExpr})}) MV.mvmult(vout_, a_, v_) } @@ -57,9 +57,9 @@ object MVmult { def mvmult_ac(a: Array[Array[Int]]): Expr[(Array[Int], Array[Int]) => Unit] = { import Lifters._ '{ - val arr = ~a.toExpr - ~{ - val (n, m, a2) = amat1(a, '(arr)) + val arr = ${a.toExpr} + ${ + val (n, m, a2) = amat1(a, '{arr}) mvmult_abs0(new RingIntPExpr, new VecRStaDyn(new RingIntPExpr))(n, m, a2) } } @@ -68,9 +68,9 @@ object MVmult { def mvmult_opt(a: Array[Array[Int]]): Expr[(Array[Int], Array[Int]) => Unit] = { import Lifters._ '{ - val arr = ~a.toExpr - ~{ - val (n, m, a2) = amat1(a, '(arr)) + val arr = ${a.toExpr} + ${ + val (n, m, a2) = amat1(a, '{arr}) mvmult_abs0(new RingIntOPExpr, new VecRStaDyn(new RingIntPExpr))(n, m, a2) } } @@ -79,9 +79,9 @@ object MVmult { def mvmult_roll(a: Array[Array[Int]]): Expr[(Array[Int], Array[Int]) => Unit] = { import Lifters._ '{ - val arr = ~a.toExpr - ~{ - val (n, m, a2) = amat1(a, '(arr)) + val arr = ${a.toExpr} + ${ + val (n, m, a2) = amat1(a, '{arr}) mvmult_abs0(new RingIntOPExpr, new VecRStaOptDynInt(new RingIntPExpr))(n, m, a2) } } @@ -104,11 +104,11 @@ object MVmult { def loop(i: Int, acc: List[Expr[Array[Int]]]): Expr[T] = { if (i >= a.length) cont(acc.toArray.reverse) else if (a(i).count(_ != 0) < VecRStaOptDynInt.threshold) { - val default: Expr[Array[Int]] = '(null.asInstanceOf[Array[Int]]) // never accessed + val default: Expr[Array[Int]] = '{null.asInstanceOf[Array[Int]]} // never accessed loop(i + 1, default :: acc) } else '{ - val row = ~a(i).toExpr - ~{ loop(i + 1, '(row) :: acc) } + val row = ${a(i).toExpr} + ${ loop(i + 1, '{row} :: acc) } } } loop(0, Nil) @@ -119,8 +119,8 @@ object MVmult { val m = a(0).length val vec: Vec[PV[Int], Vec[PV[Int], PV[Int]]] = Vec(Sta(n), i => Vec(Sta(m), j => (i, j) match { case (Sta(i), Sta(j)) => Sta(a(i)(j)) - case (Sta(i), Dyn(j)) => Dyn('((~aa)(~i.toExpr)(~j))) - case (i, j) => Dyn('{ (~aa)(~(Dyns.dyni(i)))(~(Dyns.dyni(j))) }) + case (Sta(i), Dyn(j)) => Dyn('{$aa(${i.toExpr})($j)}) + case (i, j) => Dyn('{ $aa(${Dyns.dyni(i)})(${Dyns.dyni(j)}) }) })) (n, m, vec) } @@ -130,7 +130,7 @@ object MVmult { val m = a(0).length val vec: Vec[PV[Int], Vec[PV[Int], PV[Int]]] = Vec(Sta(n), i => Vec(Sta(m), j => (i, j) match { case (Sta(i), Sta(j)) => Sta(a(i)(j)) - case (Sta(i), Dyn(j)) => Dyn('((~refs(i))(~j))) + case (Sta(i), Dyn(j)) => Dyn('{(${refs(i)})($j)}) })) (n, m, vec) } @@ -151,23 +151,23 @@ object MVmult { def copy_row1: Array[Int] => (Expr[Int] => Expr[Int]) = v => { import Lifters._ val arr = v.toExpr - i => '{ (~arr).apply(~i) } + i => '{ ($arr).apply($i) } } def copy_row_let: Array[Int] => (Expr[Int] => Expr[Int]) = v => { import Lifters._ val arr: Expr[Array[Int]] = ??? // FIXME used genlet v.toExpr - i => '{ (~arr).apply(~i) } + i => '{ ($arr).apply($i) } } private def mvmult_abs0(ring: Ring[PV[Int]], vecOp: VecROp[PV[Int], PV[Int], Expr[Unit]])(n: Int, m: Int, a: Vec[PV[Int], Vec[PV[Int], PV[Int]]]): Expr[(Array[Int], Array[Int]) => Unit] = { '{ (vout, v) => { - if (~n.toExpr != vout.length) throw new IndexOutOfBoundsException(~n.toString.toExpr) - if (~m.toExpr != v.length) throw new IndexOutOfBoundsException(~m.toString.toExpr) - ~{ - val vout_ : OVec[PV[Int], PV[Int], Expr[Unit]] = OVec(Sta(n), (i, x) => '(vout(~Dyns.dyni(i)) = ~Dyns.dyn(x))) - val v_ : Vec[PV[Int], PV[Int]] = Vec(Sta(m), i => Dyn('(v(~Dyns.dyni(i))))) + if (${n.toExpr} != vout.length) throw new IndexOutOfBoundsException(${n.toString.toExpr}) + if (${m.toExpr} != v.length) throw new IndexOutOfBoundsException(${m.toString.toExpr}) + ${ + val vout_ : OVec[PV[Int], PV[Int], Expr[Unit]] = OVec(Sta(n), (i, x) => '{vout(${Dyns.dyni(i)}) = ${Dyns.dyn(x)}}) + val v_ : Vec[PV[Int], PV[Int]] = Vec(Sta(m), i => Dyn('{v(${Dyns.dyni(i)})})) val MV = new MVmult[PV[Int], PV[Int], Expr[Unit]](ring, vecOp) MV.mvmult(vout_, a, v_) } diff --git a/tests/run-with-compiler/shonan-hmm/Ring.scala b/tests/run-with-compiler/shonan-hmm/Ring.scala index 521fff3ac819..9c14b0271375 100644 --- a/tests/run-with-compiler/shonan-hmm/Ring.scala +++ b/tests/run-with-compiler/shonan-hmm/Ring.scala @@ -25,11 +25,11 @@ object RingInt extends Ring[Int] { } object RingIntExpr extends Ring[Expr[Int]] { - val zero = '(0) - val one = '(1) - val add = (x, y) => '(~x + ~y) - val sub = (x, y) => '(~x - ~y) - val mul = (x, y) => '(~x * ~y) + val zero = '{0} + val one = '{1} + val add = (x, y) => '{~x + ~y} + val sub = (x, y) => '{~x - ~y} + val mul = (x, y) => '{~x * ~y} override def toString(): String = "RingIntExpr" } diff --git a/tests/run-with-compiler/shonan-hmm/Test.scala b/tests/run-with-compiler/shonan-hmm/Test.scala index 38341199bd17..4aec6d833bb6 100644 --- a/tests/run-with-compiler/shonan-hmm/Test.scala +++ b/tests/run-with-compiler/shonan-hmm/Test.scala @@ -18,7 +18,7 @@ object Test { val intExprComplex = new RingComplex(RingIntExpr) import intExprComplex._ - val res = Complex('(1), '(2)) * Complex('(4), '(2)) + val res = Complex('{1}, '{2}) * Complex('{4}, '{2}) println(s"Complex(${res.re.show}, ${res.im.show})") } @@ -26,7 +26,7 @@ object Test { // val intExprComplex = implicitly[Ring[Expr[Complex[Int]]]] // import intExprComplex._ - // val res = '(Complex(1, 2)) * '(Complex(4, 2)) + // val res = '{Complex(1, 2)} * '{Complex(4, 2)} // println(res.show) // } diff --git a/tests/run-with-compiler/shonan-hmm/UnrolledExpr.scala b/tests/run-with-compiler/shonan-hmm/UnrolledExpr.scala index b76edae7fd92..179bd50d96fb 100644 --- a/tests/run-with-compiler/shonan-hmm/UnrolledExpr.scala +++ b/tests/run-with-compiler/shonan-hmm/UnrolledExpr.scala @@ -21,7 +21,7 @@ object UnrolledExpr { class UnrolledExpr[T: Liftable, It <: Iterable[T]](xs: It) { import UnrolledExpr._ - def foreach[U](f: T => Expr[U]): Expr[Unit] = block(xs.map(f), '()) + def foreach[U](f: T => Expr[U]): Expr[Unit] = block(xs.map(f), '{}) def withFilter(f: T => Boolean): UnrolledExpr[T, Iterable[T]] = new UnrolledExpr(xs.filter(f)) diff --git a/tests/run-with-compiler/shonan-hmm/VecOp.scala b/tests/run-with-compiler/shonan-hmm/VecOp.scala index c8bbbd6d3b69..c57ef2ad632a 100644 --- a/tests/run-with-compiler/shonan-hmm/VecOp.scala +++ b/tests/run-with-compiler/shonan-hmm/VecOp.scala @@ -16,7 +16,7 @@ class VecDyn extends VecOp[Expr[Int], Expr[Unit]] { def iter: Vec[Expr[Int], Expr[Unit]] => Expr[Unit] = arr => '{ var i = 0 while (i < ~arr.size) { - ~arr('(i)) + ~arr('{i}) i += 1 } } diff --git a/tests/run-with-compiler/shonan-hmm/VecROp.scala b/tests/run-with-compiler/shonan-hmm/VecROp.scala index 3d8b8aa63ebe..2d0be63a9684 100644 --- a/tests/run-with-compiler/shonan-hmm/VecROp.scala +++ b/tests/run-with-compiler/shonan-hmm/VecROp.scala @@ -22,7 +22,7 @@ class VecRDyn[T: Type] extends VecDyn with VecROp[Expr[Int], Expr[T], Expr[Unit] var sum = ~zero var i = 0 while (i < ~vec.size) { - sum = ~{ plus('(sum), vec('(i))) } + sum = ${ plus('{sum}, vec('{i})) } i += 1 } sum @@ -40,7 +40,7 @@ class VecRStaDim[T: Type](r: Ring[T]) extends VecROp[Int, T, Expr[Unit]] { def loop(i: Int, acc: Expr[Unit]): Expr[Unit] = if (i < arr.size) loop(i + 1, '{ ~acc; ~arr.get(i) }) else acc - loop(0, '()) + loop(0, '{}) } override def toString(): String = s"VecRStaDim($r)" } @@ -60,7 +60,7 @@ class VecRStaDyn[T : Type : Liftable](r: Ring[PV[T]]) extends VecROp[PV[Int], PV def loop(i: Int, acc: Expr[Unit]): Expr[Unit] = if (i < n) loop(i + 1, '{ ~acc; ~arr.get(Sta(i)) }) else acc - loop(0, '()) + loop(0, '{}) case Dyn(n) => '{ "TODO"; () } diff --git a/tests/run-with-compiler/shonan-hmm/Vmults.scala b/tests/run-with-compiler/shonan-hmm/Vmults.scala index a3bf8a775451..bf8005842c6b 100644 --- a/tests/run-with-compiler/shonan-hmm/Vmults.scala +++ b/tests/run-with-compiler/shonan-hmm/Vmults.scala @@ -24,10 +24,10 @@ object Vmults { def vmultCA: Expr[(Array[Complex[Int]], Array[Complex[Int]], Array[Complex[Int]]) => Unit] = '{ (vout, v1, v2) => { val n = vout.length - ~{ - val vout_ = OVec[Expr[Int], Complex[Expr[Int]], Expr[Unit]]('(n), (i, v) => '(vout(~i) = ~Complex.of_expr_complex(v))) - val v1_ = Vec ('(n), i => Complex.of_complex_expr('(v1(~i)))) - val v2_ = Vec ('(n), i => Complex.of_complex_expr('(v2(~i)))) + ${ + val vout_ = OVec[Expr[Int], Complex[Expr[Int]], Expr[Unit]]('{n}, (i, v) => '{vout($i) = ${Complex.of_expr_complex(v)}}) + val v1_ = Vec ('{n}, i => Complex.of_complex_expr('{v1($i)})) + val v2_ = Vec ('{n}, i => Complex.of_complex_expr('{v2($i)})) val V = new Vmult[Expr[Int], Complex[Expr[Int]], Expr[Unit]](RingComplex(RingIntExpr), new VecDyn) V.vmult(vout_, v1_, v2_) diff --git a/tests/run-with-compiler/tasty-extractors-constants-2/quoted_1.scala b/tests/run-with-compiler/tasty-extractors-constants-2/quoted_1.scala index d3e1ecdba402..bbc1e7fbfbeb 100644 --- a/tests/run-with-compiler/tasty-extractors-constants-2/quoted_1.scala +++ b/tests/run-with-compiler/tasty-extractors-constants-2/quoted_1.scala @@ -19,8 +19,8 @@ object Macros { val run2 = power(n.toExpr, 4.0.toExpr).run // n is a constant in a quote - val show3 = power('(2), 5.0.toExpr).show - val run3 = power('(2), 5.0.toExpr).run + val show3 = power('{2}, 5.0.toExpr).show + val run3 = power('{2}, 5.0.toExpr).run // n2 is clearly not a constant // FIXME @@ -29,17 +29,17 @@ object Macros { // val run4 = (power(n2, 6.0.toExpr).run) '{ - println(~show1.toExpr) - println(~run1.toExpr) + println(${show1.toExpr}) + println(${run1.toExpr}) println() - println(~show2.toExpr) - println(~run2.toExpr) + println(${show2.toExpr}) + println(${run2.toExpr}) println() - println(~show3.toExpr) - println(~run3.toExpr) + println(${show3.toExpr}) + println(${run3.toExpr}) // println() -// println(~show4.toExpr) -// println(~run4.toExpr) +// println(${show4.toExpr}) +// println(${run4.toExpr}) } } @@ -54,9 +54,9 @@ object Macros { } def powerCode(n: Int, x: Expr[Double]): Expr[Double] = - if (n == 0) '(1.0) + if (n == 0) '{1.0} else if (n == 1) x - else if (n % 2 == 0) '{ { val y = ~x * ~x; ~powerCode(n / 2, '(y)) } } + else if (n % 2 == 0) '{ { val y = ~x * ~x; ~powerCode(n / 2, '{y}) } } else '{ ~x * ~powerCode(n - 1, x) } def dynamicPower(n: Int, x: Double): Double = diff --git a/tests/run-with-compiler/tasty-unsafe-let/quoted_1.scala b/tests/run-with-compiler/tasty-unsafe-let/quoted_1.scala index 793cb85c9e47..337ad2059f45 100644 --- a/tests/run-with-compiler/tasty-unsafe-let/quoted_1.scala +++ b/tests/run-with-compiler/tasty-unsafe-let/quoted_1.scala @@ -5,7 +5,7 @@ import scala.tasty._ object Macros { inline def let[T](rhs: T)(body: => T => Unit): Unit = - ~impl('(rhs), '(body)) + ~impl('{rhs}, '{body}) private def impl[T](rhs: Expr[T], body: Expr[T => Unit])(implicit reflect: Reflection): Expr[Unit] = { import reflect._ diff --git a/tests/run/Course-2002-07.check b/tests/run/Course-2002-07.check index 75e956f31054..aa933e066fdb 100644 --- a/tests/run/Course-2002-07.check +++ b/tests/run/Course-2002-07.check @@ -91,14 +91,14 @@ List(1, 6) = heads(List(List(), List(1, 2, 3, 4, 5), List(6))) List(1, 3, 5) = heads(List(List(1, 2), List(3, 4), List(5, 6))) f (x) = Prod(Var(x), Var(x)) -f'(x) = Sum(Prod(Var(x), Number(1)), Prod(Var(x), Number(1))) +f'{x} = Sum(Prod(Var(x), Number(1)), Prod(Var(x), Number(1))) f (x) = x * x -f'(x) = x * 1 + x * 1 +f'{x} = x * 1 + x * 1 g (x) = 2 * x * x + 3 * x -g'(x) = 2 * x * 1 + x * (2 * 1 + x * 0) + 3 * 1 + x * 0 +g'{x} = 2 * x * 1 + x * (2 * 1 + x * 0) + 3 * 1 + x * 0 g (3) = 27 -g'(3) = 15 +g'{3} = 15 ta(x) = x + 3 tb(x) = x + 3 diff --git a/tests/run/Course-2002-07.scala b/tests/run/Course-2002-07.scala index 779d27188075..c168313a56d7 100644 --- a/tests/run/Course-2002-07.scala +++ b/tests/run/Course-2002-07.scala @@ -364,7 +364,7 @@ object M9 { val f0 = Prod(x, x); val f1 = f0 derive x; Console.println("f (x) = " + f0); - Console.println("f'(x) = " + f1); + Console.println("f'{x} = " + f1); Console.println(); } @@ -431,14 +431,14 @@ object MA { val f0 = x * x; val f1 = f0 derive x; Console.println("f (x) = " + f0); - Console.println("f'(x) = " + f1); + Console.println("f'{x} = " + f1); val g0 = Number(2) * x * x + Number(3) * x; val g1 = g0 derive x; Console.println("g (x) = " + g0); - Console.println("g'(x) = " + g1); + Console.println("g'{x} = " + g1); Console.println("g (3) = " + evalvars(List(("x",3)))(g0)); - Console.println("g'(3) = " + evalvars(List(("x",3)))(g1)); + Console.println("g'{3} = " + evalvars(List(("x",3)))(g1)); Console.println(); } diff --git a/tests/run/f-interpolation-1/FQuote_1.scala b/tests/run/f-interpolation-1/FQuote_1.scala index c428ecfe0c0d..3f639a91f1fc 100644 --- a/tests/run/f-interpolation-1/FQuote_1.scala +++ b/tests/run/f-interpolation-1/FQuote_1.scala @@ -6,7 +6,7 @@ import scala.language.implicitConversions object FQuote { implicit class SCOps(ctx: StringContext) { - inline def ff(args: => Any*): String = ~impl('(this), '(args)) + inline def ff(args: => Any*): String = ~impl('{this}, '{args}) } /*private*/ def impl(receiver: Expr[SCOps], args: Expr[Seq[Any]])(implicit reflect: Reflection): Expr[String] = { @@ -17,7 +17,7 @@ object FQuote { val head = x.seal[Any] val tail = liftListOfAny(xs) '{ ~head :: ~tail } - case Nil => '(Nil) + case Nil => '{Nil} } def isStringConstant(tree: Term) = tree match { @@ -47,12 +47,12 @@ object FQuote { for ((arg, part) <- allArgs.zip(parts.tail)) { if (part.startsWith("%d") && !(arg.tpe <:< definitions.IntType)) { - return '(s"`${~arg.showCode.toExpr}` is not of type Int") + return '{s"`${${arg.showCode.toExpr}}` is not of type Int"} } } val string = parts.mkString("") - '{ new collection.immutable.StringOps(~string.toExpr).format(~args: _*) } + '{ new collection.immutable.StringOps(${string.toExpr}).format(~args: _*) } } } diff --git a/tests/run/gestalt-optional-staging/Macro_1.scala b/tests/run/gestalt-optional-staging/Macro_1.scala index 74b2538782bc..400dc2455766 100644 --- a/tests/run/gestalt-optional-staging/Macro_1.scala +++ b/tests/run/gestalt-optional-staging/Macro_1.scala @@ -7,9 +7,9 @@ final class Optional[+A >: Null](val value: A) extends AnyVal { def get: A = value def isEmpty = value == null - inline def getOrElse[B >: A](alt: => B): B = ~Optional.getOrElseImpl('(this), '(alt)) + inline def getOrElse[B >: A](alt: => B): B = ~Optional.getOrElseImpl('{this}, '{alt}) - inline def map[B >: Null](f: A => B): Optional[B] = ~Optional.mapImpl('(this), '(f)) + inline def map[B >: Null](f: A => B): Optional[B] = ~Optional.mapImpl('{this}, '{f}) override def toString = if (isEmpty) "" else s"$value" } @@ -18,13 +18,13 @@ object Optional { // FIXME fix issue #5097 and enable private /*private*/ def getOrElseImpl[T >: Null : Type](opt: Expr[Optional[T]], alt: Expr[T]): Expr[T] = '{ - if ((~opt).isEmpty) ~alt else (~opt).value + if ($opt.isEmpty) $alt else $opt.value } // FIXME fix issue #5097 and enable private /*private*/ def mapImpl[A >: Null : Type, B >: Null : Type](opt: Expr[Optional[A]], f: Expr[A => B]): Expr[Optional[B]] = '{ - if ((~opt).isEmpty) new Optional(null) - else new Optional(~f('((~opt).value))) + if ($opt.isEmpty) new Optional(null) + else new Optional(${f('{$opt.value})}) } } diff --git a/tests/run/gestalt-type-toolbox-reflect/Macro_1.scala b/tests/run/gestalt-type-toolbox-reflect/Macro_1.scala index 0eafbb998104..6dffdcd3a940 100644 --- a/tests/run/gestalt-type-toolbox-reflect/Macro_1.scala +++ b/tests/run/gestalt-type-toolbox-reflect/Macro_1.scala @@ -6,7 +6,7 @@ import scala.tasty._ object TypeToolbox { /** are the two types equal? */ - inline def =:=[A, B]: Boolean = ~tpEqImpl('[A], '[B]) + inline def =:=[A, B]: Boolean = ${tpEqImpl('[A], '[B])} private def tpEqImpl[A, B](a: Type[A], b: Type[B])(implicit reflect: Reflection): Expr[Boolean] = { import reflect._ val res = a.unseal.tpe =:= b.unseal.tpe @@ -14,7 +14,7 @@ object TypeToolbox { } /** is `tp1` a subtype of `tp2` */ - inline def <:<[A, B]: Boolean = ~tpLEqImpl('[A], '[B]) + inline def <:<[A, B]: Boolean = ${tpLEqImpl('[A], '[B])} private def tpLEqImpl[A, B](a: Type[A], b: Type[B])(implicit reflect: Reflection): Expr[Boolean] = { import reflect._ val res = a.unseal.tpe <:< b.unseal.tpe @@ -22,7 +22,7 @@ object TypeToolbox { } /** type associated with the tree */ - inline def typeOf[T, Expected](a: T): Boolean = ~typeOfImpl('(a), '[Expected]) + inline def typeOf[T, Expected](a: T): Boolean = ${typeOfImpl('{a}, '[Expected])} private def typeOfImpl(a: Expr[_], expected: Type[_])(implicit reflect: Reflection): Expr[Boolean] = { import reflect._ val res = a.unseal.tpe =:= expected.unseal.tpe @@ -30,7 +30,7 @@ object TypeToolbox { } /** does the type refer to a case class? */ - inline def isCaseClass[A]: Boolean = ~isCaseClassImpl('[A]) + inline def isCaseClass[A]: Boolean = ${isCaseClassImpl('[A])} private def isCaseClassImpl(tp: Type[_])(implicit reflect: Reflection): Expr[Boolean] = { import reflect._ val res = tp.unseal.symbol match { @@ -41,66 +41,66 @@ object TypeToolbox { } /** val fields of a case class Type -- only the ones declared in primary constructor */ - inline def caseFields[T]: List[String] = ~caseFieldsImpl('[T]) + inline def caseFields[T]: List[String] = ${caseFieldsImpl('[T])} private def caseFieldsImpl(tp: Type[_])(implicit reflect: Reflection): Expr[List[String]] = { import reflect._ val fields = tp.unseal.symbol.asClass.caseFields.map(_.name) fields.toExpr } - inline def fieldIn[T](inline mem: String): String = ~fieldInImpl('[T], mem) + inline def fieldIn[T](inline mem: String): String = ${fieldInImpl('[T], mem)} private def fieldInImpl(t: Type[_], mem: String)(implicit reflect: Reflection): Expr[String] = { import reflect._ val field = t.unseal.symbol.asClass.field(mem) field.map(_.name).getOrElse("").toExpr } - inline def fieldsIn[T]: Seq[String] = ~fieldsInImpl('[T]) + inline def fieldsIn[T]: Seq[String] = ${fieldsInImpl('[T])} private def fieldsInImpl(t: Type[_])(implicit reflect: Reflection): Expr[Seq[String]] = { import reflect._ val fields = t.unseal.symbol.asClass.fields fields.map(_.name).toList.toExpr } - inline def methodIn[T](inline mem: String): Seq[String] = ~methodInImpl('[T], mem) + inline def methodIn[T](inline mem: String): Seq[String] = ${methodInImpl('[T], mem)} private def methodInImpl(t: Type[_], mem: String)(implicit reflect: Reflection): Expr[Seq[String]] = { import reflect._ t.unseal.symbol.asClass.classMethod(mem).map(_.name).toExpr } - inline def methodsIn[T]: Seq[String] = ~methodsInImpl('[T]) + inline def methodsIn[T]: Seq[String] = ${methodsInImpl('[T])} private def methodsInImpl(t: Type[_])(implicit reflect: Reflection): Expr[Seq[String]] = { import reflect._ t.unseal.symbol.asClass.classMethods.map(_.name).toExpr } - inline def method[T](inline mem: String): Seq[String] = ~methodImpl('[T], mem) + inline def method[T](inline mem: String): Seq[String] = ${methodImpl('[T], mem)} private def methodImpl(t: Type[_], mem: String)(implicit reflect: Reflection): Expr[Seq[String]] = { import reflect._ t.unseal.symbol.asClass.method(mem).map(_.name).toExpr } - inline def methods[T]: Seq[String] = ~methodsImpl('[T]) + inline def methods[T]: Seq[String] = ${methodsImpl('[T])} private def methodsImpl(t: Type[_])(implicit reflect: Reflection): Expr[Seq[String]] = { import reflect._ t.unseal.symbol.asClass.methods.map(_.name).toExpr } - inline def typeTag[T](x: T): String = ~typeTagImpl('[T]) + inline def typeTag[T](x: T): String = ${typeTagImpl('[T])} private def typeTagImpl(tp: Type[_])(implicit reflect: Reflection): Expr[String] = { import reflect._ val res = tp.unseal.tpe.showCode res.toExpr } - inline def companion[T1, T2]: Boolean = ~companionImpl('[T1], '[T2]) + inline def companion[T1, T2]: Boolean = ${companionImpl('[T1], '[T2])} private def companionImpl(t1: Type[_], t2: Type[_])(implicit reflect: Reflection): Expr[Boolean] = { import reflect._ val res = t1.unseal.symbol.asClass.companionModule.contains(t2.unseal.symbol) res.toExpr } - inline def companionName[T1]: String = ~companionNameImpl('[T1]) + inline def companionName[T1]: String = ${companionNameImpl('[T1])} private def companionNameImpl(tp: Type[_])(implicit reflect: Reflection): Expr[String] = { import reflect._ val companionClassOpt = tp.unseal.symbol match { @@ -114,8 +114,8 @@ object TypeToolbox { // TODO add to the std lib private implicit def listIsLiftable[T: Type: Liftable]: Liftable[List[T]] = new Liftable { def toExpr(list: List[T]): Expr[List[T]] = list match { - case x :: xs => '(~x.toExpr :: ~toExpr(xs)) - case Nil => '(Nil) + case x :: xs => '{${x.toExpr} :: ${toExpr(xs)}} + case Nil => '{Nil} } } } diff --git a/tests/run/i4431/quoted_1.scala b/tests/run/i4431/quoted_1.scala index 8f0be7b23ef7..e433ec5677a6 100644 --- a/tests/run/i4431/quoted_1.scala +++ b/tests/run/i4431/quoted_1.scala @@ -1,5 +1,5 @@ import scala.quoted._ object Macros { - inline def h(f: => Int => String): String = ~ '(f(42)) + inline def h(f: => Int => String): String = ~{'{f(42)}} } diff --git a/tests/run/i4455/Macro_1.scala b/tests/run/i4455/Macro_1.scala index 9ac3070ed986..ec78c82b6d85 100644 --- a/tests/run/i4455/Macro_1.scala +++ b/tests/run/i4455/Macro_1.scala @@ -1,8 +1,8 @@ import scala.quoted._ object Macros { - inline def foo(inline i: Int): Int = ~bar('(i)) + inline def foo(inline i: Int): Int = ~bar('{i}) - inline def foo2(inline i: Int): Int = ~bar('(i + 1)) + inline def foo2(inline i: Int): Int = ~bar('{i + 1}) def bar(x: Expr[Int]): Expr[Int] = x } diff --git a/tests/run/i4492/quoted_1.scala b/tests/run/i4492/quoted_1.scala index 67e68d59c1e7..8c4810cc3c43 100644 --- a/tests/run/i4492/quoted_1.scala +++ b/tests/run/i4492/quoted_1.scala @@ -2,5 +2,5 @@ trait Index object Index { - inline def succ(prev: Index): Unit = ~{ '(println("Ok")) } + inline def succ(prev: Index): Unit = ${ '{println("Ok")} } } diff --git a/tests/run/i4515/Macro_1.scala b/tests/run/i4515/Macro_1.scala index f6fed9b178d3..905ca5279721 100644 --- a/tests/run/i4515/Macro_1.scala +++ b/tests/run/i4515/Macro_1.scala @@ -1,5 +1,5 @@ object Macro { - inline def foo[X](x: X): Unit = ~fooImpl('(x)) - def fooImpl[X: quoted.Type](x: quoted.Expr[X]): quoted.Expr[Unit] = '() + inline def foo[X](x: X): Unit = ~fooImpl('{x}) + def fooImpl[X: quoted.Type](x: quoted.Expr[X]): quoted.Expr[Unit] = '{} } diff --git a/tests/run/i4515b/Macro_1.scala b/tests/run/i4515b/Macro_1.scala index 176dc147ea08..a3e8f0be055f 100644 --- a/tests/run/i4515b/Macro_1.scala +++ b/tests/run/i4515b/Macro_1.scala @@ -2,5 +2,5 @@ import scala.tasty.Reflection object Macro { inline def foo: Unit = ~fooImpl - def fooImpl(implicit reflect: Reflection): quoted.Expr[Unit] = '() + def fooImpl(implicit reflect: Reflection): quoted.Expr[Unit] = '{} } diff --git a/tests/run/i4734/Macro_1.scala b/tests/run/i4734/Macro_1.scala index 5b4a90383bb8..eadea10600d4 100644 --- a/tests/run/i4734/Macro_1.scala +++ b/tests/run/i4734/Macro_1.scala @@ -3,21 +3,21 @@ import scala.quoted._ object Macros { inline def unrolledForeach(seq: IndexedSeq[Int], f: => Int => Unit, inline unrollSize: Int): Unit = // or f: Int => Unit - ~unrolledForeachImpl('(seq), '(f), unrollSize) + ~unrolledForeachImpl('{seq}, '{f}, unrollSize) def unrolledForeachImpl(seq: Expr[IndexedSeq[Int]], f: Expr[Int => Unit], unrollSize: Int): Expr[Unit] = '{ val size = (~seq).length - assert(size % (~unrollSize.toExpr) == 0) // for simplicity of the implementation + assert(size % (${unrollSize.toExpr}) == 0) // for simplicity of the implementation var i = 0 while (i < size) { - ~{ + ${ for (j <- new UnrolledRange(0, unrollSize)) '{ - val index = i + ~j.toExpr + val index = i + ${j.toExpr} val element = (~seq)(index) - ~f('(element)) // or `(~f)(element)` if `f` should not be inlined + ~f('{element}) // or `(~f)(element)` if `f` should not be inlined } } - i += ~unrollSize.toExpr + i += ${unrollSize.toExpr} } } @@ -27,7 +27,7 @@ object Macros { @tailrec def loop(i: Int, acc: Expr[Unit]): Expr[Unit] = if (i >= 0) loop(i - 1, '{ ~f(i); ~acc }) else acc - loop(end - 1, '()) + loop(end - 1, '{}) } } } diff --git a/tests/run/i4735/Macro_1.scala b/tests/run/i4735/Macro_1.scala index 2a7aabc6db47..9b87f08c3853 100644 --- a/tests/run/i4735/Macro_1.scala +++ b/tests/run/i4735/Macro_1.scala @@ -4,21 +4,21 @@ import scala.quoted._ object Macro { inline def unrolledForeach(inline unrollSize: Int, seq: Array[Int], f: => Int => Unit): Unit = // or f: Int => Unit - ~unrolledForeachImpl(unrollSize, '(seq), '(f)) + ~unrolledForeachImpl(unrollSize, '{seq}, '{f}) private def unrolledForeachImpl(unrollSize: Int, seq: Expr[Array[Int]], f: Expr[Int => Unit]): Expr[Unit] = '{ val size = (~seq).length - assert(size % (~unrollSize.toExpr) == 0) // for simplicity of the implementation + assert(size % (${unrollSize.toExpr}) == 0) // for simplicity of the implementation var i = 0 while (i < size) { println(" start loop") - ~{ + ${ for (j <- new UnrolledRange(0, unrollSize)) '{ - val element = (~seq)(i + ~j.toExpr) - ~f('(element)) // or `(~f)(element)` if `f` should not be inlined + val element = ($seq)(i + ${j.toExpr}) + ~f('{element}) // or `(~f)(element)` if `f` should not be inlined } } - i += ~unrollSize.toExpr + i += ${unrollSize.toExpr} } } @@ -28,7 +28,7 @@ object Macro { @tailrec def loop(i: Int, acc: Expr[Unit]): Expr[Unit] = if (i >= 0) loop(i - 1, '{ ~f(i); ~acc }) else acc - loop(end - 1, '()) + loop(end - 1, '{}) } } } diff --git a/tests/run/i4803/App_2.scala b/tests/run/i4803/App_2.scala index 703fbf871457..a2526b7158b8 100644 --- a/tests/run/i4803/App_2.scala +++ b/tests/run/i4803/App_2.scala @@ -1,6 +1,6 @@ class Num2(x: Double) { - inline def power(inline n: Long) = ~PowerMacro.powerCode('(x), n) + inline def power(inline n: Long) = ~PowerMacro.powerCode('{x}, n) } object Test { diff --git a/tests/run/i4803/Macro_1.scala b/tests/run/i4803/Macro_1.scala index 46cd0e925c7b..93b5f260ffba 100644 --- a/tests/run/i4803/Macro_1.scala +++ b/tests/run/i4803/Macro_1.scala @@ -2,11 +2,11 @@ import scala.quoted._ object PowerMacro { def powerCode(x: Expr[Double], n: Long): Expr[Double] = - if (n == 0) '(1.0) - else if (n % 2 == 0) '{ val y = ~x * ~x; ~powerCode('(y), n / 2) } + if (n == 0) '{1.0} + else if (n % 2 == 0) '{ val y = ~x * ~x; ~powerCode('{y}, n / 2) } else '{ ~x * ~powerCode(x, n - 1) } } class Num(x: Double) { - inline def power(inline n: Long) = ~PowerMacro.powerCode('(x), n) + inline def power(inline n: Long) = ~PowerMacro.powerCode('{x}, n) } diff --git a/tests/run/i4803b/App_2.scala b/tests/run/i4803b/App_2.scala index 698885b5b54f..478a7183ecf5 100644 --- a/tests/run/i4803b/App_2.scala +++ b/tests/run/i4803b/App_2.scala @@ -2,7 +2,7 @@ class Nums { class Num(x: Double) { - inline def power(inline n: Long) = ~PowerMacro.powerCode('(x), n) + inline def power(inline n: Long) = ~PowerMacro.powerCode('{x}, n) } } diff --git a/tests/run/i4803b/Macro_1.scala b/tests/run/i4803b/Macro_1.scala index 681f3b2fac63..b0690dac9eac 100644 --- a/tests/run/i4803b/Macro_1.scala +++ b/tests/run/i4803b/Macro_1.scala @@ -2,7 +2,7 @@ import scala.quoted._ object PowerMacro { def powerCode(x: Expr[Double], n: Long): Expr[Double] = - if (n == 0) '(1.0) - else if (n % 2 == 0) '{ val y = ~x * ~x; ~powerCode('(y), n / 2) } + if (n == 0) '{1.0} + else if (n % 2 == 0) '{ val y = ~x * ~x; ~powerCode('{y}, n / 2) } else '{ ~x * ~powerCode(x, n - 1) } } diff --git a/tests/run/i4803c/App_2.scala b/tests/run/i4803c/App_2.scala index 128fcfb19600..41debe518ea3 100644 --- a/tests/run/i4803c/App_2.scala +++ b/tests/run/i4803c/App_2.scala @@ -2,7 +2,7 @@ object Test { def main(args: Array[String]): Unit = { class Num(x: Double) { - inline def power(inline n: Long) = ~PowerMacro.powerCode('(x), n) + inline def power(inline n: Long) = ~PowerMacro.powerCode('{x}, n) } val n = new Num(1.5) println(n.power(0)) @@ -10,7 +10,7 @@ object Test { println(n.power(2)) println(n.power(5)) - inline def power(x: Double, inline n: Long) = ~PowerMacro.powerCode('(x), n) + inline def power(x: Double, inline n: Long) = ~PowerMacro.powerCode('{x}, n) val x: Double = 1.5 diff --git a/tests/run/i4803c/Macro_1.scala b/tests/run/i4803c/Macro_1.scala index 681f3b2fac63..b0690dac9eac 100644 --- a/tests/run/i4803c/Macro_1.scala +++ b/tests/run/i4803c/Macro_1.scala @@ -2,7 +2,7 @@ import scala.quoted._ object PowerMacro { def powerCode(x: Expr[Double], n: Long): Expr[Double] = - if (n == 0) '(1.0) - else if (n % 2 == 0) '{ val y = ~x * ~x; ~powerCode('(y), n / 2) } + if (n == 0) '{1.0} + else if (n % 2 == 0) '{ val y = ~x * ~x; ~powerCode('{y}, n / 2) } else '{ ~x * ~powerCode(x, n - 1) } } diff --git a/tests/run/i4803e/App_2.scala b/tests/run/i4803e/App_2.scala index 224df7eabb0d..343284775631 100644 --- a/tests/run/i4803e/App_2.scala +++ b/tests/run/i4803e/App_2.scala @@ -10,5 +10,5 @@ object Test { println(power2(x3)) } - inline def power2(x: Double) = ~PowerMacro.power2('(x)) + inline def power2(x: Double) = ~PowerMacro.power2('{x}) } diff --git a/tests/run/i4803f/App_2.scala b/tests/run/i4803f/App_2.scala index 224df7eabb0d..343284775631 100644 --- a/tests/run/i4803f/App_2.scala +++ b/tests/run/i4803f/App_2.scala @@ -10,5 +10,5 @@ object Test { println(power2(x3)) } - inline def power2(x: Double) = ~PowerMacro.power2('(x)) + inline def power2(x: Double) = ~PowerMacro.power2('{x}) } diff --git a/tests/run/i4803f/Macro_1.scala b/tests/run/i4803f/Macro_1.scala index dd693322b62d..c6958091055f 100644 --- a/tests/run/i4803f/Macro_1.scala +++ b/tests/run/i4803f/Macro_1.scala @@ -2,12 +2,12 @@ import scala.quoted._ object PowerMacro { def powerCode(x: Expr[Double], n: Long): Expr[Double] = - if (n == 0) '(1.0) - else if (n % 2 == 0) '{ val y = ~x * ~x; ~powerCode('(y), n / 2) } + if (n == 0) '{1.0} + else if (n % 2 == 0) '{ val y = ~x * ~x; ~powerCode('{y}, n / 2) } else '{ ~x * ~powerCode(x, n - 1) } def power2(x: Expr[Double]) = '{ - inline def power(x: Double): Double = ~powerCode('(x), 2) + inline def power(x: Double): Double = ~powerCode('{x}, 2) power(~x) } } diff --git a/tests/run/i4947e/Test_2.scala b/tests/run/i4947e/Test_2.scala index cc83cd4b4536..f7594f2f0e0e 100644 --- a/tests/run/i4947e/Test_2.scala +++ b/tests/run/i4947e/Test_2.scala @@ -1,6 +1,6 @@ object Test { - inline def assert2(expr: => Boolean): Unit = ~Macros.assertImpl('(expr)) + inline def assert2(expr: => Boolean): Unit = ~Macros.assertImpl('{expr}) def main(args: Array[String]): Unit = { val x = 1 diff --git a/tests/run/i4947f/Macro_1.scala b/tests/run/i4947f/Macro_1.scala index c18b3c0a7eba..97dbed912dd7 100644 --- a/tests/run/i4947f/Macro_1.scala +++ b/tests/run/i4947f/Macro_1.scala @@ -9,6 +9,6 @@ object Macros { println(~expr) } - inline def assert2(expr: => Boolean): Unit = ~Macros.assertImpl('(expr)) + inline def assert2(expr: => Boolean): Unit = ~Macros.assertImpl('{expr}) } diff --git a/tests/run/i5119/Macro_1.scala b/tests/run/i5119/Macro_1.scala index c0be1daf8560..6041252d2f6c 100644 --- a/tests/run/i5119/Macro_1.scala +++ b/tests/run/i5119/Macro_1.scala @@ -3,7 +3,7 @@ import scala.tasty.Reflection object Macro { class StringContextOps(sc: => StringContext) { - inline def ff(args: => Any*): String = ~Macro.impl('(sc), '(args)) + inline def ff(args: => Any*): String = ~Macro.impl('{sc}, '{args}) } implicit inline def XmlQuote(sc: => StringContext): StringContextOps = new StringContextOps(sc) def impl(sc: Expr[StringContext], args: Expr[Seq[Any]])(implicit reflect: Reflection): Expr[String] = { diff --git a/tests/run/i5119b/Macro_1.scala b/tests/run/i5119b/Macro_1.scala index e2be2b6fb147..be398f2c457d 100644 --- a/tests/run/i5119b/Macro_1.scala +++ b/tests/run/i5119b/Macro_1.scala @@ -3,7 +3,7 @@ import scala.tasty.Reflection object Macro { - inline def ff(arg1: Any, arg2: Any): String = ~Macro.impl('(arg1), '(arg2)) + inline def ff(arg1: Any, arg2: Any): String = ~Macro.impl('{arg1}, '{arg2}) def impl(arg1: Expr[Any], arg2: Expr[Any])(implicit reflect: Reflection): Expr[String] = { import reflect._ diff --git a/tests/run/i5386.scala b/tests/run/i5386.scala index eff28a2601f9..1543fa3f6938 100644 --- a/tests/run/i5386.scala +++ b/tests/run/i5386.scala @@ -1,6 +1,6 @@ object Test extends App { - ~{ + ${ println("!") 1 } diff --git a/tests/run/i5533/Macro_1.scala b/tests/run/i5533/Macro_1.scala index 05552fcc7513..afd547f80eda 100644 --- a/tests/run/i5533/Macro_1.scala +++ b/tests/run/i5533/Macro_1.scala @@ -6,7 +6,7 @@ object scalatest { def f(x: Int): Boolean = false def f(x: String): Boolean = true - inline def assert(condition: => Boolean): Unit = ~assertImpl('(condition)) + inline def assert(condition: => Boolean): Unit = ${assertImpl('{condition})} def assertImpl(condition: Expr[Boolean])(implicit refl: Reflection): Expr[Unit] = { import refl._ @@ -15,6 +15,6 @@ object scalatest { val expr = tree.seal[Boolean] - '(println(~expr)) + '{println($expr)} } } diff --git a/tests/run/i5533b/Macro_1.scala b/tests/run/i5533b/Macro_1.scala index ad63176aa2cd..3af4d58fde05 100644 --- a/tests/run/i5533b/Macro_1.scala +++ b/tests/run/i5533b/Macro_1.scala @@ -5,7 +5,7 @@ object scalatest { def f(x: Int): Int = x def f(x: String): String = x - inline def assert(condition: => Boolean): Unit = ~assertImpl('(condition)) + inline def assert(condition: => Boolean): Unit = ~assertImpl('{condition}) def assertImpl(condition: Expr[Boolean])(implicit refl: Reflection): Expr[Unit] = { import refl._ diff --git a/tests/run/i5536/Macro_1.scala b/tests/run/i5536/Macro_1.scala index 58e986cad5e7..e4e0e67a09b0 100644 --- a/tests/run/i5536/Macro_1.scala +++ b/tests/run/i5536/Macro_1.scala @@ -2,7 +2,7 @@ import scala.quoted._ import scala.tasty._ object scalatest { - inline def assert(condition: => Boolean): Unit = ~assertImpl('(condition)) + inline def assert(condition: => Boolean): Unit = ~assertImpl('{condition}) def assertImpl(condition: Expr[Boolean])(implicit refl: Reflection): Expr[Unit] = { import refl._ diff --git a/tests/run/i5606.scala b/tests/run/i5606.scala index 8bbad0138813..a7b9fc340b60 100644 --- a/tests/run/i5606.scala +++ b/tests/run/i5606.scala @@ -1,14 +1,14 @@ object Test extends App { - def (f: A => B) $[A, B](a: A): B = f(a) + def (f: A => B) `$`[A, B](a: A): B = f(a) - assert((((a: Int) => a.toString()) $ 10) == "10") + assert((((a: Int) => a.toString()) `$` 10) == "10") def g(x: Int): String = x.toString - assert((g $ 10) == "10") + assert((g `$` 10) == "10") val h: Int => String = _.toString - assert((h $ 10) == "10") + assert((h `$` 10) == "10") } diff --git a/tests/run/inline-macro-staged-interpreter/Macro_1.scala b/tests/run/inline-macro-staged-interpreter/Macro_1.scala index 11bdd3533e00..c22c8dd72f1d 100644 --- a/tests/run/inline-macro-staged-interpreter/Macro_1.scala +++ b/tests/run/inline-macro-staged-interpreter/Macro_1.scala @@ -36,21 +36,21 @@ trait Op2[T] { trait Plus2[T] extends Op2[T] object Plus2 { implicit case object IPlus extends Plus2[Int] { - def apply(x: Expr[Int], y: Expr[Int]): Expr[Int] = '(~x + ~y) + def apply(x: Expr[Int], y: Expr[Int]): Expr[Int] = '{~x + ~y} } implicit case object DPlus extends Plus2[Double] { - def apply(x: Expr[Double], y: Expr[Double]): Expr[Double] = '(~x + ~y) + def apply(x: Expr[Double], y: Expr[Double]): Expr[Double] = '{~x + ~y} } } trait Times2[T] extends Op2[T] object Times2 { implicit case object ITimes extends Times2[Int] { - def apply(x: Expr[Int], y: Expr[Int]): Expr[Int] = '(~x * ~y) + def apply(x: Expr[Int], y: Expr[Int]): Expr[Int] = '{~x * ~y} } implicit case object DTimes extends Times2[Double] { - def apply(x: Expr[Double], y: Expr[Double]): Expr[Double] = '(~x * ~y) + def apply(x: Expr[Double], y: Expr[Double]): Expr[Double] = '{~x * ~y} } } diff --git a/tests/run/inline-option/Macro_1.scala b/tests/run/inline-option/Macro_1.scala index 6f278bcf5403..59f5f8f3f9ea 100644 --- a/tests/run/inline-option/Macro_1.scala +++ b/tests/run/inline-option/Macro_1.scala @@ -5,7 +5,7 @@ object Macros { def impl(opt: Option[Int]): Expr[Int] = opt match { case Some(i) => i.toExpr - case None => '(-1) + case None => '{-1} } def impl2(opt: Option[Option[Int]]): Expr[Int] = impl(opt.flatten) diff --git a/tests/run/quote-and-splice/Macros_1.scala b/tests/run/quote-and-splice/Macros_1.scala index ef3706464b41..652f8f6b1e70 100644 --- a/tests/run/quote-and-splice/Macros_1.scala +++ b/tests/run/quote-and-splice/Macros_1.scala @@ -3,25 +3,25 @@ import scala.quoted._ object Macros { inline def macro1 = ~ macro1Impl - def macro1Impl = '(3) + def macro1Impl = '{3} inline def macro2(inline p: Boolean) = ~ macro2Impl(p) - def macro2Impl(p: Boolean) = if (p) '(3) else '(4) + def macro2Impl(p: Boolean) = if (p) '{3} else '{4} - inline def macro3(n: Int) = ~ macro3Impl('(n)) + inline def macro3(n: Int) = ~ macro3Impl('{n}) def macro3Impl(p: Expr[Int]) = '{ 2 + ~p } - inline def macro4(i: Int)(j: Int) = ~ macro4Impl('(i))('(j)) + inline def macro4(i: Int)(j: Int) = ~ macro4Impl('{i})('{j}) def macro4Impl(i: Expr[Int])(j: Expr[Int]) = '{ ~i + ~j } - inline def macro5(i: Int, j: Int) = ~ macro5Impl(j = '(j), i = '(i)) + inline def macro5(i: Int, j: Int) = ~ macro5Impl(j = '{j}, i = '{i}) def macro5Impl(i: Expr[Int], j: Expr[Int]) = '{ ~i + ~j } - inline def power(inline n: Int, x: Double) = ~powerCode(n, '(x)) + inline def power(inline n: Int, x: Double) = ~powerCode(n, '{x}) def powerCode(n: Int, x: Expr[Double]): Expr[Double] = - if (n == 0) '(1.0) + if (n == 0) '{1.0} else if (n == 1) x - else if (n % 2 == 0) '{ { val y = ~x * ~x; ~powerCode(n / 2, '(y)) } } + else if (n % 2 == 0) '{ { val y = ~x * ~x; ~powerCode(n / 2, '{y}) } } else '{ ~x * ~powerCode(n - 1, x) } } diff --git a/tests/run/quote-change-owner/Macro_1.scala b/tests/run/quote-change-owner/Macro_1.scala index 7ae01816db48..fe41e653efe7 100644 --- a/tests/run/quote-change-owner/Macro_1.scala +++ b/tests/run/quote-change-owner/Macro_1.scala @@ -1,6 +1,6 @@ import scala.quoted._ object Macros { - inline def assert2(expr: => Boolean): Unit = ~ assertImpl('(expr)) + inline def assert2(expr: => Boolean): Unit = ~ assertImpl('{expr}) def assertImpl(expr: Expr[Boolean]) = '{ def foo(): Unit = ~expr foo() diff --git a/tests/run/quote-compile-constants.scala b/tests/run/quote-compile-constants.scala index bcf98ff0f88b..9fd8a478f82c 100644 --- a/tests/run/quote-compile-constants.scala +++ b/tests/run/quote-compile-constants.scala @@ -2,19 +2,19 @@ import scala.quoted._ object Test { def main(args: Array[String]): Unit = { - println(('(true)).getClass) + println(('{true}).getClass) println(('{ 'a' }).getClass) println(('{ '\n' }).getClass) println(('{ '"' }).getClass) println(('{ '\'' }).getClass) println(('{ '\\' }).getClass) - println(('(1)).getClass) - println(('( { { 2 } } )).getClass) - println(('(3L)).getClass) - println(('(4.0f)).getClass) - println(('(5.0d)).getClass) - println(('("xyz")).getClass) - println(('()).getClass) + println(('{1}).getClass) + println(('{ { { 2 } } }).getClass) + println(('{3L}).getClass) + println(('{4.0f}).getClass) + println(('{5.0d}).getClass) + println(('{"xyz"}).getClass) + println(('{}).getClass) println(('{()}).getClass) println(('{{()}}).getClass) } diff --git a/tests/run/quote-force/quoted_1.scala b/tests/run/quote-force/quoted_1.scala index 47c01a3c3abf..24f235074b82 100644 --- a/tests/run/quote-force/quoted_1.scala +++ b/tests/run/quote-force/quoted_1.scala @@ -4,15 +4,15 @@ case class Location(owners: List[String]) object Location { - implicit inline def location: Location = ~impl + implicit inline def location: Location = ${impl} def impl: Expr[Location] = { val list = List("a", "b", "c", "d", "e", "f") - '(new Location(~list.toExpr)) + '{new Location(${list.toExpr})} } private implicit def ListIsLiftable[T : Liftable : Type]: Liftable[List[T]] = { - case x :: xs => '{ ~x.toExpr :: ~xs.toExpr } + case x :: xs => '{ ${x.toExpr} :: ${xs.toExpr} } case Nil => '{ List.empty[T] } } } diff --git a/tests/run/quote-indexed-map-by-name/quoted_1.scala b/tests/run/quote-indexed-map-by-name/quoted_1.scala index 32ed34bac0e6..5696310081b5 100644 --- a/tests/run/quote-indexed-map-by-name/quoted_1.scala +++ b/tests/run/quote-indexed-map-by-name/quoted_1.scala @@ -5,9 +5,9 @@ object Index { implicit def zero[K, T]: Index[K, (K, T)] = new Index(0) - implicit inline def succ[K, H, T](implicit prev: => Index[K, T]): Index[K, (H, T)] = ~succImpl('[K], '[H], '[T]) + implicit inline def succ[K, H, T](implicit prev: => Index[K, T]): Index[K, (H, T)] = ${succImpl('[K], '[H], '[T])} def succImpl[K, H, T](implicit k: Type[K], h: Type[H], t: Type[T]): Expr[Index[K, (H, T)]] = { - '(new Index(0)) + '{new Index(0)} } } \ No newline at end of file diff --git a/tests/run/quote-sep-comp-2/Test_2.scala b/tests/run/quote-sep-comp-2/Test_2.scala index 30be33cad19c..c756443b4848 100644 --- a/tests/run/quote-sep-comp-2/Test_2.scala +++ b/tests/run/quote-sep-comp-2/Test_2.scala @@ -1,7 +1,7 @@ object Test { - inline def assert2(expr: => Boolean): Unit = ~Macros.assertImpl('(expr)) + inline def assert2(expr: => Boolean): Unit = ~Macros.assertImpl('{expr}) def main(args: Array[String]): Unit = { val x = 1 diff --git a/tests/run/quote-sep-comp/Macro_1.scala b/tests/run/quote-sep-comp/Macro_1.scala index c3ce7e2e1d53..b8b73c3016fc 100644 --- a/tests/run/quote-sep-comp/Macro_1.scala +++ b/tests/run/quote-sep-comp/Macro_1.scala @@ -1,5 +1,5 @@ import scala.quoted._ object Macros { - inline def assert2(expr: => Boolean): Unit = ~ assertImpl('(expr)) + inline def assert2(expr: => Boolean): Unit = ~ assertImpl('{expr}) def assertImpl(expr: Expr[Boolean]) = '{ println(~expr) } } diff --git a/tests/run/quote-simple-hole.scala b/tests/run/quote-simple-hole.scala index 2fcb905abc3e..6caa33bf9139 100644 --- a/tests/run/quote-simple-hole.scala +++ b/tests/run/quote-simple-hole.scala @@ -1,13 +1,13 @@ object Test { def main(args: Array[String]): Unit = { - val x = '(0) - val y = '(~x) - val z = '(~('(~y))) + val x = '{0} + val y = '{$x} + val z = '{${'{$y}}} assert(x eq y) assert(x eq z) val i = '[Int] - val j = '[~i] + val j = '[$i] assert(i eq j) } } diff --git a/tests/run/quote-simple-macro/quoted_1.scala b/tests/run/quote-simple-macro/quoted_1.scala index 9f3dbea2f0c5..87109ebd4070 100644 --- a/tests/run/quote-simple-macro/quoted_1.scala +++ b/tests/run/quote-simple-macro/quoted_1.scala @@ -1,6 +1,6 @@ import scala.quoted._ object Macros { - inline def foo(inline i: Int, dummy: Int, j: Int): Int = ~bar(i, '(j)) - def bar(x: Int, y: Expr[Int]): Expr[Int] = '{ ~x.toExpr + ~y } + inline def foo(inline i: Int, dummy: Int, j: Int): Int = ~bar(i, '{j}) + def bar(x: Int, y: Expr[Int]): Expr[Int] = '{ ${x.toExpr} + ~y } } diff --git a/tests/run/quote-unrolled-foreach/quoted_1.scala b/tests/run/quote-unrolled-foreach/quoted_1.scala index 0f1ac1d3599a..e7b3da4e294c 100644 --- a/tests/run/quote-unrolled-foreach/quoted_1.scala +++ b/tests/run/quote-unrolled-foreach/quoted_1.scala @@ -4,21 +4,21 @@ import scala.quoted._ object Macro { inline def unrolledForeach(inline unrollSize: Int, seq: Array[Int])(f: => Int => Unit): Unit = // or f: Int => Unit - ~unrolledForeachImpl(unrollSize, '(seq), '(f)) + ${unrolledForeachImpl(unrollSize, '{seq}, '{f})} private def unrolledForeachImpl(unrollSize: Int, seq: Expr[Array[Int]], f: Expr[Int => Unit]): Expr[Unit] = '{ - val size = (~seq).length - assert(size % (~unrollSize.toExpr) == 0) // for simplicity of the implementation + val size = $seq.length + assert(size % (${unrollSize.toExpr}) == 0) // for simplicity of the implementation var i = 0 while (i < size) { println(" start loop") - ~{ + ${ @tailrec def loop(j: Int, acc: Expr[Unit]): Expr[Unit] = - if (j >= 0) loop(j - 1, '{ ~f('((~seq)(i + ~j.toExpr))); ~acc }) + if (j >= 0) loop(j - 1, '{ ${f('{$seq(i + ${j.toExpr})})}; $acc }) else acc - loop(unrollSize - 1, '()) + loop(unrollSize - 1, '{}) } - i += ~unrollSize.toExpr + i += ${unrollSize.toExpr} } } } diff --git a/tests/run/reflect-select-copy/assert_1.scala b/tests/run/reflect-select-copy/assert_1.scala index 498bd48c4c2d..a127be649336 100644 --- a/tests/run/reflect-select-copy/assert_1.scala +++ b/tests/run/reflect-select-copy/assert_1.scala @@ -3,7 +3,7 @@ import scala.tasty._ object scalatest { - inline def assert(condition: => Boolean): Unit = ~assertImpl('(condition), '("")) + inline def assert(condition: => Boolean): Unit = ~assertImpl('{condition}, '{""}) def assertImpl(cond: Expr[Boolean], clue: Expr[Any])(implicit refl: Reflection): Expr[Unit] = { import refl._ diff --git a/tests/run/t6111.scala b/tests/run/t6111.scala index 915c23b446fe..2fa6c55a109b 100644 --- a/tests/run/t6111.scala +++ b/tests/run/t6111.scala @@ -23,6 +23,6 @@ object Test extends dotty.runtime.LegacyApp { case Foo(p) => p // p should be a pair of Int }) - // Prints '(x, x)' + // Prints '{x, x}' "x" match { case Foo997(a) => println(a) } } diff --git a/tests/run/t6888.scala b/tests/run/t6888.scala index f58116c31c59..af69c6063d29 100644 --- a/tests/run/t6888.scala +++ b/tests/run/t6888.scala @@ -1,6 +1,6 @@ class C { val x = 1 - object $ { + object `$` { val y = x + x class abc$ { def xy = x + y @@ -13,7 +13,7 @@ class C { object Test extends dotty.runtime.LegacyApp { val c = new C() - println(c.$.y) - println(c.$.abc$.xy) - println(new c.$.abc$().xy) + println(c.`$`.y) + println(c.`$`.abc$.xy) + println(new c.`$`.abc$().xy) } diff --git a/tests/run/tasty-argument-tree-1.check b/tests/run/tasty-argument-tree-1.check index b6b86afcffc1..26c3d1e13212 100644 --- a/tests/run/tasty-argument-tree-1.check +++ b/tests/run/tasty-argument-tree-1.check @@ -1,33 +1,33 @@ -tree: Term.Literal(Constant.Int(3)) +tree: Term.Block(Nil, Term.Literal(Constant.Int(3))) tree deref. vals: Term.Literal(Constant.Int(3)) -tree: Term.Ident("v") +tree: Term.Block(Nil, Term.Ident("v")) tree deref. vals: Term.Literal(Constant.Int(1)) -tree: Term.Ident("x") +tree: Term.Block(Nil, Term.Ident("x")) tree deref. vals: Term.Literal(Constant.Int(2)) -tree: Term.Ident("l") +tree: Term.Block(Nil, Term.Ident("l")) tree deref. vals: Term.Literal(Constant.Int(3)) -tree: Term.Ident("a") +tree: Term.Block(Nil, Term.Ident("a")) tree deref. vals: Term.Ident("a") -tree: Term.Ident("x") +tree: Term.Block(Nil, Term.Ident("x")) tree deref. vals: Term.Ident("b") -tree: Term.Ident("vv") +tree: Term.Block(Nil, Term.Ident("vv")) tree deref. vals: Term.Literal(Constant.Int(1)) -tree: Term.Ident("x") +tree: Term.Block(Nil, Term.Ident("x")) tree deref. vals: Term.Literal(Constant.Int(1)) -tree: Term.Ident("vd") +tree: Term.Block(Nil, Term.Ident("vd")) tree deref. vals: Term.Literal(Constant.Int(2)) -tree: Term.Ident("x") +tree: Term.Block(Nil, Term.Ident("x")) tree deref. vals: Term.Literal(Constant.Int(2)) -tree: Term.Ident("x") +tree: Term.Block(Nil, Term.Ident("x")) tree deref. vals: Term.Apply(Term.TypeApply(Term.Select(Term.Ident("Tuple2"), "apply"), List(TypeTree.Inferred(), TypeTree.Inferred())), List(Term.Literal(Constant.Int(1)), Term.Literal(Constant.Int(2)))) diff --git a/tests/run/tasty-argument-tree-1/quoted_1.scala b/tests/run/tasty-argument-tree-1/quoted_1.scala index 496332724bb2..5b20542b2467 100644 --- a/tests/run/tasty-argument-tree-1/quoted_1.scala +++ b/tests/run/tasty-argument-tree-1/quoted_1.scala @@ -3,15 +3,15 @@ import scala.tasty._ object Macros { - inline def inspect[T](x: T): Unit = ~impl('(x)) + inline def inspect[T](x: T): Unit = ~impl('{x}) def impl[T](x: Expr[T])(implicit reflect: Reflection): Expr[Unit] = { import reflect._ val tree = x.unseal '{ println() - println("tree: " + ~tree.show.toExpr) - println("tree deref. vals: " + ~tree.underlying.show.toExpr) + println("tree: " + ${tree.show.toExpr}) + println("tree deref. vals: " + ${tree.underlying.show.toExpr}) } } } diff --git a/tests/run/tasty-custom-show/quoted_1.scala b/tests/run/tasty-custom-show/quoted_1.scala index 96c51a43dd80..7bec29d426cd 100644 --- a/tests/run/tasty-custom-show/quoted_1.scala +++ b/tests/run/tasty-custom-show/quoted_1.scala @@ -5,7 +5,7 @@ import scala.tasty.Reflection object Macros { implicit inline def printOwners[T](x: => T): Unit = - ~impl('(x)) + ~impl('{x}) def impl[T](x: Expr[T])(implicit reflect: Reflection): Expr[Unit] = { import reflect._ @@ -35,7 +35,7 @@ object Macros { val tree = x.unseal output.traverseTree(tree) - '(print(~buff.result().toExpr)) + '{print(${buff.result().toExpr})} } def dummyShow(implicit reflect: Reflection): reflect.Printer = { diff --git a/tests/run/tasty-definitions-1/quoted_1.scala b/tests/run/tasty-definitions-1/quoted_1.scala index 6382461d5b3e..f9d565e16d3c 100644 --- a/tests/run/tasty-definitions-1/quoted_1.scala +++ b/tests/run/tasty-definitions-1/quoted_1.scala @@ -4,7 +4,7 @@ import scala.tasty._ object Macros { - inline def testDefinitions(): Unit = ~testDefinitionsImpl + inline def testDefinitions(): Unit = ${testDefinitionsImpl} def testDefinitionsImpl(implicit reflect: Reflection): Expr[Unit] = { import reflect._ @@ -93,7 +93,7 @@ object Macros { printout(definitions.StringType.show) - '(println(~buff.result().mkString("\n").toExpr)) + '{println(${buff.result().mkString("\n").toExpr})} } } diff --git a/tests/run/tasty-eval/quoted_1.scala b/tests/run/tasty-eval/quoted_1.scala index b06f2bc82c94..dd4e5ee98d0c 100644 --- a/tests/run/tasty-eval/quoted_1.scala +++ b/tests/run/tasty-eval/quoted_1.scala @@ -5,7 +5,7 @@ import scala.tasty._ object Macros { implicit inline def foo(i: Int): String = - ~impl('(i)) + ~impl('{i}) def impl(i: Expr[Int])(implicit reflect: Reflection): Expr[String] = { value(i).toString.toExpr diff --git a/tests/run/tasty-extractors-1.check b/tests/run/tasty-extractors-1.check index b04fa977ed07..94e361b976b0 100644 --- a/tests/run/tasty-extractors-1.check +++ b/tests/run/tasty-extractors-1.check @@ -1,19 +1,19 @@ -Term.Literal(Constant.Boolean(true)) +Term.Block(Nil, Term.Literal(Constant.Boolean(true))) Type.ConstantType(Constant.Boolean(true)) -Term.Literal(Constant.Int(1)) +Term.Block(Nil, Term.Literal(Constant.Int(1))) Type.ConstantType(Constant.Int(1)) -Term.Literal(Constant.Long(2)) +Term.Block(Nil, Term.Literal(Constant.Long(2))) Type.ConstantType(Constant.Long(2)) -Term.Literal(Constant.Float(2.1)) +Term.Block(Nil, Term.Literal(Constant.Float(2.1))) Type.ConstantType(Constant.Float(2.1)) -Term.Literal(Constant.Double(2.2)) +Term.Block(Nil, Term.Literal(Constant.Double(2.2))) Type.ConstantType(Constant.Double(2.2)) -Term.Literal(Constant.String("abc")) +Term.Block(Nil, Term.Literal(Constant.String("abc"))) Type.ConstantType(Constant.String("abc")) Term.Inlined(None, Nil, Term.Apply(Term.Ident("println"), List(Term.Literal(Constant.String("abc"))))) @@ -28,7 +28,7 @@ Type.SymRef(IsClassSymbol(), Type.SymRef(IsPackageSymbol(), T Term.Inlined(None, Nil, Term.Typed(Term.Literal(Constant.Short(8)), TypeTree.Ident("Short"))) Type.SymRef(IsClassSymbol(), Type.SymRef(IsPackageSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(<>), NoPrefix())))) -Term.Literal(Constant.Char(a)) +Term.Block(Nil, Term.Literal(Constant.Char(a))) Type.ConstantType(Constant.Char(a)) Term.Inlined(None, Nil, Term.Block(List(Term.Literal(Constant.Int(1)), Term.Literal(Constant.Int(2))), Term.Literal(Constant.Int(3)))) diff --git a/tests/run/tasty-extractors-1/quoted_1.scala b/tests/run/tasty-extractors-1/quoted_1.scala index ad349107df4a..df20178d8a97 100644 --- a/tests/run/tasty-extractors-1/quoted_1.scala +++ b/tests/run/tasty-extractors-1/quoted_1.scala @@ -5,7 +5,7 @@ import scala.tasty._ object Macros { implicit inline def printTree[T](x: => T): Unit = - ~impl('(x)) + ~impl('{x}) def impl[T](x: Expr[T])(implicit reflect: Reflection): Expr[Unit] = { import reflect._ @@ -15,8 +15,8 @@ object Macros { val treeTpeStr = tree.tpe.show '{ - println(~treeStr.toExpr) - println(~treeTpeStr.toExpr) + println(${treeStr.toExpr}) + println(${treeTpeStr.toExpr}) println() } } diff --git a/tests/run/tasty-extractors-2.check b/tests/run/tasty-extractors-2.check index 2f98f387de8a..39cae9f16ad5 100644 --- a/tests/run/tasty-extractors-2.check +++ b/tests/run/tasty-extractors-2.check @@ -7,7 +7,7 @@ Type.AppliedType(Type.SymRef(IsClassSymbol(), Type.ThisType(Typ Term.Inlined(None, Nil, Term.Ident("???")) Type.SymRef(IsDefSymbol(), Type.SymRef(IsValSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix())))) -Term.Literal(Constant.Int(1)) +Term.Block(Nil, Term.Literal(Constant.Int(1))) Type.ConstantType(Constant.Int(1)) Term.Inlined(None, Nil, Term.Typed(Term.Literal(Constant.Int(1)), TypeTree.Ident("Int"))) diff --git a/tests/run/tasty-extractors-2/quoted_1.scala b/tests/run/tasty-extractors-2/quoted_1.scala index 0d82d75da91f..89ac3994e81e 100644 --- a/tests/run/tasty-extractors-2/quoted_1.scala +++ b/tests/run/tasty-extractors-2/quoted_1.scala @@ -5,7 +5,7 @@ import scala.tasty._ object Macros { implicit inline def printTree[T](x: => T): Unit = - ~impl('(x)) + ~impl('{x}) def impl[T](x: Expr[T])(implicit reflect: Reflection): Expr[Unit] = { import reflect._ @@ -16,8 +16,8 @@ object Macros { val treeTpeStr = tree.tpe.show '{ - println(~treeStr.toExpr) - println(~treeTpeStr.toExpr) + println(${treeStr.toExpr}) + println(${treeTpeStr.toExpr}) println() } } diff --git a/tests/run/tasty-extractors-3/quoted_1.scala b/tests/run/tasty-extractors-3/quoted_1.scala index 921a389db5e8..cbf74db9cd7d 100644 --- a/tests/run/tasty-extractors-3/quoted_1.scala +++ b/tests/run/tasty-extractors-3/quoted_1.scala @@ -5,7 +5,7 @@ import scala.tasty.Reflection object Macros { implicit inline def printTypes[T](x: => T): Unit = - ~impl('(x)) + ${impl('{x})} def impl[T](x: Expr[T])(implicit reflect: Reflection): Expr[Unit] = { import reflect._ @@ -21,6 +21,6 @@ object Macros { val tree = x.unseal traverser.traverseTree(tree) - '(print(~buff.result().toExpr)) + '{print(${buff.result().toExpr})} } } diff --git a/tests/run/tasty-extractors-constants-1/quoted_1.scala b/tests/run/tasty-extractors-constants-1/quoted_1.scala index d9b6f1ead5f7..1b298081e3cb 100644 --- a/tests/run/tasty-extractors-constants-1/quoted_1.scala +++ b/tests/run/tasty-extractors-constants-1/quoted_1.scala @@ -5,7 +5,7 @@ import scala.tasty.util._ object Macros { - implicit inline def testMacro: Unit = ~impl + implicit inline def testMacro: Unit = ${impl} def impl(implicit reflect: Reflection): Expr[Unit] = { import reflect._ @@ -16,12 +16,12 @@ object Macros { val Constant = new ConstantExtractor(reflect) 3.toExpr match { case Constant(n) => stagedPrintln(n) } - '(4) match { case Constant(n) => stagedPrintln(n) } - '("abc") match { case Constant(n) => stagedPrintln(n) } - '(null) match { case Constant(n) => stagedPrintln(n) } + '{4} match { case Constant(n) => stagedPrintln(n) } + '{"abc"} match { case Constant(n) => stagedPrintln(n) } + '{null} match { case Constant(n) => stagedPrintln(n) } - '(new Object) match { case Constant(n) => println(n); case _ => stagedPrintln("OK") } + '{new Object} match { case Constant(n) => println(n); case _ => stagedPrintln("OK") } - '(print(~buff.result().toExpr)) + '{print(${buff.result().toExpr})} } } diff --git a/tests/run/tasty-extractors-types/quoted_1.scala b/tests/run/tasty-extractors-types/quoted_1.scala index fb683ab4f81b..9c720dbb5859 100644 --- a/tests/run/tasty-extractors-types/quoted_1.scala +++ b/tests/run/tasty-extractors-types/quoted_1.scala @@ -11,8 +11,8 @@ object Macros { val tree = x.unseal '{ - println(~tree.show.toExpr) - println(~tree.tpe.show.toExpr) + println(${tree.show.toExpr}) + println(${tree.tpe.show.toExpr}) println() } } diff --git a/tests/run/tasty-implicit-fun-context-2/Macro_1.scala b/tests/run/tasty-implicit-fun-context-2/Macro_1.scala index 07c838ee6503..a34036a6b2a6 100644 --- a/tests/run/tasty-implicit-fun-context-2/Macro_1.scala +++ b/tests/run/tasty-implicit-fun-context-2/Macro_1.scala @@ -10,7 +10,7 @@ object Foo { ~fooImpl def fooImpl(implicit reflect: Reflection): given Reflection => Tastier[given Reflection => Macro[String]] = { - '("abc") + '{"abc"} } } diff --git a/tests/run/tasty-indexed-map/quoted_1.scala b/tests/run/tasty-indexed-map/quoted_1.scala index e6e31700910c..e84e95eb3372 100644 --- a/tests/run/tasty-indexed-map/quoted_1.scala +++ b/tests/run/tasty-indexed-map/quoted_1.scala @@ -24,7 +24,7 @@ object Index { implicit def zero[K, T]: Index[K, (K, T)] = new Index(0) - implicit inline def succ[K, H, T](implicit prev: => Index[K, T]): Index[K, (H, T)] = ~succImpl[K, H, T] + implicit inline def succ[K, H, T](implicit prev: => Index[K, T]): Index[K, (H, T)] = ${succImpl[K, H, T]} def succImpl[K, H, T](implicit reflect: Reflection, k: Type[K], h: Type[H], t: Type[T]): Expr[Index[K, (H, T)]] = { import reflect._ @@ -43,6 +43,6 @@ object Index { val index = keys.indexOf(key) - '(new Index(~index.toExpr)) + '{new Index(${index.toExpr})} } } diff --git a/tests/run/tasty-interpolation-1/Macro.scala b/tests/run/tasty-interpolation-1/Macro.scala index 2846a1030642..8bbd1f732013 100644 --- a/tests/run/tasty-interpolation-1/Macro.scala +++ b/tests/run/tasty-interpolation-1/Macro.scala @@ -8,26 +8,26 @@ import scala.quoted.Toolbox.Default._ object Macro { class StringContextOps(strCtx: => StringContext) { - inline def s2(args: Any*): String = ~SIntepolator('(strCtx), '(args)) - inline def raw2(args: Any*): String = ~RawIntepolator('(strCtx), '(args)) - inline def foo(args: Any*): String = ~FooIntepolator('(strCtx), '(args)) + inline def s2(args: Any*): String = ${SIntepolator('{strCtx}, '{args})} + inline def raw2(args: Any*): String = ${RawIntepolator('{strCtx}, '{args})} + inline def foo(args: Any*): String = ${FooIntepolator('{strCtx}, '{args})} } implicit inline def SCOps(strCtx: => StringContext): StringContextOps = new StringContextOps(strCtx) } object SIntepolator extends MacroStringInterpolator[String] { protected def interpolate(strCtx: StringContext, args: List[Expr[Any]])(implicit reflect: Reflection): Expr[String] = - '((~strCtx.toExpr).s(~args.toExprOfList: _*)) + '{(${strCtx.toExpr}).s(${args.toExprOfList}: _*)} } object RawIntepolator extends MacroStringInterpolator[String] { protected def interpolate(strCtx: StringContext, args: List[Expr[Any]])(implicit reflect: Reflection): Expr[String] = - '((~strCtx.toExpr).raw(~args.toExprOfList: _*)) + '{(${strCtx.toExpr}).raw(${args.toExprOfList}: _*)} } object FooIntepolator extends MacroStringInterpolator[String] { protected def interpolate(strCtx: StringContext, args: List[Expr[Any]])(implicit reflect: Reflection): Expr[String] = - '((~strCtx.toExpr).s(~args.map(_ => '("foo")).toExprOfList: _*)) + '{(${strCtx.toExpr}).s(${args.map(_ => '{"foo"}).toExprOfList}: _*)} } // TODO put this class in the stdlib or separate project? @@ -80,11 +80,11 @@ abstract class MacroStringInterpolator[T] { // TODO define in stdlib? implicit def ListIsLiftable: Liftable[List[String]] = new Liftable[List[String]] { override def toExpr(list: List[String]): Expr[List[String]] = list match { - case x :: xs => '(~x.toExpr :: ~toExpr(xs)) - case Nil => '(Nil) + case x :: xs => '{${x.toExpr} :: ${toExpr(xs)}} + case Nil => '{Nil} } } - '(StringContext(~strCtx.parts.toList.toExpr: _*)) + '{StringContext(${strCtx.parts.toList.toExpr}: _*)} } } diff --git a/tests/run/tasty-linenumber-2/quoted_1.scala b/tests/run/tasty-linenumber-2/quoted_1.scala index 164a326e9040..fd7e303da349 100644 --- a/tests/run/tasty-linenumber-2/quoted_1.scala +++ b/tests/run/tasty-linenumber-2/quoted_1.scala @@ -8,11 +8,11 @@ class LineNumber(val value: Int) { object LineNumber { - implicit inline def line: LineNumber = ~lineImpl + implicit inline def line: LineNumber = ${lineImpl} def lineImpl(implicit reflect: Reflection): Expr[LineNumber] = { import reflect._ - '(new LineNumber(~rootPosition.startLine.toExpr)) + '{new LineNumber(${rootPosition.startLine.toExpr})} } } diff --git a/tests/run/tasty-linenumber/quoted_1.scala b/tests/run/tasty-linenumber/quoted_1.scala index 1e4df5b9637b..49c64f59e1e4 100644 --- a/tests/run/tasty-linenumber/quoted_1.scala +++ b/tests/run/tasty-linenumber/quoted_1.scala @@ -9,11 +9,11 @@ class LineNumber(val value: Int) { object LineNumber { implicit inline def line[T >: Unit <: Unit]: LineNumber = - ~lineImpl('[T]) + ${lineImpl('[T])} def lineImpl(x: Type[Unit])(implicit reflect: Reflection): Expr[LineNumber] = { import reflect._ - '(new LineNumber(~rootPosition.startLine.toExpr)) + '{new LineNumber(${rootPosition.startLine.toExpr})} } } diff --git a/tests/run/tasty-location/quoted_1.scala b/tests/run/tasty-location/quoted_1.scala index ddcf0e5a5e96..24755e59123b 100644 --- a/tests/run/tasty-location/quoted_1.scala +++ b/tests/run/tasty-location/quoted_1.scala @@ -6,7 +6,7 @@ case class Location(owners: List[String]) object Location { - implicit inline def location: Location = ~impl + implicit inline def location: Location = ${impl} def impl(implicit reflect: Reflection): Expr[Location] = { import reflect._ @@ -16,11 +16,11 @@ object Location { else listOwnerNames(sym.owner, sym.name :: acc) val list = listOwnerNames(rootContext.owner, Nil) - '(new Location(~list.toExpr)) + '{new Location(${list.toExpr})} } private implicit def ListIsLiftable[T : Liftable : Type]: Liftable[List[T]] = { - case x :: xs => '{ ~x.toExpr :: ~xs.toExpr } + case x :: xs => '{ ${x.toExpr} :: ${xs.toExpr} } case Nil => '{ List.empty[T] } } } diff --git a/tests/run/tasty-macro-assert/quoted_1.scala b/tests/run/tasty-macro-assert/quoted_1.scala index ae804284fa9e..ea7b121f69f4 100644 --- a/tests/run/tasty-macro-assert/quoted_1.scala +++ b/tests/run/tasty-macro-assert/quoted_1.scala @@ -12,7 +12,7 @@ object Asserts { object Ops inline def macroAssert(cond: => Boolean): Unit = - ~impl('(cond)) + ${impl('{cond})} def impl(cond: Expr[Boolean])(implicit reflect: Reflection): Expr[Unit] = { import reflect._ @@ -35,11 +35,11 @@ object Asserts { tree match { case Term.Inlined(_, Nil, Term.Apply(Term.Select(OpsTree(left), op), right :: Nil)) => op match { - case "===" => '(assertEquals(~left.seal[Any], ~right.seal[Any])) - case "!==" => '(assertNotEquals(~left.seal[Any], ~right.seal[Any])) + case "===" => '{assertEquals(${left.seal[Any]}, ${right.seal[Any]})} + case "!==" => '{assertNotEquals(${left.seal[Any]}, ${right.seal[Any]})} } case _ => - '(assertTrue(~cond)) + '{assertTrue($cond)} } } diff --git a/tests/run/tasty-macro-const/quoted_1.scala b/tests/run/tasty-macro-const/quoted_1.scala index 9d4a5dc970c3..73d12d4a3f21 100644 --- a/tests/run/tasty-macro-const/quoted_1.scala +++ b/tests/run/tasty-macro-const/quoted_1.scala @@ -3,7 +3,7 @@ import scala.tasty._ object Macros { - inline def natConst(x: Int): Int = ~natConstImpl('(x)) + inline def natConst(x: Int): Int = ${ natConstImpl('{x}) } def natConstImpl(x: Expr[Int])(implicit reflection: Reflection): Expr[Int] = { import reflection._ diff --git a/tests/run/tasty-original-source/Macros_1.scala b/tests/run/tasty-original-source/Macros_1.scala index 44ce6448bbe7..c463f35be58c 100644 --- a/tests/run/tasty-original-source/Macros_1.scala +++ b/tests/run/tasty-original-source/Macros_1.scala @@ -3,12 +3,12 @@ import scala.tasty._ object Macros { - implicit inline def withSource(arg: Any): (String, Any) = ~impl('(arg)) + implicit inline def withSource(arg: Any): (String, Any) = ~impl('{arg}) private def impl(arg: Expr[Any])(implicit reflect: Reflection): Expr[(String, Any)] = { import reflect._ val source = arg.unseal.underlyingArgument.pos.sourceCode.toString.toExpr - '(Tuple2(~source, ~arg)) + '{Tuple2($source, $arg)} } } diff --git a/tests/run/tasty-positioned/quoted_1.scala b/tests/run/tasty-positioned/quoted_1.scala index 070453104e45..8eab35ed86aa 100644 --- a/tests/run/tasty-positioned/quoted_1.scala +++ b/tests/run/tasty-positioned/quoted_1.scala @@ -9,7 +9,7 @@ case class Positioned[T](value: T, position: Position) object Positioned { - implicit inline def apply[T](x: => T): Positioned[T] = ~impl('(x)) + implicit inline def apply[T](x: => T): Positioned[T] = ${impl('{x})} def impl[T](x: Expr[T])(implicit ev: Type[T], reflect: Reflection): Expr[Positioned[T]] = { import reflect.{Position => _, _} @@ -23,7 +23,7 @@ object Positioned { val startColumn = pos.startColumn.toExpr val endColumn = pos.endColumn.toExpr - val liftedPosition = '(new Position(~path, ~start, ~end, ~startLine, ~startColumn, ~endLine, ~endColumn)) - '(Positioned[T](~x, ~liftedPosition)) + val liftedPosition = '{new Position($path, $start, $end, $startLine, $startColumn, $endLine, $endColumn)} + '{Positioned[T]($x, $liftedPosition)} } } diff --git a/tests/run/tasty-seal-method/quoted_1.scala b/tests/run/tasty-seal-method/quoted_1.scala index 09ecf2b9e936..b71ed47598ab 100644 --- a/tests/run/tasty-seal-method/quoted_1.scala +++ b/tests/run/tasty-seal-method/quoted_1.scala @@ -5,7 +5,7 @@ import scala.tasty._ object Asserts { inline def zeroLastArgs(x: => Int): Int = - ~zeroLastArgsImpl('(x)) + ~zeroLastArgsImpl('{x}) /** Replaces last argument list by 0s */ def zeroLastArgsImpl(x: Expr[Int])(implicit reflect: Reflection): Expr[Int] = { @@ -17,9 +17,9 @@ object Asserts { case Type.IsMethodType(_) => args.size match { case 0 => fn.seal[() => Int].apply() - case 1 => fn.seal[Int => Int].apply('(0)) - case 2 => fn.seal[(Int, Int) => Int].apply('(0), '(0)) - case 3 => fn.seal[(Int, Int, Int) => Int].apply('(0), '(0), '(0)) + case 1 => fn.seal[Int => Int].apply('{0}) + case 2 => fn.seal[(Int, Int) => Int].apply('{0}, '{0}) + case 3 => fn.seal[(Int, Int, Int) => Int].apply('{0}, '{0}, '{0}) } } case _ => x @@ -27,7 +27,7 @@ object Asserts { } inline def zeroAllArgs(x: => Int): Int = - ~zeroAllArgsImpl('(x)) + ~zeroAllArgsImpl('{x}) /** Replaces all argument list by 0s */ def zeroAllArgsImpl(x: Expr[Int])(implicit reflect: Reflection): Expr[Int] = { @@ -38,9 +38,9 @@ object Asserts { val pre = rec(fn) args.size match { case 0 => pre.seal[() => Any].apply().unseal - case 1 => pre.seal[Int => Any].apply('(0)).unseal - case 2 => pre.seal[(Int, Int) => Any].apply('(0), '(0)).unseal - case 3 => pre.seal[(Int, Int, Int) => Any].apply('(0), '(0), '(0)).unseal + case 1 => pre.seal[Int => Any].apply('{0}).unseal + case 2 => pre.seal[(Int, Int) => Any].apply('{0}, '{0}).unseal + case 3 => pre.seal[(Int, Int, Int) => Any].apply('{0}, '{0}, '{0}).unseal } case _ => term } diff --git a/tests/run/tasty-subtyping/quoted_1.scala b/tests/run/tasty-subtyping/quoted_1.scala index 3aecfd9505aa..c0b8831e2c2f 100644 --- a/tests/run/tasty-subtyping/quoted_1.scala +++ b/tests/run/tasty-subtyping/quoted_1.scala @@ -5,10 +5,10 @@ import scala.tasty._ object Macros { inline def isTypeEqual[T, U]: Boolean = - ~isTypeEqualImpl('[T], '[U]) + ${isTypeEqualImpl('[T], '[U])} inline def isSubTypeOf[T, U]: Boolean = - ~isSubTypeOfImpl('[T], '[U]) + ${isSubTypeOfImpl('[T], '[U])} def isTypeEqualImpl[T, U](t: Type[T], u: Type[U])(implicit reflect: Reflection): Expr[Boolean] = { import reflect._ diff --git a/tests/run/tasty-tree-map/quoted_1.scala b/tests/run/tasty-tree-map/quoted_1.scala index ceb98beb1343..fc9216017e01 100644 --- a/tests/run/tasty-tree-map/quoted_1.scala +++ b/tests/run/tasty-tree-map/quoted_1.scala @@ -3,7 +3,7 @@ import scala.tasty._ object Macros { - implicit inline def identityMaped[T](x: => T): T = ~impl('(x)) + implicit inline def identityMaped[T](x: => T): T = ~impl('{x}) def impl[T: Type](x: Expr[T])(implicit reflection: Reflection): Expr[T] = { import reflection._ diff --git a/tests/run/tasty-typeof/Macro_1.scala b/tests/run/tasty-typeof/Macro_1.scala index 90c716fd6982..efa49c533282 100644 --- a/tests/run/tasty-typeof/Macro_1.scala +++ b/tests/run/tasty-typeof/Macro_1.scala @@ -8,25 +8,25 @@ object Macros { private def testTypeOfImpl(implicit reflect: Reflection): Expr[Unit] = { import reflect._ '{ - assert(~(typeOf[Unit] =:= definitions.UnitType).toExpr, "Unit") - assert(~(typeOf[Byte] =:= definitions.ByteType).toExpr, "Byte") - assert(~(typeOf[Short] =:= definitions.ShortType).toExpr, "Short") - assert(~(typeOf[Int] =:= definitions.IntType).toExpr, "Int") - assert(~(typeOf[Long] =:= definitions.LongType).toExpr, "Long") - assert(~(typeOf[Float] =:= definitions.FloatType).toExpr, "Float") - assert(~(typeOf[Double] =:= definitions.DoubleType).toExpr, "Double") - assert(~(typeOf[Char] =:= definitions.CharType).toExpr, "Char") - assert(~(typeOf[String] =:= definitions.StringType).toExpr, "String") + assert(${(typeOf[Unit] =:= definitions.UnitType).toExpr}, "Unit") + assert(${(typeOf[Byte] =:= definitions.ByteType).toExpr}, "Byte") + assert(${(typeOf[Short] =:= definitions.ShortType).toExpr}, "Short") + assert(${(typeOf[Int] =:= definitions.IntType).toExpr}, "Int") + assert(${(typeOf[Long] =:= definitions.LongType).toExpr}, "Long") + assert(${(typeOf[Float] =:= definitions.FloatType).toExpr}, "Float") + assert(${(typeOf[Double] =:= definitions.DoubleType).toExpr}, "Double") + assert(${(typeOf[Char] =:= definitions.CharType).toExpr}, "Char") + assert(${(typeOf[String] =:= definitions.StringType).toExpr}, "String") - assert(~(typeOf[Any] =:= definitions.AnyType).toExpr, "Any") - assert(~(typeOf[AnyRef] =:= definitions.AnyRefType).toExpr, "AnyRef") - assert(~(typeOf[AnyVal] =:= definitions.AnyValType).toExpr, "AnyVal") - assert(~(typeOf[Object] =:= definitions.ObjectType).toExpr, "Object") - assert(~(typeOf[Nothing] =:= definitions.NothingType).toExpr, "Nothing") + assert(${(typeOf[Any] =:= definitions.AnyType).toExpr}, "Any") + assert(${(typeOf[AnyRef] =:= definitions.AnyRefType).toExpr}, "AnyRef") + assert(${(typeOf[AnyVal] =:= definitions.AnyValType).toExpr}, "AnyVal") + assert(${(typeOf[Object] =:= definitions.ObjectType).toExpr}, "Object") + assert(${(typeOf[Nothing] =:= definitions.NothingType).toExpr}, "Nothing") - println(~(typeOf[List[Int]].showCode.toExpr)) - println(~(typeOf[Macros].showCode.toExpr)) - println(~(typeOf[Macros.type].showCode.toExpr)) + println(${typeOf[List[Int]].showCode.toExpr}) + println(${typeOf[Macros].showCode.toExpr}) + println(${typeOf[Macros.type].showCode.toExpr}) } } diff --git a/tests/run/xml-interpolation-1/XmlQuote_1.scala b/tests/run/xml-interpolation-1/XmlQuote_1.scala index 56c9a624ae20..072c42a3c9c5 100644 --- a/tests/run/xml-interpolation-1/XmlQuote_1.scala +++ b/tests/run/xml-interpolation-1/XmlQuote_1.scala @@ -8,7 +8,7 @@ case class Xml(parts: String, args: List[Any]) object XmlQuote { implicit class SCOps(ctx: StringContext) { - inline def xml(args: => Any*): Xml = ~XmlQuote.impl('(this), '(args)) + inline def xml(args: => Any*): Xml = ${XmlQuote.impl('{this}, '{args})} } def impl(receiver: Expr[SCOps], args: Expr[Seq[Any]]) @@ -29,8 +29,8 @@ object XmlQuote { case x :: xs => val head = x.seal[Any] val tail = liftListOfAny(xs) - '{ ~head :: ~tail } - case Nil => '(Nil) + '{ $head :: $tail } + case Nil => '{Nil} } def isStringConstant(tree: Term) = tree match { @@ -59,6 +59,6 @@ object XmlQuote { val Typed(Repeated(args0, _), _) = args.unseal.underlyingArgument val string = parts.mkString("??") - '(new Xml(~string.toExpr, ~liftListOfAny(args0))) + '{new Xml(${string.toExpr}, ${liftListOfAny(args0)})} } } diff --git a/tests/run/xml-interpolation-2/XmlQuote_1.scala b/tests/run/xml-interpolation-2/XmlQuote_1.scala index c51f145f9642..6cb5d363c8fb 100644 --- a/tests/run/xml-interpolation-2/XmlQuote_1.scala +++ b/tests/run/xml-interpolation-2/XmlQuote_1.scala @@ -10,7 +10,7 @@ case class Xml(parts: String, args: List[Any]) object XmlQuote { class SCOps(ctx: => StringContext) { - inline def xml(args: Any*): Xml = ~XmlQuote.impl('(this), '(args)) + inline def xml(args: Any*): Xml = ~XmlQuote.impl('{this}, '{args}) } implicit inline def SCOps(ctx: => StringContext): SCOps = new SCOps(ctx) @@ -58,11 +58,11 @@ object XmlQuote { case Typed(Repeated(args0, _), _) => // statically known args, make list directly args0.map(_.seal[Any]).toExprOfList case _ => - '((~args).toList) + '{$args.toList} } val string = parts.mkString("??") - '(new Xml(~string.toExpr, ~args2)) + '{new Xml(${string.toExpr}, $args2)} } } diff --git a/tests/run/xml-interpolation-3/XmlQuote_1.scala b/tests/run/xml-interpolation-3/XmlQuote_1.scala index 34402cd470b7..5316b3589741 100644 --- a/tests/run/xml-interpolation-3/XmlQuote_1.scala +++ b/tests/run/xml-interpolation-3/XmlQuote_1.scala @@ -9,11 +9,11 @@ object XmlQuote { implicit object SCOps { inline def (inline ctx: StringContext) xml (args: => Any*): Xml = - ~XmlQuote.impl(ctx, '(args)) + ${XmlQuote.impl(ctx, '{args})} } def impl(receiver: StringContext, args: Expr[Seq[Any]]): Expr[Xml] = { val string = receiver.parts.mkString("??") - '(new Xml(~string.toExpr, (~args).toList)) + '{new Xml(${string.toExpr}, $args.toList)} } } diff --git a/tests/untried/neg/t997.scala b/tests/untried/neg/t997.scala index 1198738f2495..63c396b89920 100644 --- a/tests/untried/neg/t997.scala +++ b/tests/untried/neg/t997.scala @@ -3,10 +3,10 @@ object Foo { def unapply(x : String) = Some((x, x)) } object Test extends App { -// Prints '(x, x)'. Should compile as per SI-6111. +// Prints '{x, x}'. Should compile as per SI-6111. "x" match { case Foo(a) => Console.println(a) } -// Prints '(x,x)' as expected. +// Prints '{x,x}' as expected. "x" match { case Foo(a, b) => Console.println((a,b)) } // Gives confusing error 'not found: value c'. From 6faa0dfdbad0197d67b2b8807eef64b103623e5a Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Thu, 14 Feb 2019 12:53:49 +0100 Subject: [PATCH 04/26] Use nme.UNARY_~ directly --- compiler/src/dotty/tools/dotc/ast/Desugar.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/ast/Desugar.scala b/compiler/src/dotty/tools/dotc/ast/Desugar.scala index 55b8b58b54ae..9c2ced566d32 100644 --- a/compiler/src/dotty/tools/dotc/ast/Desugar.scala +++ b/compiler/src/dotty/tools/dotc/ast/Desugar.scala @@ -1319,9 +1319,9 @@ object desugar { else Apply(ref(defn.QuotedExpr_applyR), t) case Splice(expr) => - Select(expr, nme.UNARY_PREFIX ++ nme.raw.TILDE) + Select(expr, nme.UNARY_~) case TypSplice(expr) => - Select(expr, tpnme.UNARY_PREFIX ++ nme.raw.TILDE) + Select(expr, tpnme.UNARY_~) case InterpolatedString(id, segments) => val strs = segments map { case ts: Thicket => ts.trees.head From a067989bb306e38dc2986c386b8a11202450ad3b Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Mon, 18 Feb 2019 12:20:00 +0100 Subject: [PATCH 05/26] Fix some tests --- tests/pos/i4774e.scala | 4 ++-- tests/pos/i4774f.scala | 4 ++-- tests/pos/quote-liftable-list-2.scala | 4 ++-- tests/pos/quote-liftable-list.scala | 2 +- tests/run/tasty-macro-const/quoted_1.scala | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/pos/i4774e.scala b/tests/pos/i4774e.scala index d836c86093d8..9d5118aec02c 100644 --- a/tests/pos/i4774e.scala +++ b/tests/pos/i4774e.scala @@ -3,8 +3,8 @@ import scala.quoted._ object Test { def loop[T](x: Expr[T])(implicit t: Type[T]): Expr[T] = - '{ def y = ~x; ~loop('(y)) } + '{ def y = $x; ${ loop('{y}) } } def loop2[T](x: Expr[T])(implicit t: Type[T]): Expr[T] = - '{ def y() = ~x; ~loop('(y())) } + '{ def y() = $x; ${ loop('{y()}) } } } diff --git a/tests/pos/i4774f.scala b/tests/pos/i4774f.scala index 37b6031e8fb6..c4bd2bd16aba 100644 --- a/tests/pos/i4774f.scala +++ b/tests/pos/i4774f.scala @@ -3,8 +3,8 @@ import scala.quoted._ object Test { def loop[T](x: Expr[T])(implicit t: Type[T]): Expr[T] = - '{ def y: T = ~x; ~loop('(y)) } + '{ def y: T = $x; ${ loop('{y}) } } def loop2[T](x: Expr[T])(implicit t: Type[T]): Expr[T] = - '{ def y(): T = ~x; ~loop('(y())) } + '{ def y(): T = $x; ${ loop('{y()}) } } } diff --git a/tests/pos/quote-liftable-list-2.scala b/tests/pos/quote-liftable-list-2.scala index e249c388d475..6c946cc36334 100644 --- a/tests/pos/quote-liftable-list-2.scala +++ b/tests/pos/quote-liftable-list-2.scala @@ -3,11 +3,11 @@ import scala.quoted._ object Test { implicit def ListIsLiftableOr[T: Type, U: Type]: Liftable[List[T | U]] = new { - def toExpr(xs: List[T | U]): Expr[List[T | U]] = '(Nil: List[T | U]) + def toExpr(xs: List[T | U]): Expr[List[T | U]] = '{ Nil: List[T | U] } } implicit def ListIsLiftableAnd[T: Type, U: Type]: Liftable[List[T & U]] = new { - def toExpr(xs: List[T & U]): Expr[List[T & U]] = '(Nil: List[T & U]) + def toExpr(xs: List[T & U]): Expr[List[T & U]] = '{ Nil: List[T & U] } } } diff --git a/tests/pos/quote-liftable-list.scala b/tests/pos/quote-liftable-list.scala index fdefe80801a4..7b5e091b8b80 100644 --- a/tests/pos/quote-liftable-list.scala +++ b/tests/pos/quote-liftable-list.scala @@ -3,7 +3,7 @@ import scala.quoted._ object Test { implicit def ListIsLiftable[T: Liftable: Type]: Liftable[List[T]] = new { - def toExpr(xs: List[T]): Expr[List[T]] = '(Nil: List[T]) + def toExpr(xs: List[T]): Expr[List[T]] = '{ Nil: List[T] } } } diff --git a/tests/run/tasty-macro-const/quoted_1.scala b/tests/run/tasty-macro-const/quoted_1.scala index 73d12d4a3f21..fc60765e7271 100644 --- a/tests/run/tasty-macro-const/quoted_1.scala +++ b/tests/run/tasty-macro-const/quoted_1.scala @@ -9,7 +9,7 @@ object Macros { import reflection._ val xTree: Term = x.unseal xTree match { - case Term.Literal(Constant.Int(n)) => + case Term.Block(Nil, Term.Literal(Constant.Int(n))) => if (n <= 0) throw new QuoteError("Parameter must be natural number") xTree.seal[Int] From eee09d42eefdbf24aa4677422a0a355f7a1ccfb9 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Mon, 18 Feb 2019 12:24:29 +0100 Subject: [PATCH 06/26] Fix more tests --- .../Yretain-trees/tasty-definitions-2/Macro_1.scala | 2 +- .../Yretain-trees/tasty-definitions-3/Macro_1.scala | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/run-custom-args/Yretain-trees/tasty-definitions-2/Macro_1.scala b/tests/run-custom-args/Yretain-trees/tasty-definitions-2/Macro_1.scala index 1ce3115c1f19..c9ebceca0a8b 100644 --- a/tests/run-custom-args/Yretain-trees/tasty-definitions-2/Macro_1.scala +++ b/tests/run-custom-args/Yretain-trees/tasty-definitions-2/Macro_1.scala @@ -15,7 +15,7 @@ object Foo { } x.unseal match { case Term.Inlined(None, Nil, arg) => definitionString(arg) - case arg => definitionString(arg) // TODO should all by name parameters be in an inline node? + case Term.Block(Nil, arg) => definitionString(arg) // TODO should all by name parameters be in an inline node? } } diff --git a/tests/run-custom-args/Yretain-trees/tasty-definitions-3/Macro_1.scala b/tests/run-custom-args/Yretain-trees/tasty-definitions-3/Macro_1.scala index 5c8a70abad71..070f47ae1385 100644 --- a/tests/run-custom-args/Yretain-trees/tasty-definitions-3/Macro_1.scala +++ b/tests/run-custom-args/Yretain-trees/tasty-definitions-3/Macro_1.scala @@ -15,7 +15,7 @@ object Foo { } x.unseal match { case Term.Inlined(None, Nil, arg) => definitionString(arg) - case arg => definitionString(arg) // TODO should all by name parameters be in an inline node? + case Term.Block(Nil, arg) => definitionString(arg) // TODO should all by name parameters be in an inline node? } } } From e2086dabbfbdcef36d82dc8e417236b8edb15aa0 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Mon, 18 Feb 2019 12:52:27 +0100 Subject: [PATCH 07/26] Fix ${ 'x } -> x and '{ $x } -> x transformation --- .../dotc/transform/TreeMapWithStages.scala | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/transform/TreeMapWithStages.scala b/compiler/src/dotty/tools/dotc/transform/TreeMapWithStages.scala index a7cba635b7f0..58896d9e4c4e 100644 --- a/compiler/src/dotty/tools/dotc/transform/TreeMapWithStages.scala +++ b/compiler/src/dotty/tools/dotc/transform/TreeMapWithStages.scala @@ -76,18 +76,24 @@ abstract class TreeMapWithStages(@constructorOnly ictx: Context) extends TreeMap enteredSyms = enteredSyms.tail } + def dropEmptyBlocks(tree: Tree): Tree = tree match { + case Block(Nil, expr) => dropEmptyBlocks(expr) + case _ => tree + } + tree match { - case Quoted(Spliced(t)) => - transform(t) // '(~x) --> x case Quoted(quotedTree) => - transformQuotation(quotedTree, tree) - - case Spliced(Quoted(quotedTree)) => - transform(quotedTree) // ~('x) --> x + dropEmptyBlocks(quotedTree) match { + case Spliced(t) => transform(t) // '{ $x } --> x + case _ => transformQuotation(quotedTree, tree) + } - case tree @ Spliced(_) => - transformSplice(tree) + case tree @ Spliced(splicedTree) => + dropEmptyBlocks(splicedTree) match { + case Quoted(t) => transform(t) // ${ 'x } --> x + case _ => transformSplice(tree) + } case Block(stats, _) => val last = enteredSyms From 26ca22111d7fbc8ea3cc2c2209f0d403e1c3a425 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Mon, 18 Feb 2019 12:55:08 +0100 Subject: [PATCH 08/26] Add regression tests --- tests/run/quote-simple-hole.scala | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/run/quote-simple-hole.scala b/tests/run/quote-simple-hole.scala index 6caa33bf9139..5bfcf0ac45cd 100644 --- a/tests/run/quote-simple-hole.scala +++ b/tests/run/quote-simple-hole.scala @@ -3,8 +3,12 @@ object Test { val x = '{0} val y = '{$x} val z = '{${'{$y}}} + val a = '{{{$x}}} + val b = '{{${{'{{$y}}}}}} assert(x eq y) assert(x eq z) + assert(x eq a) + assert(x eq b) val i = '[Int] val j = '[$i] From d749bd9cebec1115fafeb530d2896f95e224fa75 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Mon, 18 Feb 2019 14:58:23 +0100 Subject: [PATCH 09/26] Adapt more tests --- tests/run-with-compiler/quote-lib.scala | 32 +++++++------- tests/run-with-compiler/quote-owners-2.scala | 6 +-- .../quote-run-staged-interpreter.scala | 2 +- .../quote-unrolled-foreach.scala | 44 +++++++++---------- .../reflect-select-copy/assert_1.scala | 6 +-- 5 files changed, 45 insertions(+), 45 deletions(-) diff --git a/tests/run-with-compiler/quote-lib.scala b/tests/run-with-compiler/quote-lib.scala index 5b81ffc10009..2c7a35b00f6c 100644 --- a/tests/run-with-compiler/quote-lib.scala +++ b/tests/run-with-compiler/quote-lib.scala @@ -60,40 +60,40 @@ package liftable { object Lets { def letVal[T, U: Type](expr: Expr[T])(body: Expr[T] => Expr[U])(implicit t: Type[T]): Expr[U] = - '{ val letVal: ~t = ~expr; ~body('{letVal}) } + '{ val letVal: $t = $expr; ${ body('{letVal}) } } def letLazyVal[T, U: Type](expr: Expr[T])(body: Expr[T] => Expr[U])(implicit t: Type[T]): Expr[U] = - '{ lazy val letLazyVal: ~t = ~expr; ~body('{letLazyVal}) } + '{ lazy val letLazyVal: $t = $expr; ${ body('{letLazyVal}) } } def letDef[T, U: Type](expr: Expr[T])(body: Expr[T] => Expr[U])(implicit t: Type[T]): Expr[U] = - '{ def letDef: ~t = ~expr; ~body('{letDef}) } + '{ def letDef: $t = $expr; ${ body('{letDef}) } } } object Loops { - def liftedWhile(cond: Expr[Boolean])(body: Expr[Unit]): Expr[Unit] = '{ while (~cond) ~body } - def liftedDoWhile(body: Expr[Unit])(cond: Expr[Boolean]): Expr[Unit] = '{ do ~body while (~cond) } + def liftedWhile(cond: Expr[Boolean])(body: Expr[Unit]): Expr[Unit] = '{ while ($cond) $body } + def liftedDoWhile(body: Expr[Unit])(cond: Expr[Boolean]): Expr[Unit] = '{ do $body while ($cond) } } object Tuples { implicit def Tuple1IsLiftable[T1: Liftable](implicit t1: Type[T1]): Liftable[Tuple1[T1]] = new Liftable[Tuple1[T1]] { def toExpr(x: Tuple1[T1]): Expr[Tuple1[T1]] = - '{ Tuple1[~t1](~x._1.toExpr) } + '{ Tuple1[$t1](${ x._1.toExpr}) } } implicit def Tuple2IsLiftable[T1: Liftable, T2: Liftable](implicit t1: Type[T1], t2: Type[T2]): Liftable[(T1, T2)] = new Liftable[(T1, T2)] { def toExpr(x: (T1, T2)): Expr[(T1, T2)] = - '{ Tuple2[~t1, ~t2](~x._1.toExpr, ~x._2.toExpr) } + '{ Tuple2[$t1, $t2](${x._1.toExpr}, ${x._2.toExpr}) } } implicit def Tuple3IsLiftable[T1: Liftable, T2: Liftable, T3: Liftable](implicit t1: Type[T1], t2: Type[T2], t3: Type[T3]): Liftable[(T1, T2, T3)] = new Liftable[(T1, T2, T3)] { def toExpr(x: (T1, T2, T3)): Expr[(T1, T2, T3)] = - '{ Tuple3[${t1, ~t2, ~t3](~x._1.toExpr, ~x._2.toExpr, ~x._3.toExpr}) } + '{ Tuple3[$t1, $t2, $t3](${x._1.toExpr}, ${x._2.toExpr}, ${x._3.toExpr}) } } implicit def Tuple4IsLiftable[T1: Liftable, T2: Liftable, T3: Liftable, T4: Liftable](implicit t1: Type[T1], t2: Type[T2], t3: Type[T3], t4: Type[T4]): Liftable[(T1, T2, T3, T4)] = new Liftable[(T1, T2, T3, T4)] { def toExpr(x: (T1, T2, T3, T4)): Expr[(T1, T2, T3, T4)] = - '{ Tuple4[~t1, ~t2, ~t3, ~t4](~x._1.toExpr, ~x._2.toExpr, ~x._3.toExpr, ~x._4.toExpr) } + '{ Tuple4[$t1, $t2, $t3, $t4](${x._1.toExpr}, ${x._2.toExpr}, ${x._3.toExpr}, ${x._4.toExpr}) } } // TODO more tuples @@ -104,32 +104,32 @@ package liftable { object Lists { implicit def ListIsLiftable[T: Liftable](implicit t: Type[T]): Liftable[List[T]] = new Liftable[List[T]] { def toExpr(x: List[T]): Expr[List[T]] = x match { - case x :: xs => '{ (~xs.toExpr).::[~t](~x.toExpr) } - case Nil => '{ Nil: List[~t] } + case x :: xs => '{ (${xs.toExpr}).::[$t](${x.toExpr}) } + case Nil => '{ Nil: List[$t] } } } implicit class LiftedOps[T: Liftable](list: Expr[List[T]])(implicit t: Type[T]) { def foldLeft[U](acc: Expr[U])(f: Expr[(U, T) => U])(implicit u: Type[U]): Expr[U] = - '{ (~list).foldLeft[~u](~acc)(~f) } + '{ ($list).foldLeft[$u]($acc)($f) } def foreach(f: Expr[T => Unit]): Expr[Unit] = - '{ (~list).foreach(~f) } + '{ ($list).foreach($f) } } implicit class UnrolledOps[T: Liftable](list: List[T])(implicit t: Type[T]) { def unrolledFoldLeft[U](acc: Expr[U])(f: Expr[(U, T) => U])(implicit u: Type[U]): Expr[U] = list match { - case x :: xs => xs.unrolledFoldLeft('{ (~f).apply(~acc, ~x.toExpr) })(f) + case x :: xs => xs.unrolledFoldLeft('{ ($f).apply($acc, ${x.toExpr}) })(f) case Nil => acc } def unrolledForeach(f: Expr[T => Unit]): Expr[Unit] = list match { - case x :: xs => '{ (${f).apply(${x.toExpr}}); ~xs.unrolledForeach(f) } + case x :: xs => '{ ($f).apply(${x.toExpr}); ${ xs.unrolledForeach(f) } } case Nil => '{} } } object Arrays { implicit def ArrayIsLiftable[T: Liftable](implicit t: Type[T], ct: Expr[ClassTag[T]]): Liftable[Array[T]] = new Liftable[Array[T]] { - def toExpr(arr: Array[T]): Expr[Array[T]] = '{ new Array[~t](~arr.length.toExpr)(~ct) } + def toExpr(arr: Array[T]): Expr[Array[T]] = '{ new Array[$t](${arr.length.toExpr})($ct) } } } diff --git a/tests/run-with-compiler/quote-owners-2.scala b/tests/run-with-compiler/quote-owners-2.scala index 78db786a24e6..94a1857cf617 100644 --- a/tests/run-with-compiler/quote-owners-2.scala +++ b/tests/run-with-compiler/quote-owners-2.scala @@ -13,8 +13,8 @@ object Test { def f(t: Type[List[Int]]): Expr[Int] = '{ def ff: Int = { - val a: ~t = { - type T = ~t + val a: $t = { + type T = $t val b: T = 3 :: Nil b } @@ -23,5 +23,5 @@ object Test { ff } - def g[T](a: Type[T]): Type[List[T]] = '[List[~a]] + def g[T](a: Type[T]): Type[List[T]] = '[List[$a]] } diff --git a/tests/run-with-compiler/quote-run-staged-interpreter.scala b/tests/run-with-compiler/quote-run-staged-interpreter.scala index 915418cd1552..216e179442d4 100644 --- a/tests/run-with-compiler/quote-run-staged-interpreter.scala +++ b/tests/run-with-compiler/quote-run-staged-interpreter.scala @@ -19,7 +19,7 @@ object Test { case Var(x) => env(x) case Let(x, e, body) => if (keepLets) - '{ val y = ${compileImpl(e, env)}; ${compileImpl(body, env + (x -> '{y})} } + '{ val y = ${compileImpl(e, env)}; ${compileImpl(body, env + (x -> '{y})) } } else compileImpl(body, env + (x -> compileImpl(e, env))) } diff --git a/tests/run-with-compiler/quote-unrolled-foreach.scala b/tests/run-with-compiler/quote-unrolled-foreach.scala index 13e5a391bbe9..49ef60b3c1f7 100644 --- a/tests/run-with-compiler/quote-unrolled-foreach.scala +++ b/tests/run-with-compiler/quote-unrolled-foreach.scala @@ -5,7 +5,7 @@ object Test { implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make def main(args: Array[String]): Unit = { - val code1 = '{ (arr: Array[Int], f: Int => Unit) => ${ foreach1('{arr}, '{f}) } + val code1 = '{ (arr: Array[Int], f: Int => Unit) => ${ foreach1('{arr}, '{f}) } } println(code1.show) println() @@ -54,65 +54,65 @@ object Test { } def foreach1Tpe1[T](arrRef: Expr[Array[T]], f: Expr[T => Unit])(implicit t: Type[T]): Expr[Unit] = '{ - val size = (~arrRef).length + val size = ($arrRef).length var i = 0 while (i < size) { - val element: ~t = (~arrRef)(i) - (~f)(element) + val element: $t = ($arrRef)(i) + ($f)(element) i += 1 } } def foreach1Tpe2[T: Type](arrRef: Expr[Array[T]], f: Expr[T => Unit]): Expr[Unit] = '{ - val size = (~arrRef).length + val size = ($arrRef).length var i = 0 while (i < size) { - val element: T = (~arrRef)(i) - (~f)(element) + val element: T = ($arrRef)(i) + ($f)(element) i += 1 } } def foreach2(arrRef: Expr[Array[Int]], f: Expr[Int => Unit]): Expr[Unit] = '{ - val size = (~arrRef).length + val size = ($arrRef).length var i = 0 while (i < size) { - val element = (~arrRef)(i) - ~f('{element}) // Use AppliedFuntion + val element = ($arrRef)(i) + ${ f('{element}) } // Use AppliedFuntion i += 1 } } def foreach3(arrRef: Expr[Array[Int]], f: Expr[Int => Unit]): Expr[Unit] = '{ - val size = (~arrRef).length + val size = ($arrRef).length var i = 0 if (size % 3 != 0) throw new Exception("...")// for simplicity of the implementation while (i < size) { - (~f)((~arrRef)(i)) - (~f)((~arrRef)(i + 1)) - (~f)((~arrRef)(i + 2)) + ($f)(($arrRef)(i)) + ($f)(($arrRef)(i + 1)) + ($f)(($arrRef)(i + 2)) i += 3 } } def foreach3_2(arrRef: Expr[Array[Int]], f: Expr[Int => Unit]): Expr[Unit] = '{ - val size = (~arrRef).length + val size = ($arrRef).length var i = 0 if (size % 3 != 0) throw new Exception("...")// for simplicity of the implementation while (i < size) { - (~f)((~arrRef)(i)) - (~f)((~arrRef)(i + 1)) - (~f)((~arrRef)(i + 2)) + ($f)(($arrRef)(i)) + ($f)(($arrRef)(i + 1)) + ($f)(($arrRef)(i + 2)) i += 3 } } def foreach4(arrRef: Expr[Array[Int]], f: Expr[Int => Unit], unrollSize: Int): Expr[Unit] = '{ - val size = (~arrRef).length + val size = ($arrRef).length var i = 0 if (size % ${unrollSize.toExpr} != 0) throw new Exception("...") // for simplicity of the implementation while (i < size) { - ~foreachInRange(0, unrollSize)(j => '{ (~f)((~arrRef)(i + ~j.toExpr)) }) + ${ foreachInRange(0, unrollSize)(j => '{ ($f)(($arrRef)(i + ${j.toExpr})) }) } i += ${unrollSize.toExpr} } } @@ -120,14 +120,14 @@ object Test { implicit object ArrayIntIsLiftable extends Liftable[Array[Int]] { override def toExpr(x: Array[Int]): Expr[Array[Int]] = '{ val array = new Array[Int](${x.length.toExpr}) - ~foreachInRange(0, x.length)(i => '{ array(~i.toExpr) = ~x(i).toExpr}) + ${ foreachInRange(0, x.length)(i => '{ array(${i.toExpr}) = ${x(i).toExpr}}) } array } } def foreachInRange(start: Int, end: Int)(f: Int => Expr[Unit]): Expr[Unit] = { @tailrec def unroll(i: Int, acc: Expr[Unit]): Expr[Unit] = - if (i < end) unroll(i + 1, '{ ~acc; ~f(i) }) else acc + if (i < end) unroll(i + 1, '{ $acc; ${f(i)} }) else acc if (start < end) unroll(start + 1, f(start)) else '{} } diff --git a/tests/run-with-compiler/reflect-select-copy/assert_1.scala b/tests/run-with-compiler/reflect-select-copy/assert_1.scala index 3537676ff1e2..0157a8875ae5 100644 --- a/tests/run-with-compiler/reflect-select-copy/assert_1.scala +++ b/tests/run-with-compiler/reflect-select-copy/assert_1.scala @@ -3,7 +3,7 @@ import scala.tasty._ object scalatest { - inline def assert(condition: => Boolean): Unit = ~assertImpl('(condition), '("")) + inline def assert(condition: => Boolean): Unit = ${ assertImpl('{condition}, '{""}) } def assertImpl(cond: Expr[Boolean], clue: Expr[Any])(implicit refl: Reflection): Expr[Unit] = { import refl._ @@ -21,7 +21,7 @@ object scalatest { val l = left.seal[Any] val r = right.seal[Any] val b = result.seal[Boolean] - val code = '{ scala.Predef.assert(~b) } + val code = '{ scala.Predef.assert(${b}) } code.unseal } } @@ -34,7 +34,7 @@ object scalatest { val l = left.seal[Any] val r = right.seal[Any] val b = result.seal[Boolean] - val code = '{ scala.Predef.assert(~b) } + val code = '{ scala.Predef.assert(${b}) } code.unseal } } From 5bc50ded28bcf6fc1a26a51fd96c493854ca0e4e Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 18 Feb 2019 17:21:37 +0100 Subject: [PATCH 10/26] Change id syntax --- docs/docs/internals/syntax.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/docs/docs/internals/syntax.md b/docs/docs/internals/syntax.md index 4a9c2f04559e..88e5a3f0e9b8 100644 --- a/docs/docs/internals/syntax.md +++ b/docs/docs/internals/syntax.md @@ -77,7 +77,9 @@ escape ::= ‘$$’ | ‘{’ Block [‘;’ whiteSpace stringFormat whiteSpace] ‘}’ stringFormat ::= {printableChar \ (‘"’ | ‘}’ | ‘ ’ | ‘\t’ | ‘\n’)} -symbolLiteral ::= ‘'’ plainid +symbolLiteral ::= ‘'’ plainid // until 2.13 +quoteId ::= ‘'’ plainid // from 3.1 +spliceId ::= '$' plainid comment ::= ‘/*’ “any sequence of characters; nested comments are allowed” ‘*/’ | ‘//’ “any sequence of characters up to end of line” @@ -158,7 +160,8 @@ SimpleType ::= SimpleType TypeArgs | ‘_’ SubtypeBounds | Refinement RefinedTypeTree(EmptyTree, refinement) | SimpleLiteral SingletonTypeTree(l) - | ‘$’ (id | ‘{’ Block ‘}’) + | spliceId // only inside quotes + | ‘$’ ‘{’ Block ‘}’ ArgTypes ::= Type {‘,’ Type} | NamedTypeArg {‘,’ NamedTypeArg} FunArgType ::= Type @@ -208,9 +211,11 @@ InfixExpr ::= PrefixExpr PrefixExpr ::= [‘-’ | ‘+’ | ‘~’ | ‘!’] SimpleExpr PrefixOp(expr, op) SimpleExpr ::= ‘new’ (ConstrApp [TemplateBody] | TemplateBody) New(constr | templ) | BlockExpr - | ‘'’ (id | ‘{’ Block ‘}’) + | ‘'’ ‘{’ Block ‘}’ | ‘'’ ‘[’ Type ‘]’ - | ‘$’ (id | ‘{’ Block ‘}’) + | ‘$’ ‘{’ Block ‘}’ + | spliceId // only inside quotes + | quoteId // only inside splices | SimpleExpr1 [‘_’] PostfixOp(expr, _) SimpleExpr1 ::= Literal | Path From c6cc337bb1beb6f815d90e3b2222009678509896 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 18 Feb 2019 17:35:47 +0100 Subject: [PATCH 11/26] Drop Block(...) around quoted and spliced expressions where possible --- compiler/src/dotty/tools/dotc/parsing/Parsers.scala | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index 6278b6aa30c2..e6374299a568 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -923,7 +923,12 @@ object Parsers { val saved = in.inQuote in.inQuote = isQuote inDefScopeBraces { - try block() finally in.inQuote = saved + try + block() match { + case Block(Nil, expr) => expr + case t => t + } + finally in.inQuote = saved } } From 7a715805c34aa55842e0a3fe2cff327d055df4f3 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Mon, 18 Feb 2019 19:40:44 +0100 Subject: [PATCH 12/26] Fix '{} --- compiler/src/dotty/tools/dotc/parsing/Parsers.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index e6374299a568..ae52ee0348fa 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -925,7 +925,8 @@ object Parsers { inDefScopeBraces { try block() match { - case Block(Nil, expr) => expr + case t @ Block(Nil, expr) => + if (expr.isEmpty) t else expr case t => t } finally in.inQuote = saved From 6bcd70c132516739ec2019f09f7ceb015db7ac00 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Mon, 18 Feb 2019 19:58:18 +0100 Subject: [PATCH 13/26] Readapt tests --- .../tasty-definitions-2/Macro_1.scala | 2 +- .../tasty-definitions-3/Macro_1.scala | 2 +- .../Yretain-trees/tasty-load-tree-1.check | 2 +- .../Yretain-trees/tasty-load-tree-2.check | 2 +- tests/run/tasty-argument-tree-1.check | 22 +++++++++---------- tests/run/tasty-extractors-1.check | 14 ++++++------ tests/run/tasty-extractors-2.check | 2 +- tests/run/tasty-macro-const/quoted_1.scala | 2 +- 8 files changed, 24 insertions(+), 24 deletions(-) diff --git a/tests/run-custom-args/Yretain-trees/tasty-definitions-2/Macro_1.scala b/tests/run-custom-args/Yretain-trees/tasty-definitions-2/Macro_1.scala index c9ebceca0a8b..1ce3115c1f19 100644 --- a/tests/run-custom-args/Yretain-trees/tasty-definitions-2/Macro_1.scala +++ b/tests/run-custom-args/Yretain-trees/tasty-definitions-2/Macro_1.scala @@ -15,7 +15,7 @@ object Foo { } x.unseal match { case Term.Inlined(None, Nil, arg) => definitionString(arg) - case Term.Block(Nil, arg) => definitionString(arg) // TODO should all by name parameters be in an inline node? + case arg => definitionString(arg) // TODO should all by name parameters be in an inline node? } } diff --git a/tests/run-custom-args/Yretain-trees/tasty-definitions-3/Macro_1.scala b/tests/run-custom-args/Yretain-trees/tasty-definitions-3/Macro_1.scala index 070f47ae1385..5c8a70abad71 100644 --- a/tests/run-custom-args/Yretain-trees/tasty-definitions-3/Macro_1.scala +++ b/tests/run-custom-args/Yretain-trees/tasty-definitions-3/Macro_1.scala @@ -15,7 +15,7 @@ object Foo { } x.unseal match { case Term.Inlined(None, Nil, arg) => definitionString(arg) - case Term.Block(Nil, arg) => definitionString(arg) // TODO should all by name parameters be in an inline node? + case arg => definitionString(arg) // TODO should all by name parameters be in an inline node? } } } diff --git a/tests/run-custom-args/Yretain-trees/tasty-load-tree-1.check b/tests/run-custom-args/Yretain-trees/tasty-load-tree-1.check index 042dfe094ee8..fa4dada79aef 100644 --- a/tests/run-custom-args/Yretain-trees/tasty-load-tree-1.check +++ b/tests/run-custom-args/Yretain-trees/tasty-load-tree-1.check @@ -1,2 +1,2 @@ DefDef("foo", Nil, Nil, TypeTree.Ident("Int"), Some(Term.Apply(Term.Select(Term.Literal(Constant.Int(1)), "+"), List(Term.Literal(Constant.Int(2)))))) -NO DEFINTION +ValDef("bar", TypeTree.Ident("Int"), Some(Term.Apply(Term.Select(Term.Literal(Constant.Int(2)), "+"), List(Term.Literal(Constant.Int(3)))))) diff --git a/tests/run-custom-args/Yretain-trees/tasty-load-tree-2.check b/tests/run-custom-args/Yretain-trees/tasty-load-tree-2.check index 042dfe094ee8..fa4dada79aef 100644 --- a/tests/run-custom-args/Yretain-trees/tasty-load-tree-2.check +++ b/tests/run-custom-args/Yretain-trees/tasty-load-tree-2.check @@ -1,2 +1,2 @@ DefDef("foo", Nil, Nil, TypeTree.Ident("Int"), Some(Term.Apply(Term.Select(Term.Literal(Constant.Int(1)), "+"), List(Term.Literal(Constant.Int(2)))))) -NO DEFINTION +ValDef("bar", TypeTree.Ident("Int"), Some(Term.Apply(Term.Select(Term.Literal(Constant.Int(2)), "+"), List(Term.Literal(Constant.Int(3)))))) diff --git a/tests/run/tasty-argument-tree-1.check b/tests/run/tasty-argument-tree-1.check index 26c3d1e13212..b6b86afcffc1 100644 --- a/tests/run/tasty-argument-tree-1.check +++ b/tests/run/tasty-argument-tree-1.check @@ -1,33 +1,33 @@ -tree: Term.Block(Nil, Term.Literal(Constant.Int(3))) +tree: Term.Literal(Constant.Int(3)) tree deref. vals: Term.Literal(Constant.Int(3)) -tree: Term.Block(Nil, Term.Ident("v")) +tree: Term.Ident("v") tree deref. vals: Term.Literal(Constant.Int(1)) -tree: Term.Block(Nil, Term.Ident("x")) +tree: Term.Ident("x") tree deref. vals: Term.Literal(Constant.Int(2)) -tree: Term.Block(Nil, Term.Ident("l")) +tree: Term.Ident("l") tree deref. vals: Term.Literal(Constant.Int(3)) -tree: Term.Block(Nil, Term.Ident("a")) +tree: Term.Ident("a") tree deref. vals: Term.Ident("a") -tree: Term.Block(Nil, Term.Ident("x")) +tree: Term.Ident("x") tree deref. vals: Term.Ident("b") -tree: Term.Block(Nil, Term.Ident("vv")) +tree: Term.Ident("vv") tree deref. vals: Term.Literal(Constant.Int(1)) -tree: Term.Block(Nil, Term.Ident("x")) +tree: Term.Ident("x") tree deref. vals: Term.Literal(Constant.Int(1)) -tree: Term.Block(Nil, Term.Ident("vd")) +tree: Term.Ident("vd") tree deref. vals: Term.Literal(Constant.Int(2)) -tree: Term.Block(Nil, Term.Ident("x")) +tree: Term.Ident("x") tree deref. vals: Term.Literal(Constant.Int(2)) -tree: Term.Block(Nil, Term.Ident("x")) +tree: Term.Ident("x") tree deref. vals: Term.Apply(Term.TypeApply(Term.Select(Term.Ident("Tuple2"), "apply"), List(TypeTree.Inferred(), TypeTree.Inferred())), List(Term.Literal(Constant.Int(1)), Term.Literal(Constant.Int(2)))) diff --git a/tests/run/tasty-extractors-1.check b/tests/run/tasty-extractors-1.check index 94e361b976b0..b04fa977ed07 100644 --- a/tests/run/tasty-extractors-1.check +++ b/tests/run/tasty-extractors-1.check @@ -1,19 +1,19 @@ -Term.Block(Nil, Term.Literal(Constant.Boolean(true))) +Term.Literal(Constant.Boolean(true)) Type.ConstantType(Constant.Boolean(true)) -Term.Block(Nil, Term.Literal(Constant.Int(1))) +Term.Literal(Constant.Int(1)) Type.ConstantType(Constant.Int(1)) -Term.Block(Nil, Term.Literal(Constant.Long(2))) +Term.Literal(Constant.Long(2)) Type.ConstantType(Constant.Long(2)) -Term.Block(Nil, Term.Literal(Constant.Float(2.1))) +Term.Literal(Constant.Float(2.1)) Type.ConstantType(Constant.Float(2.1)) -Term.Block(Nil, Term.Literal(Constant.Double(2.2))) +Term.Literal(Constant.Double(2.2)) Type.ConstantType(Constant.Double(2.2)) -Term.Block(Nil, Term.Literal(Constant.String("abc"))) +Term.Literal(Constant.String("abc")) Type.ConstantType(Constant.String("abc")) Term.Inlined(None, Nil, Term.Apply(Term.Ident("println"), List(Term.Literal(Constant.String("abc"))))) @@ -28,7 +28,7 @@ Type.SymRef(IsClassSymbol(), Type.SymRef(IsPackageSymbol(), T Term.Inlined(None, Nil, Term.Typed(Term.Literal(Constant.Short(8)), TypeTree.Ident("Short"))) Type.SymRef(IsClassSymbol(), Type.SymRef(IsPackageSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(<>), NoPrefix())))) -Term.Block(Nil, Term.Literal(Constant.Char(a))) +Term.Literal(Constant.Char(a)) Type.ConstantType(Constant.Char(a)) Term.Inlined(None, Nil, Term.Block(List(Term.Literal(Constant.Int(1)), Term.Literal(Constant.Int(2))), Term.Literal(Constant.Int(3)))) diff --git a/tests/run/tasty-extractors-2.check b/tests/run/tasty-extractors-2.check index 39cae9f16ad5..2f98f387de8a 100644 --- a/tests/run/tasty-extractors-2.check +++ b/tests/run/tasty-extractors-2.check @@ -7,7 +7,7 @@ Type.AppliedType(Type.SymRef(IsClassSymbol(), Type.ThisType(Typ Term.Inlined(None, Nil, Term.Ident("???")) Type.SymRef(IsDefSymbol(), Type.SymRef(IsValSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix())))) -Term.Block(Nil, Term.Literal(Constant.Int(1))) +Term.Literal(Constant.Int(1)) Type.ConstantType(Constant.Int(1)) Term.Inlined(None, Nil, Term.Typed(Term.Literal(Constant.Int(1)), TypeTree.Ident("Int"))) diff --git a/tests/run/tasty-macro-const/quoted_1.scala b/tests/run/tasty-macro-const/quoted_1.scala index fc60765e7271..73d12d4a3f21 100644 --- a/tests/run/tasty-macro-const/quoted_1.scala +++ b/tests/run/tasty-macro-const/quoted_1.scala @@ -9,7 +9,7 @@ object Macros { import reflection._ val xTree: Term = x.unseal xTree match { - case Term.Block(Nil, Term.Literal(Constant.Int(n))) => + case Term.Literal(Constant.Int(n)) => if (n <= 0) throw new QuoteError("Parameter must be natural number") xTree.seal[Int] From 8b0ba22f5a71011e047e4b46b46c7f9516e4dc1a Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Mon, 18 Feb 2019 20:20:04 +0100 Subject: [PATCH 14/26] Fix and adapt tests --- tests/run-with-compiler/i3847-b.scala | 2 +- tests/run-with-compiler/i3847.scala | 2 +- tests/run-with-compiler/i4044e.scala | 2 +- tests/run-with-compiler/i5247.scala | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/run-with-compiler/i3847-b.scala b/tests/run-with-compiler/i3847-b.scala index 926e1d8c1068..dd7cb855caca 100644 --- a/tests/run-with-compiler/i3847-b.scala +++ b/tests/run-with-compiler/i3847-b.scala @@ -6,7 +6,7 @@ object Arrays { implicit def ArrayIsLiftable[T: Liftable](implicit t: Type[T]): Liftable[Array[List[T]]] = { new Liftable[Array[List[T]]] { def toExpr(arr: Array[List[T]]): Expr[Array[List[T]]] = '{ - new Array[List[${t]](${arr.length.toExpr}}) + new Array[List[$t]](${arr.length.toExpr}) // TODO add elements } } diff --git a/tests/run-with-compiler/i3847.scala b/tests/run-with-compiler/i3847.scala index e15c215fb63c..d0420824e4a8 100644 --- a/tests/run-with-compiler/i3847.scala +++ b/tests/run-with-compiler/i3847.scala @@ -6,7 +6,7 @@ object Arrays { implicit def ArrayIsLiftable[T: Liftable](implicit t: Type[T], ct: Expr[ClassTag[T]]): Liftable[Array[T]] = { new Liftable[Array[T]] { def toExpr(arr: Array[T]): Expr[Array[T]] = '{ - new Array[${t](${arr.length.toExpr}})(~ct) + new Array[$t](${arr.length.toExpr})(~ct) // TODO add elements } } diff --git a/tests/run-with-compiler/i4044e.scala b/tests/run-with-compiler/i4044e.scala index dcd0cc5ea77f..05c82bed26ba 100644 --- a/tests/run-with-compiler/i4044e.scala +++ b/tests/run-with-compiler/i4044e.scala @@ -6,7 +6,7 @@ class Foo { val e: Expr[Int] = '{3} val f: Expr[Int] = '{5} val t: Type[Int] = '[Int] - val q = '{ ~( '{ (~e + ~f).asInstanceOf[~t] } ) } + val q = '{ ${ '{ ($e + $f).asInstanceOf[$t] } } } println(q.show) } } diff --git a/tests/run-with-compiler/i5247.scala b/tests/run-with-compiler/i5247.scala index 5a8d02ef3681..38e04d42aa12 100644 --- a/tests/run-with-compiler/i5247.scala +++ b/tests/run-with-compiler/i5247.scala @@ -7,10 +7,10 @@ object Test { } def foo[H : Type]: Expr[H] = { val t = '[H] - '{ null.asInstanceOf[~t] } + '{ null.asInstanceOf[$t] } } def bar[H : Type]: Expr[List[H]] = { val t = '[List[H]] - '{ null.asInstanceOf[~t] } + '{ null.asInstanceOf[$t] } } } From bc5e0688b134c73beb82754f43981c7830dfbd0d Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Tue, 19 Feb 2019 07:05:15 +0100 Subject: [PATCH 15/26] Rename $MaxSpecialized to MaxSpecialized --- library/src-bootstrapped/scala/StagedTuple.scala | 10 +++++----- library/src-bootstrapped/scala/Tuple.scala | 14 +++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/library/src-bootstrapped/scala/StagedTuple.scala b/library/src-bootstrapped/scala/StagedTuple.scala index c23d768e9e02..2ce1aaf67c2e 100644 --- a/library/src-bootstrapped/scala/StagedTuple.scala +++ b/library/src-bootstrapped/scala/StagedTuple.scala @@ -21,7 +21,7 @@ object StagedTuple { tup.as[Tuple3[Object, Object, Object]].bind(t => '{Array($t._1, $t._2, $t._3)}) case Some(4) => tup.as[Tuple4[Object, Object, Object, Object]].bind(t => '{Array($t._1, $t._2, $t._3, $t._4)}) - case Some(n) if n <= $MaxSpecialized => + case Some(n) if n <= MaxSpecialized => '{to$Array($tup, ${ n.toExpr })} case Some(n) => '{${ tup.as[TupleXXL] }.elems} @@ -86,9 +86,9 @@ object StagedTuple { '{${ tup.as[Tuple3[_, _, _]]}._1} case Some(4) => '{${ tup.as[Tuple4[_, _, _, _]] }._1} - case Some(n) if n > 4 && n <= $MaxSpecialized => + case Some(n) if n > 4 && n <= MaxSpecialized => '{${ tup.as[Product] }.productElement(0)} - case Some(n) if n > $MaxSpecialized => + case Some(n) if n > MaxSpecialized => '{${tup.as[TupleXXL] }.elems(0)} case None => '{dynamicHead($tup)} @@ -159,13 +159,13 @@ object StagedTuple { case Some(3) => '{$t._4} case _ => fallbackApply() } - case Some(s) if s > 4 && s <= $MaxSpecialized => + case Some(s) if s > 4 && s <= MaxSpecialized => val t = tup.as[Product] nValue match { case Some(n) if n >= 0 && n < s => '{$t.productElement(${ n.toExpr })} case _ => fallbackApply() } - case Some(s) if s > $MaxSpecialized => + case Some(s) if s > MaxSpecialized => val t = tup.as[TupleXXL] nValue match { case Some(n) if n >= 0 && n < s => '{$t.elems(${ n.toExpr })} diff --git a/library/src-bootstrapped/scala/Tuple.scala b/library/src-bootstrapped/scala/Tuple.scala index f6823e954d1f..b42c274738fa 100644 --- a/library/src-bootstrapped/scala/Tuple.scala +++ b/library/src-bootstrapped/scala/Tuple.scala @@ -23,7 +23,7 @@ sealed trait Tuple extends Any { case Some(4) => val t = asInstanceOf[Tuple4[Object, Object, Object, Object]] Array(t._1, t._2, t._3, t._4) - case Some(n) if n <= $MaxSpecialized => + case Some(n) if n <= MaxSpecialized => to$Array(this, n) case Some(n) => asInstanceOf[TupleXXL].elems @@ -125,8 +125,8 @@ sealed trait Tuple extends Any { } object Tuple { - inline val $MaxSpecialized = 22 - inline private val XXL = $MaxSpecialized + 1 + inline val MaxSpecialized = 22 + inline private val XXL = MaxSpecialized + 1 final val stageIt = false @@ -328,9 +328,9 @@ sealed trait NonEmptyTuple extends Tuple { case Some(4) => val t = asInstanceOf[Tuple4[_, _, _, _]] t._1 - case Some(n) if n > 4 && n <= $MaxSpecialized => + case Some(n) if n > 4 && n <= MaxSpecialized => asInstanceOf[Product].productElement(0) - case Some(n) if n > $MaxSpecialized => + case Some(n) if n > MaxSpecialized => val t = asInstanceOf[TupleXXL] t.elems(0) case None => @@ -412,13 +412,13 @@ sealed trait NonEmptyTuple extends Tuple { case Some(3) => t._4.asInstanceOf[Result] case _ => fallbackApply(n).asInstanceOf[Result] } - case Some(s) if s > 4 && s <= $MaxSpecialized => + case Some(s) if s > 4 && s <= MaxSpecialized => val t = asInstanceOf[Product] inline constValueOpt[n.type] match { case Some(n) if n >= 0 && n < s => t.productElement(n).asInstanceOf[Result] case _ => fallbackApply(n).asInstanceOf[Result] } - case Some(s) if s > $MaxSpecialized => + case Some(s) if s > MaxSpecialized => val t = asInstanceOf[TupleXXL] inline constValueOpt[n.type] match { case Some(n) if n >= 0 && n < s => t.elems(n).asInstanceOf[Result] From cc279c830d5c6e1f1618f508f1f1398871159e18 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Tue, 19 Feb 2019 07:08:24 +0100 Subject: [PATCH 16/26] Revert changes in tests/pos/t4579.scala --- tests/pos/t4579.scala | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/pos/t4579.scala b/tests/pos/t4579.scala index 5f6d6d12a3aa..500ffae40200 100644 --- a/tests/pos/t4579.scala +++ b/tests/pos/t4579.scala @@ -7,7 +7,7 @@ class LispTokenizer(s: String) extends Iterator[String] { private var i = 0; - private def isDelimiter(ch: Char) = ch <= ' ' || ch == '{' || ch == '}' + private def isDelimiter(ch: Char) = ch <= ' ' || ch == '(' || ch == ')' def hasNext: Boolean = { while (i < s.length() && s.charAt(i) <= ' ') i += 1 i < s.length() @@ -459,11 +459,11 @@ class LispUser(lisp: Lisp) { Console.println(lisp2string(string2lisp("(lambda (x) (+ (* x x) 1))"))); Console.println(); - Console.println("( '{1 2 3}) = " + evaluate(" (quote(1 2 3))")); - Console.println("(car '{1 2 3}) = " + evaluate("(car (quote(1 2 3)))")); - Console.println("(cdr '{1 2 3}) = " + evaluate("(cdr (quote(1 2 3)))")); - Console.println("(null? '{2 3}) = " + evaluate("(null? (quote(2 3)))")); - Console.println("(null? '{}) = " + evaluate("(null? (quote()))")); + Console.println("( '(1 2 3)) = " + evaluate(" (quote(1 2 3))")); + Console.println("(car '(1 2 3)) = " + evaluate("(car (quote(1 2 3)))")); + Console.println("(cdr '(1 2 3)) = " + evaluate("(cdr (quote(1 2 3)))")); + Console.println("(null? '(2 3)) = " + evaluate("(null? (quote(2 3)))")); + Console.println("(null? '()) = " + evaluate("(null? (quote()))")); Console.println(); Console.println("faculty(10) = " + evaluate( From 7d39a1e5646a3d082125bb84e1dc12c2708d59a6 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Tue, 19 Feb 2019 07:51:18 +0100 Subject: [PATCH 17/26] Update printer --- compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala b/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala index 407635418b3d..3632779dd4cb 100644 --- a/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala +++ b/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala @@ -328,8 +328,8 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { if (name.isTypeName) typeText(txt) else txt case tree @ Select(qual, name) => - if (tree.hasType && tree.symbol == defn.QuotedExpr_~) keywordStr("~(") ~ toTextLocal(qual) ~ keywordStr(")") - else if (tree.hasType && tree.symbol == defn.QuotedType_~) typeText("~(") ~ toTextLocal(qual) ~ typeText(")") + if (tree.hasType && tree.symbol == defn.QuotedExpr_~) keywordStr("${") ~ toTextLocal(qual) ~ keywordStr("}") + else if (tree.hasType && tree.symbol == defn.QuotedType_~) typeText("${") ~ toTextLocal(qual) ~ typeText("}") else if (qual.isType) toTextLocal(qual) ~ "#" ~ typeText(toText(name)) else toTextLocal(qual) ~ ("." ~ nameIdText(tree) provided name != nme.CONSTRUCTOR) case tree: This => From e23bf3ca9a9c4f9224f51c328ea50c8048595d44 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Tue, 19 Feb 2019 08:25:54 +0100 Subject: [PATCH 18/26] Avoid accidental conversion from ${ x } to x.unary_~ and back --- bench/tests/power-macro/PowerMacro.scala | 6 +- .../src/dotty/tools/dotc/ast/Desugar.scala | 4 +- .../dotty/tools/dotc/core/Definitions.scala | 6 +- .../tools/dotc/printing/RefinedPrinter.scala | 4 +- .../tools/dotc/transform/ReifyQuotes.scala | 8 +- .../dotty/tools/dotc/transform/Staging.scala | 2 +- .../dotty/tools/dotc/transform/SymUtils.scala | 2 +- .../dotty/tools/dotc/typer/Implicits.scala | 2 +- compiler/test-resources/repl/i5551 | 4 +- .../scala/quoted/package.scala | 2 +- library/src/scala/quoted/Expr.scala | 6 +- library/src/scala/quoted/Type.scala | 2 +- tests/disabled/run/i4803d/App_2.scala | 2 +- tests/disabled/run/i4803d/Macro_1.scala | 4 +- .../quote-run-in-macro-1/quoted_1.scala | 2 +- .../quote-run-in-macro-2/quoted_1.scala | 2 +- tests/neg/i4044b.scala | 4 +- tests/neg/i4774b.scala | 4 +- tests/neg/inline-case-objects/Main_2.scala | 2 +- .../Macro_1.scala | 2 +- tests/neg/inline-option/Main_2.scala | 6 +- tests/neg/inline-tuples-1/Main_2.scala | 44 ++--- tests/neg/quote-MacroOverride.scala | 2 +- tests/neg/quote-complex-top-splice.scala | 8 +- tests/neg/quote-macro-2-splices.scala | 4 +- tests/neg/quote-macro-complex-arg-0.scala | 4 +- tests/neg/quote-macro-splice.scala | 10 +- tests/neg/quote-pcp-in-arg.scala | 2 +- tests/neg/quote-this.scala | 12 +- tests/neg/splice-in-top-level-splice-1.scala | 2 +- tests/neg/splice-in-top-level-splice-2.scala | 2 +- tests/neg/splice-non-expr.scala | 11 ++ tests/pos-with-compiler/quote-0.scala | 14 +- .../quote-assert/quoted_2.scala | 4 +- tests/pos/i3898/quoted_1.scala | 2 +- tests/pos/i3898b/quoted_1.scala | 2 +- tests/pos/i3898c/quoted_1.scala | 2 +- tests/pos/i3912-1/i3912_1.scala | 2 +- tests/pos/i3912-2/i3912_1.scala | 2 +- tests/pos/i3912-3/i3912_1.scala | 2 +- tests/pos/i4023b/Macro_1.scala | 2 +- tests/pos/i4380a.scala | 2 +- tests/pos/i4380b.scala | 2 +- tests/pos/i4514.scala | 2 +- tests/pos/i4734/Macro_1.scala | 2 +- tests/pos/i4773.scala | 2 +- tests/pos/i4774a.scala | 2 +- tests/pos/i4774c.scala | 2 +- tests/pos/i4774d.scala | 2 +- tests/pos/i4846.scala | 2 +- tests/pos/macro-with-type/Macro_1.scala | 2 +- tests/pos/power-macro/Macro_1.scala | 6 +- tests/pos/quote-1.scala | 2 +- tests/pos/quote-bind-T.scala | 2 +- tests/pos/quote-lift.scala | 4 +- tests/pos/quote-nested-object/Macro_1.scala | 6 +- tests/pos/quote-non-static-macro.scala | 8 +- .../tasty-extractors-owners.check | 4 +- .../tasty-extractors-owners/quoted_1.scala | 2 +- .../tasty-load-tree-1/quoted_1.scala | 2 +- .../tasty-load-tree-2/quoted_1.scala | 2 +- .../staged-streams_1.scala | 171 +++++++++--------- tests/run-with-compiler/i3823-b.scala | 2 +- tests/run-with-compiler/i3823-c.scala | 2 +- tests/run-with-compiler/i3823.scala | 2 +- tests/run-with-compiler/i3847.scala | 2 +- tests/run-with-compiler/i3947.scala | 2 +- tests/run-with-compiler/i3947b.scala | 2 +- tests/run-with-compiler/i3947b2.scala | 2 +- tests/run-with-compiler/i3947b3.scala | 2 +- tests/run-with-compiler/i3947c.scala | 2 +- tests/run-with-compiler/i3947d.scala | 2 +- tests/run-with-compiler/i3947d2.scala | 2 +- tests/run-with-compiler/i3947e.scala | 2 +- tests/run-with-compiler/i3947f.scala | 2 +- tests/run-with-compiler/i3947g.scala | 2 +- tests/run-with-compiler/i3947i.scala | 2 +- tests/run-with-compiler/i3947j.scala | 2 +- tests/run-with-compiler/i4044a.scala | 2 +- tests/run-with-compiler/i4044b.scala | 10 +- tests/run-with-compiler/i4044c.scala | 2 +- tests/run-with-compiler/i4044d.scala | 2 +- tests/run-with-compiler/i4044f.scala | 8 +- tests/run-with-compiler/i4591.scala | 2 +- tests/run-with-compiler/i5144b.scala | 2 +- .../run-with-compiler/quote-ackermann-1.scala | 2 +- tests/run-with-compiler/quote-fun-app-1.scala | 6 +- .../quote-impure-by-name/quoted_1.scala | 2 +- .../quote-inline-function/quoted_1.scala | 12 +- tests/run-with-compiler/quote-lambda.scala | 2 +- tests/run-with-compiler/quote-lib.scala | 6 +- tests/run-with-compiler/quote-nested-2.scala | 2 +- tests/run-with-compiler/quote-nested-3.scala | 2 +- tests/run-with-compiler/quote-nested-5.scala | 6 +- tests/run-with-compiler/quote-owners.scala | 2 +- tests/run-with-compiler/quote-run-2.scala | 4 +- .../run-with-compiler/quote-show-blocks.scala | 4 +- .../quote-two-captured-ref.scala | 2 +- tests/run-with-compiler/quote-var.scala | 20 +- tests/run-with-compiler/shonan-hmm/Ring.scala | 6 +- .../shonan-hmm/UnrolledExpr.scala | 2 +- .../run-with-compiler/shonan-hmm/VecOp.scala | 4 +- .../run-with-compiler/shonan-hmm/VecROp.scala | 10 +- .../quoted_1.scala | 8 +- .../tasty-unsafe-let/quoted_1.scala | 2 +- tests/run/f-interpolation-1/FQuote_1.scala | 6 +- .../gestalt-optional-staging/Macro_1.scala | 4 +- tests/run/i4431/quoted_1.scala | 2 +- tests/run/i4455/Macro_1.scala | 4 +- tests/run/i4515/Macro_1.scala | 2 +- tests/run/i4515b/Macro_1.scala | 2 +- tests/run/i4734/Macro_1.scala | 10 +- tests/run/i4735/Macro_1.scala | 8 +- tests/run/i4803/App_2.scala | 2 +- tests/run/i4803/Macro_1.scala | 6 +- tests/run/i4803b/App_2.scala | 2 +- tests/run/i4803b/Macro_1.scala | 4 +- tests/run/i4803c/App_2.scala | 4 +- tests/run/i4803c/Macro_1.scala | 4 +- tests/run/i4803e/App_2.scala | 2 +- tests/run/i4803e/Macro_1.scala | 2 +- tests/run/i4803f/App_2.scala | 2 +- tests/run/i4803f/Macro_1.scala | 8 +- tests/run/i4947e/Macro_1.scala | 2 +- tests/run/i4947e/Test_2.scala | 2 +- tests/run/i4947f/Macro_1.scala | 4 +- tests/run/i5119/Macro_1.scala | 2 +- tests/run/i5119b/Macro_1.scala | 2 +- tests/run/i5188a/Macro_1.scala | 2 +- tests/run/i5386.check | 1 - tests/run/i5386.scala | 5 - tests/run/i5533b/Macro_1.scala | 6 +- tests/run/i5536/Macro_1.scala | 6 +- tests/run/inline-case-objects/Main_2.scala | 2 +- .../Macro_1.scala | 10 +- tests/run/inline-option/Main_2.scala | 10 +- tests/run/inline-tuples-1/Main_2.scala | 44 ++--- tests/run/inline-tuples-2/Main_2.scala | 8 +- tests/run/inline-varargs-1/Main_2.scala | 2 +- tests/run/quote-and-splice/Macros_1.scala | 22 +-- tests/run/quote-change-owner/Macro_1.scala | 4 +- tests/run/quote-sep-comp-2/Macro_1.scala | 2 +- tests/run/quote-sep-comp-2/Test_2.scala | 2 +- tests/run/quote-sep-comp/Macro_1.scala | 4 +- tests/run/quote-simple-macro/quoted_1.scala | 4 +- tests/run/reflect-select-copy/assert_1.scala | 6 +- .../run/tasty-argument-tree-1/quoted_1.scala | 2 +- tests/run/tasty-custom-show/quoted_1.scala | 2 +- tests/run/tasty-eval/quoted_1.scala | 2 +- tests/run/tasty-extractors-1/quoted_1.scala | 2 +- tests/run/tasty-extractors-2/quoted_1.scala | 2 +- .../run/tasty-extractors-types/quoted_1.scala | 2 +- .../Macro_1.scala | 2 +- tests/run/tasty-getfile/Macro_1.scala | 2 +- .../Macro_1.scala | 2 +- .../run/tasty-original-source/Macros_1.scala | 2 +- tests/run/tasty-seal-method/quoted_1.scala | 4 +- tests/run/tasty-tree-map/quoted_1.scala | 2 +- tests/run/tasty-typeof/Macro_1.scala | 2 +- .../run/xml-interpolation-2/XmlQuote_1.scala | 2 +- 160 files changed, 435 insertions(+), 423 deletions(-) create mode 100644 tests/neg/splice-non-expr.scala diff --git a/bench/tests/power-macro/PowerMacro.scala b/bench/tests/power-macro/PowerMacro.scala index aca9c4838284..042f212c9aa4 100644 --- a/bench/tests/power-macro/PowerMacro.scala +++ b/bench/tests/power-macro/PowerMacro.scala @@ -2,11 +2,11 @@ import scala.quoted.Expr object PowerMacro { - inline def power(inline n: Long, x: Double) = ~powerCode(n, '{x}) + inline def power(inline n: Long, x: Double) = ${powerCode(n, '{x})} def powerCode(n: Long, x: Expr[Double]): Expr[Double] = if (n == 0) '{1.0} - else if (n % 2 == 0) '{ val y = ~x * ~x; ~powerCode(n / 2, '{y}) } - else '{ ~x * ~powerCode(n - 1, x) } + else if (n % 2 == 0) '{ val y = $x * $x; ${powerCode(n / 2, '{y})} } + else '{ $x * ${powerCode(n - 1, x)} } } diff --git a/compiler/src/dotty/tools/dotc/ast/Desugar.scala b/compiler/src/dotty/tools/dotc/ast/Desugar.scala index 9c2ced566d32..68e13de6ccce 100644 --- a/compiler/src/dotty/tools/dotc/ast/Desugar.scala +++ b/compiler/src/dotty/tools/dotc/ast/Desugar.scala @@ -1319,9 +1319,9 @@ object desugar { else Apply(ref(defn.QuotedExpr_applyR), t) case Splice(expr) => - Select(expr, nme.UNARY_~) + Select(expr, nme.splice) case TypSplice(expr) => - Select(expr, tpnme.UNARY_~) + Select(expr, tpnme.splice) case InterpolatedString(id, segments) => val strs = segments map { case ts: Thicket => ts.trees.head diff --git a/compiler/src/dotty/tools/dotc/core/Definitions.scala b/compiler/src/dotty/tools/dotc/core/Definitions.scala index 1bc6fcdb737b..2e4f65d4cc5e 100644 --- a/compiler/src/dotty/tools/dotc/core/Definitions.scala +++ b/compiler/src/dotty/tools/dotc/core/Definitions.scala @@ -707,7 +707,7 @@ class Definitions { def QuotedExprModule(implicit ctx: Context): Symbol = QuotedExprClass.companionModule lazy val QuotedExpr_applyR: TermRef = QuotedExprModule.requiredMethodRef(nme.apply) def QuotedExpr_apply(implicit ctx: Context): Symbol = QuotedExpr_applyR.symbol - lazy val QuotedExpr_~ : TermSymbol = QuotedExprClass.requiredMethod(nme.UNARY_~) + lazy val QuotedExpr_splice : TermSymbol = QuotedExprClass.requiredMethod(nme.splice) lazy val QuotedExprsModule: TermSymbol = ctx.requiredModule("scala.quoted.Exprs") def QuotedExprsClass(implicit ctx: Context): ClassSymbol = QuotedExprsModule.asClass @@ -715,8 +715,8 @@ class Definitions { lazy val QuotedTypeType: TypeRef = ctx.requiredClassRef("scala.quoted.Type") def QuotedTypeClass(implicit ctx: Context): ClassSymbol = QuotedTypeType.symbol.asClass - lazy val QuotedType_spliceR: TypeRef = QuotedTypeClass.requiredType(tpnme.UNARY_~).typeRef - def QuotedType_~ : Symbol = QuotedType_spliceR.symbol + lazy val QuotedType_spliceR: TypeRef = QuotedTypeClass.requiredType(tpnme.splice).typeRef + def QuotedType_splice : Symbol = QuotedType_spliceR.symbol lazy val QuotedTypeModuleType: TermRef = ctx.requiredModuleRef("scala.quoted.Type") def QuotedTypeModule(implicit ctx: Context): Symbol = QuotedTypeModuleType.symbol diff --git a/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala b/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala index 3632779dd4cb..13052d2cd8cb 100644 --- a/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala +++ b/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala @@ -328,8 +328,8 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { if (name.isTypeName) typeText(txt) else txt case tree @ Select(qual, name) => - if (tree.hasType && tree.symbol == defn.QuotedExpr_~) keywordStr("${") ~ toTextLocal(qual) ~ keywordStr("}") - else if (tree.hasType && tree.symbol == defn.QuotedType_~) typeText("${") ~ toTextLocal(qual) ~ typeText("}") + if (tree.hasType && tree.symbol == defn.QuotedExpr_splice) keywordStr("${") ~ toTextLocal(qual) ~ keywordStr("}") + else if (tree.hasType && tree.symbol == defn.QuotedType_splice) typeText("${") ~ toTextLocal(qual) ~ typeText("}") else if (qual.isType) toTextLocal(qual) ~ "#" ~ typeText(toText(name)) else toTextLocal(qual) ~ ("." ~ nameIdText(tree) provided name != nme.CONSTRUCTOR) case tree: This => diff --git a/compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala b/compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala index 931450af868d..70ba8e64c174 100644 --- a/compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala +++ b/compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala @@ -129,13 +129,13 @@ class ReifyQuotes extends MacroTransform { def mkTagSymbolAndAssignType(spliced: TermRef): TypeDef = { val splicedTree = tpd.ref(spliced) - val rhs = transform(splicedTree.select(tpnme.UNARY_~)) + val rhs = transform(splicedTree.select(tpnme.splice)) val alias = ctx.typeAssigner.assignType(untpd.TypeBoundsTree(rhs, rhs), rhs, rhs) val local = ctx.newSymbol( owner = ctx.owner, name = UniqueName.fresh((splicedTree.symbol.name.toString + "$_~").toTermName).toTypeName, flags = Synthetic, - info = TypeAlias(splicedTree.tpe.select(tpnme.UNARY_~)), + info = TypeAlias(splicedTree.tpe.select(tpnme.splice)), coord = spliced.termSymbol.coord).asType ctx.typeAssigner.assignType(untpd.TypeDef(local.name, alias), local) @@ -353,11 +353,11 @@ class ReifyQuotes extends MacroTransform { case tree: TypeTree if tree.tpe.typeSymbol.isSplice => val splicedType = tree.tpe.stripTypeVar.asInstanceOf[TypeRef].prefix.termSymbol - transformSplice(ref(splicedType).select(tpnme.UNARY_~).withSpan(tree.span)) + transformSplice(ref(splicedType).select(tpnme.splice).withSpan(tree.span)) case tree: RefTree if isCaptured(tree.symbol, level) => val t = capturers(tree.symbol).apply(tree) - transformSplice(t.select(if (tree.isTerm) nme.UNARY_~ else tpnme.UNARY_~)) + transformSplice(t.select(if (tree.isTerm) nme.splice else tpnme.splice)) case tree: DefDef if tree.symbol.is(Macro) && level == 0 => // Shrink size of the tree. The methods have already been inlined. diff --git a/compiler/src/dotty/tools/dotc/transform/Staging.scala b/compiler/src/dotty/tools/dotc/transform/Staging.scala index 637a0b698961..06d1be91567e 100644 --- a/compiler/src/dotty/tools/dotc/transform/Staging.scala +++ b/compiler/src/dotty/tools/dotc/transform/Staging.scala @@ -301,7 +301,7 @@ class Staging extends MacroTransform { | The access would be accepted with the right type tag, but | ${ctx.typer.missingArgMsg(tag, reqType, "")}""") case _ => - Some(tag.select(tpnme.UNARY_~)) + Some(tag.select(tpnme.splice)) } } case _ => diff --git a/compiler/src/dotty/tools/dotc/transform/SymUtils.scala b/compiler/src/dotty/tools/dotc/transform/SymUtils.scala index cf932dcf3c74..700d174e5671 100644 --- a/compiler/src/dotty/tools/dotc/transform/SymUtils.scala +++ b/compiler/src/dotty/tools/dotc/transform/SymUtils.scala @@ -162,5 +162,5 @@ class SymUtils(val self: Symbol) extends AnyVal { /** Is symbol a splice operation? */ def isSplice(implicit ctx: Context): Boolean = - self == defn.QuotedExpr_~ || self == defn.QuotedType_~ + self == defn.QuotedExpr_splice || self == defn.QuotedType_splice } diff --git a/compiler/src/dotty/tools/dotc/typer/Implicits.scala b/compiler/src/dotty/tools/dotc/typer/Implicits.scala index 0b717bd60bde..a5aca1b408d8 100644 --- a/compiler/src/dotty/tools/dotc/typer/Implicits.scala +++ b/compiler/src/dotty/tools/dotc/typer/Implicits.scala @@ -669,7 +669,7 @@ trait Implicits { self: Typer => case t @ TypeRef(NoPrefix, _) => inferImplicit(defn.QuotedTypeType.appliedTo(t), EmptyTree, span) match { case SearchSuccess(tag, _, _) if tag.tpe.isStable => - tag.tpe.select(defn.QuotedType_~) + tag.tpe.select(defn.QuotedType_splice) case _ => ok = false t diff --git a/compiler/test-resources/repl/i5551 b/compiler/test-resources/repl/i5551 index 85564f4b1029..eadfea38c3a6 100644 --- a/compiler/test-resources/repl/i5551 +++ b/compiler/test-resources/repl/i5551 @@ -1,9 +1,9 @@ scala> import scala.quoted._ -scala> def assertImpl(expr: Expr[Boolean]) = '{ if !(~expr) then throw new AssertionError("failed assertion")} +scala> def assertImpl(expr: Expr[Boolean]) = '{ if !($expr) then throw new AssertionError("failed assertion")} def assertImpl(expr: quoted.Expr[Boolean]): quoted.Expr[Unit] -scala> inline def assert(expr: => Boolean): Unit = ~ assertImpl('{expr}) +scala> inline def assert(expr: => Boolean): Unit = ${ assertImpl('{expr}) } def assert(expr: => Boolean): Unit scala> assert(0 == 0) diff --git a/library/src-bootstrapped/scala/quoted/package.scala b/library/src-bootstrapped/scala/quoted/package.scala index 7334ac3d0677..54ef75f46823 100644 --- a/library/src-bootstrapped/scala/quoted/package.scala +++ b/library/src-bootstrapped/scala/quoted/package.scala @@ -9,7 +9,7 @@ package object quoted { implicit class ListOfExprOps[T](val list: List[Expr[T]]) extends AnyVal { def toExprOfList(implicit ev: Type[T]): Expr[List[T]] = { def rec(list: List[Expr[T]]): Expr[List[T]] = list match { - case x :: xs => '{ (~x) :: (~rec(xs)) } + case x :: xs => '{ ($x) :: ${rec(xs)} } case Nil => '{Nil} } rec(list) diff --git a/library/src/scala/quoted/Expr.scala b/library/src/scala/quoted/Expr.scala index eda1fb984802..5de5cb1576ae 100644 --- a/library/src/scala/quoted/Expr.scala +++ b/library/src/scala/quoted/Expr.scala @@ -3,7 +3,8 @@ package scala.quoted import scala.runtime.quoted.Unpickler.Pickled sealed abstract class Expr[+T] { - final def unary_~ : T = throw new Error("~ should have been compiled away") + + final def splice: T = throw new Error("splice should have been compiled away") /** Evaluate the contents of this expression and return the result. * @@ -13,6 +14,7 @@ sealed abstract class Expr[+T] { /** Show a source code like representation of this expression */ final def show(implicit toolbox: Toolbox): String = toolbox.show(this) + } object Expr { @@ -146,7 +148,7 @@ object Exprs { // TODO Use a List in FunctionAppliedTo(val f: Expr[_], val args: List[Expr[_]]) // FIXME: Having the List in the code above trigers an assertion error while testing dotty.tools.dotc.reporting.ErrorMessagesTests.i3187 // This test does redefine `scala.collection`. Further investigation is needed. - /** An Expr representing `'{(~f).apply(~x1, ..., ~xn)}` but it is beta-reduced when the closure is known */ + /** An Expr representing `'{($f).apply($x1, ..., $xn)}` but it is beta-reduced when the closure is known */ final class FunctionAppliedTo[+R](val f: Expr[_], val args: Array[Expr[_]]) extends Expr[R] { override def toString: String = s"Expr($f ${args.toList})" } diff --git a/library/src/scala/quoted/Type.scala b/library/src/scala/quoted/Type.scala index 9eeed775ad69..2a5708475f6c 100644 --- a/library/src/scala/quoted/Type.scala +++ b/library/src/scala/quoted/Type.scala @@ -5,7 +5,7 @@ import scala.reflect.ClassTag import scala.runtime.quoted.Unpickler.Pickled sealed abstract class Type[T] { - type unary_~ = T + type splice = T } /** Some basic type tags, currently incomplete */ diff --git a/tests/disabled/run/i4803d/App_2.scala b/tests/disabled/run/i4803d/App_2.scala index 9a4926c8c6d7..16324e9a82bf 100644 --- a/tests/disabled/run/i4803d/App_2.scala +++ b/tests/disabled/run/i4803d/App_2.scala @@ -11,7 +11,7 @@ object Test { } inline def power2(x: Double) = { - inline def power(x: Double, inline n: Long) = ~PowerMacro.powerCode('{x}, n) + inline def power(x: Double, inline n: Long) = ${ PowerMacro.powerCode('{x}, n) } power(x, 2) } } diff --git a/tests/disabled/run/i4803d/Macro_1.scala b/tests/disabled/run/i4803d/Macro_1.scala index b90f101eecf7..5c146d1f2a7b 100644 --- a/tests/disabled/run/i4803d/Macro_1.scala +++ b/tests/disabled/run/i4803d/Macro_1.scala @@ -3,6 +3,6 @@ import scala.quoted._ object PowerMacro { def powerCode(x: Expr[Double], n: Long): Expr[Double] = if (n == 0) '{1.0} - else if (n % 2 == 0) '{ val y = $x * $x; ~powerCode('{y}, n / 2) } - else '{ $x * ~powerCode(x, n - 1) } + else if (n % 2 == 0) '{ val y = $x * $x; ${powerCode('{y}, n / 2)} } + else '{ $x * ${powerCode(x, n - 1)} } } diff --git a/tests/neg-with-compiler/quote-run-in-macro-1/quoted_1.scala b/tests/neg-with-compiler/quote-run-in-macro-1/quoted_1.scala index 2546a09b1055..093b8e8f5849 100644 --- a/tests/neg-with-compiler/quote-run-in-macro-1/quoted_1.scala +++ b/tests/neg-with-compiler/quote-run-in-macro-1/quoted_1.scala @@ -3,7 +3,7 @@ import scala.quoted._ import scala.quoted.Toolbox.Default._ object Macros { - inline def foo(i: => Int): Int = ~fooImpl('{i}) + inline def foo(i: => Int): Int = ${ fooImpl('{i}) } def fooImpl(i: Expr[Int]): Expr[Int] = { val y: Int = i.run y.toExpr diff --git a/tests/neg-with-compiler/quote-run-in-macro-2/quoted_1.scala b/tests/neg-with-compiler/quote-run-in-macro-2/quoted_1.scala index 2546a09b1055..093b8e8f5849 100644 --- a/tests/neg-with-compiler/quote-run-in-macro-2/quoted_1.scala +++ b/tests/neg-with-compiler/quote-run-in-macro-2/quoted_1.scala @@ -3,7 +3,7 @@ import scala.quoted._ import scala.quoted.Toolbox.Default._ object Macros { - inline def foo(i: => Int): Int = ~fooImpl('{i}) + inline def foo(i: => Int): Int = ${ fooImpl('{i}) } def fooImpl(i: Expr[Int]): Expr[Int] = { val y: Int = i.run y.toExpr diff --git a/tests/neg/i4044b.scala b/tests/neg/i4044b.scala index 5431b0bc8a6f..191039ed9f18 100644 --- a/tests/neg/i4044b.scala +++ b/tests/neg/i4044b.scala @@ -8,8 +8,8 @@ class Test { '{ b // error - ~(b) - ~('{b}) // error + ${b} + ${ '{b} } // error '{ '{$b} } // error } diff --git a/tests/neg/i4774b.scala b/tests/neg/i4774b.scala index 3d62fd3deacc..9f01ba3f0bb5 100644 --- a/tests/neg/i4774b.scala +++ b/tests/neg/i4774b.scala @@ -4,8 +4,8 @@ import scala.quoted._ object Test { def loop[T](x: Expr[T])(implicit t: Type[T]): Expr[T] = '{ val y: $t = $x; - ~loop[$t]( // error + ${loop[$t]( // error '{y} - ) + )} } } diff --git a/tests/neg/inline-case-objects/Main_2.scala b/tests/neg/inline-case-objects/Main_2.scala index a61b0fc060dc..95488814cadf 100644 --- a/tests/neg/inline-case-objects/Main_2.scala +++ b/tests/neg/inline-case-objects/Main_2.scala @@ -6,6 +6,6 @@ object Test { println(fooString(bar.Baz)) // error } - inline def fooString(inline x: Any): String = ~Macros.impl(x) + inline def fooString(inline x: Any): String = ${ Macros.impl(x) } } diff --git a/tests/neg/inline-macro-staged-interpreter/Macro_1.scala b/tests/neg/inline-macro-staged-interpreter/Macro_1.scala index 0da02a108c29..56a6c16402cf 100644 --- a/tests/neg/inline-macro-staged-interpreter/Macro_1.scala +++ b/tests/neg/inline-macro-staged-interpreter/Macro_1.scala @@ -3,7 +3,7 @@ import scala.quoted._ object E { - inline def eval[T](inline x: E[T]): T = ~impl(x) + inline def eval[T](inline x: E[T]): T = ${ impl(x) } def impl[T](x: E[T]): Expr[T] = x.lift diff --git a/tests/neg/inline-option/Main_2.scala b/tests/neg/inline-option/Main_2.scala index 7ae506282eba..37425a3b4aa3 100644 --- a/tests/neg/inline-option/Main_2.scala +++ b/tests/neg/inline-option/Main_2.scala @@ -6,10 +6,10 @@ object Main { val b: Option[Int] = Some(4) size(b) // error - inline def size(inline opt: Option[Int]): Int = ~Macro.impl(opt) + inline def size(inline opt: Option[Int]): Int = ${ Macro.impl(opt) } - inline def size2(inline i: Int): Int = ~Macro.impl(None) + inline def size2(inline i: Int): Int = ${ Macro.impl(None) } - inline def size3(inline i: Int): Int = ~Macro.impl(Some(i)) + inline def size3(inline i: Int): Int = ${ Macro.impl(Some(i)) } } \ No newline at end of file diff --git a/tests/neg/inline-tuples-1/Main_2.scala b/tests/neg/inline-tuples-1/Main_2.scala index 199c0fbdcbb6..16d7916c55a1 100644 --- a/tests/neg/inline-tuples-1/Main_2.scala +++ b/tests/neg/inline-tuples-1/Main_2.scala @@ -347,27 +347,27 @@ object Test { ))) } - inline def sum(inline tup: Tuple1[Int]): Int = ~Macros.tup1(tup) - inline def sum(inline tup: Tuple2[Int, Int]): Int = ~Macros.tup2(tup) - inline def sum(inline tup: Tuple3[Int, Int, Int]): Int = ~Macros.tup3(tup) - inline def sum(inline tup: Tuple4[Int, Int, Int, Int]): Int = ~Macros.tup4(tup) - inline def sum(inline tup: Tuple5[Int, Int, Int, Int, Int]): Int = ~Macros.tup5(tup) - inline def sum(inline tup: Tuple6[Int, Int, Int, Int, Int, Int]): Int = ~Macros.tup6(tup) - inline def sum(inline tup: Tuple7[Int, Int, Int, Int, Int, Int, Int]): Int = ~Macros.tup7(tup) - inline def sum(inline tup: Tuple8[Int, Int, Int, Int, Int, Int, Int, Int]): Int = ~Macros.tup8(tup) - inline def sum(inline tup: Tuple9[Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ~Macros.tup9(tup) - inline def sum(inline tup: Tuple10[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ~Macros.tup10(tup) - inline def sum(inline tup: Tuple11[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ~Macros.tup11(tup) - inline def sum(inline tup: Tuple12[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ~Macros.tup12(tup) - inline def sum(inline tup: Tuple13[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ~Macros.tup13(tup) - inline def sum(inline tup: Tuple14[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ~Macros.tup14(tup) - inline def sum(inline tup: Tuple15[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ~Macros.tup15(tup) - inline def sum(inline tup: Tuple16[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ~Macros.tup16(tup) - inline def sum(inline tup: Tuple17[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ~Macros.tup17(tup) - inline def sum(inline tup: Tuple18[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ~Macros.tup18(tup) - inline def sum(inline tup: Tuple19[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ~Macros.tup19(tup) - inline def sum(inline tup: Tuple20[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ~Macros.tup20(tup) - inline def sum(inline tup: Tuple21[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ~Macros.tup21(tup) - inline def sum(inline tup: Tuple22[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ~Macros.tup22(tup) + inline def sum(inline tup: Tuple1[Int]): Int = ${ Macros.tup1(tup) } + inline def sum(inline tup: Tuple2[Int, Int]): Int = ${ Macros.tup2(tup) } + inline def sum(inline tup: Tuple3[Int, Int, Int]): Int = ${ Macros.tup3(tup) } + inline def sum(inline tup: Tuple4[Int, Int, Int, Int]): Int = ${ Macros.tup4(tup) } + inline def sum(inline tup: Tuple5[Int, Int, Int, Int, Int]): Int = ${ Macros.tup5(tup) } + inline def sum(inline tup: Tuple6[Int, Int, Int, Int, Int, Int]): Int = ${ Macros.tup6(tup) } + inline def sum(inline tup: Tuple7[Int, Int, Int, Int, Int, Int, Int]): Int = ${ Macros.tup7(tup) } + inline def sum(inline tup: Tuple8[Int, Int, Int, Int, Int, Int, Int, Int]): Int = ${ Macros.tup8(tup) } + inline def sum(inline tup: Tuple9[Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ${ Macros.tup9(tup) } + inline def sum(inline tup: Tuple10[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ${ Macros.tup10(tup) } + inline def sum(inline tup: Tuple11[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ${ Macros.tup11(tup) } + inline def sum(inline tup: Tuple12[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ${ Macros.tup12(tup) } + inline def sum(inline tup: Tuple13[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ${ Macros.tup13(tup) } + inline def sum(inline tup: Tuple14[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ${ Macros.tup14(tup) } + inline def sum(inline tup: Tuple15[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ${ Macros.tup15(tup) } + inline def sum(inline tup: Tuple16[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ${ Macros.tup16(tup) } + inline def sum(inline tup: Tuple17[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ${ Macros.tup17(tup) } + inline def sum(inline tup: Tuple18[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ${ Macros.tup18(tup) } + inline def sum(inline tup: Tuple19[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ${ Macros.tup19(tup) } + inline def sum(inline tup: Tuple20[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ${ Macros.tup20(tup) } + inline def sum(inline tup: Tuple21[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ${ Macros.tup21(tup) } + inline def sum(inline tup: Tuple22[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ${ Macros.tup22(tup) } } diff --git a/tests/neg/quote-MacroOverride.scala b/tests/neg/quote-MacroOverride.scala index 8467bb1d71db..55e03eee5381 100644 --- a/tests/neg/quote-MacroOverride.scala +++ b/tests/neg/quote-MacroOverride.scala @@ -6,7 +6,7 @@ object Test { } object B extends A { - inline def f() = ~('{}) // error: may not override + inline def f() = ${'{}} // error: may not override override def g() = () // error: may not override } diff --git a/tests/neg/quote-complex-top-splice.scala b/tests/neg/quote-complex-top-splice.scala index 2b65baf8d3fb..f0b5b74513b5 100644 --- a/tests/neg/quote-complex-top-splice.scala +++ b/tests/neg/quote-complex-top-splice.scala @@ -9,15 +9,15 @@ object Test { impl(x) } - inline def foo2: Unit = ~impl({ // error + inline def foo2: Unit = ${ impl({ // error val x = 1 x - }) + }) } - inline def foo3: Unit = ~impl({ // error + inline def foo3: Unit = ${ impl({ // error println("foo3") 3 - }) + }) } inline def foo4: Unit = ${ // error println("foo4") diff --git a/tests/neg/quote-macro-2-splices.scala b/tests/neg/quote-macro-2-splices.scala index 5280fb1f6b7b..7b85b6f51255 100644 --- a/tests/neg/quote-macro-2-splices.scala +++ b/tests/neg/quote-macro-2-splices.scala @@ -3,8 +3,8 @@ import scala.quoted._ object Macro { inline def foo(b: Boolean): Int = { // error - if (b) ~bar(true) - else ~bar(false) + if (b) ${ bar(true) } + else ${ bar(false) } } def bar(b: Boolean): Expr[Int] = if (b) '{1} else '{0} diff --git a/tests/neg/quote-macro-complex-arg-0.scala b/tests/neg/quote-macro-complex-arg-0.scala index 6692590dfc0a..204ba6daefbd 100644 --- a/tests/neg/quote-macro-complex-arg-0.scala +++ b/tests/neg/quote-macro-complex-arg-0.scala @@ -1,6 +1,6 @@ import scala.quoted._ object Macros { - inline def foo(inline i: Int, dummy: Int, j: Int): Int = ~bar(i + 1, '{j}) // error: i + 1 is not a parameter or field reference - def bar(x: Int, y: Expr[Int]): Expr[Int] = '{ ~{x.toExpr} + $y } + inline def foo(inline i: Int, dummy: Int, j: Int): Int = ${ bar(i + 1, '{j}) } // error: i + 1 is not a parameter or field reference + def bar(x: Int, y: Expr[Int]): Expr[Int] = '{ ${x.toExpr} + $y } } diff --git a/tests/neg/quote-macro-splice.scala b/tests/neg/quote-macro-splice.scala index 5747f521e235..4eda3cc3e8f3 100644 --- a/tests/neg/quote-macro-splice.scala +++ b/tests/neg/quote-macro-splice.scala @@ -4,21 +4,21 @@ object Test { inline def foo1: Int = { // error println() - ~impl(1.toExpr) + ${ impl(1.toExpr) } } inline def foo2: Int = { // error - ~impl(1.toExpr) - ~impl(2.toExpr) + ${ impl(1.toExpr) } + ${ impl(2.toExpr) } } inline def foo3: Int = { // error val a = 1 - ~impl('{a}) + ${ impl('{a}) } } inline def foo4: Int = { // error - ~impl('{1}) + ${ impl('{1}) } 1 } diff --git a/tests/neg/quote-pcp-in-arg.scala b/tests/neg/quote-pcp-in-arg.scala index 70e2a163bd58..4f59039289c2 100644 --- a/tests/neg/quote-pcp-in-arg.scala +++ b/tests/neg/quote-pcp-in-arg.scala @@ -1,6 +1,6 @@ import scala.quoted._ object Foo { - inline def foo(x: Int): Int = ~bar('{ '{x}; x }) // error + inline def foo(x: Int): Int = ${ bar('{ '{x}; x }) } // error def bar(i: Expr[Int]): Expr[Int] = i } diff --git a/tests/neg/quote-this.scala b/tests/neg/quote-this.scala index 320de6cebc45..58ccc6ff4716 100644 --- a/tests/neg/quote-this.scala +++ b/tests/neg/quote-this.scala @@ -11,16 +11,16 @@ class Foo { } } - inline def i(): Unit = ~Foo.impl[Any]('{ + inline def i(): Unit = ${ Foo.impl[Any]('{ '{this} // error - }) + }) } - inline def j(that: Foo): Unit = ~Foo.impl[Any]('{ + inline def j(that: Foo): Unit = ${ Foo.impl[Any]('{ '{that} // error - }) + }) } - inline def k(): Unit = ~Foo.impl[Any](this) // error - inline def l(that: Foo): Unit = ~Foo.impl[Any](that) // error + inline def k(): Unit = ${ Foo.impl[Any](this) } // error + inline def l(that: Foo): Unit = ${ Foo.impl[Any](that) } // error } diff --git a/tests/neg/splice-in-top-level-splice-1.scala b/tests/neg/splice-in-top-level-splice-1.scala index c5ba06579320..921007e2d292 100644 --- a/tests/neg/splice-in-top-level-splice-1.scala +++ b/tests/neg/splice-in-top-level-splice-1.scala @@ -1,7 +1,7 @@ import scala.quoted._ object Foo { - inline def foo(): Int = ~bar($x) // error + inline def foo(): Int = ${bar($x)} // error def x: Expr[Int] = '{1} def bar(i: Int): Expr[Int] = i.toExpr } diff --git a/tests/neg/splice-in-top-level-splice-2.scala b/tests/neg/splice-in-top-level-splice-2.scala index a839f02f0bd8..58efc998f66a 100644 --- a/tests/neg/splice-in-top-level-splice-2.scala +++ b/tests/neg/splice-in-top-level-splice-2.scala @@ -1,6 +1,6 @@ import scala.quoted._ object Foo { - inline def foo(): Int = ~($x) // error + inline def foo(): Int = ${$x} // error def x: Expr[Expr[Int]] = '{ '{1} } } diff --git a/tests/neg/splice-non-expr.scala b/tests/neg/splice-non-expr.scala new file mode 100644 index 000000000000..d0236fd6a2a4 --- /dev/null +++ b/tests/neg/splice-non-expr.scala @@ -0,0 +1,11 @@ +class Foo { + '{ + ${3} // error + ${new Object} // error + ${"abc"} // error + ${()} // error + ${new Foo} // error + } + + def unary_~ : Int = 9 +} diff --git a/tests/pos-with-compiler/quote-0.scala b/tests/pos-with-compiler/quote-0.scala index 5f3adfa81744..d6ed376ce9d1 100644 --- a/tests/pos-with-compiler/quote-0.scala +++ b/tests/pos-with-compiler/quote-0.scala @@ -5,20 +5,20 @@ import scala.quoted.Toolbox.Default._ object Macros { inline def assert(expr: => Boolean): Unit = - ~assertImpl('{expr}) + ${ assertImpl('{expr}) } def assertImpl(expr: Expr[Boolean]) = - '{ if !($expr) then throw new AssertionError(s"failed assertion: ${~showExpr(expr)}") } + '{ if !($expr) then throw new AssertionError(s"failed assertion: ${${showExpr(expr)}}") } def showExpr[T](expr: Expr[T]): Expr[String] = expr.toString.toExpr - inline def power(inline n: Int, x: Double) = ~powerCode(n, '{x}) + inline def power(inline n: Int, x: Double) = ${ powerCode(n, '{x}) } def powerCode(n: Int, x: Expr[Double]): Expr[Double] = if (n == 0) '{1.0} else if (n == 1) x - else if (n % 2 == 0) '{ { val y = $x * $x; ~powerCode(n / 2, '{y}) } } - else '{ $x * ~powerCode(n - 1, x) } + else if (n % 2 == 0) '{ { val y = $x * $x; ${ powerCode(n / 2, '{y}) } } } + else '{ $x * ${ powerCode(n - 1, x) } } } class Test { @@ -29,13 +29,13 @@ class Test { val x = 1 assert(x != 0) - ~assertImpl('{x != 0}) + ${ assertImpl('{x != 0}) } val y = math.sqrt(2.0) power(3, y) - ~powerCode(3, '{math.sqrt(2.0)}) + ${ powerCode(3, '{math.sqrt(2.0)}) } } program.run diff --git a/tests/pos-with-compiler/quote-assert/quoted_2.scala b/tests/pos-with-compiler/quote-assert/quoted_2.scala index 1b7f35fd7a25..3e609a53ad10 100644 --- a/tests/pos-with-compiler/quote-assert/quoted_2.scala +++ b/tests/pos-with-compiler/quote-assert/quoted_2.scala @@ -5,14 +5,14 @@ import Macros._ object Test { inline def assert(expr: => Boolean): Unit = - ~ assertImpl('{expr}) + ${ assertImpl('{expr}) } val program = '{ val x = 1 assert(x != 0) - ~assertImpl('{x != 0}) + ${ assertImpl('{x != 0}) } } program.run diff --git a/tests/pos/i3898/quoted_1.scala b/tests/pos/i3898/quoted_1.scala index 6b30fce3910d..675ffc1af2fb 100644 --- a/tests/pos/i3898/quoted_1.scala +++ b/tests/pos/i3898/quoted_1.scala @@ -1,5 +1,5 @@ import scala.quoted._ object Macro { - inline def ff(args: Any*): String = ~impl('{args}) + inline def ff(args: Any*): String = ${impl('{args})} def impl(args: Expr[Seq[Any]]): Expr[String] = '{""} } diff --git a/tests/pos/i3898b/quoted_1.scala b/tests/pos/i3898b/quoted_1.scala index 3d0f8a2f26d7..b609a0b18f68 100644 --- a/tests/pos/i3898b/quoted_1.scala +++ b/tests/pos/i3898b/quoted_1.scala @@ -1,5 +1,5 @@ import scala.quoted._ object Macro { - inline def ff(x: Int, inline y: Int): String = ~impl('{x}) + inline def ff(x: Int, inline y: Int): String = ${impl('{x})} def impl(x: Expr[Int]): Expr[String] = '{""} } diff --git a/tests/pos/i3898c/quoted_1.scala b/tests/pos/i3898c/quoted_1.scala index 3d0f8a2f26d7..b609a0b18f68 100644 --- a/tests/pos/i3898c/quoted_1.scala +++ b/tests/pos/i3898c/quoted_1.scala @@ -1,5 +1,5 @@ import scala.quoted._ object Macro { - inline def ff(x: Int, inline y: Int): String = ~impl('{x}) + inline def ff(x: Int, inline y: Int): String = ${impl('{x})} def impl(x: Expr[Int]): Expr[String] = '{""} } diff --git a/tests/pos/i3912-1/i3912_1.scala b/tests/pos/i3912-1/i3912_1.scala index 998a9c159756..faa6c82a4ca8 100644 --- a/tests/pos/i3912-1/i3912_1.scala +++ b/tests/pos/i3912-1/i3912_1.scala @@ -1,7 +1,7 @@ import scala.quoted._ object Macros { - inline def foo(): Int = { ~impl() } + inline def foo(): Int = { ${ impl() } } def impl(): Expr[Int] = '{1} } \ No newline at end of file diff --git a/tests/pos/i3912-2/i3912_1.scala b/tests/pos/i3912-2/i3912_1.scala index 10702302c413..b6912a6efa74 100644 --- a/tests/pos/i3912-2/i3912_1.scala +++ b/tests/pos/i3912-2/i3912_1.scala @@ -1,7 +1,7 @@ import scala.quoted._ object Macros { - inline def foo2(): Unit = ~impl() + inline def foo2(): Unit = ${ impl() } def impl(): Expr[Int] = '{1} } \ No newline at end of file diff --git a/tests/pos/i3912-3/i3912_1.scala b/tests/pos/i3912-3/i3912_1.scala index 187dd90ff551..c1df47e41db6 100644 --- a/tests/pos/i3912-3/i3912_1.scala +++ b/tests/pos/i3912-3/i3912_1.scala @@ -3,7 +3,7 @@ import scala.quoted._ object Macros { inline def foo3(): Int = { { - ~impl() + ${ impl() } } } diff --git a/tests/pos/i4023b/Macro_1.scala b/tests/pos/i4023b/Macro_1.scala index 7fbb9f6429d8..bad8763aeeb2 100644 --- a/tests/pos/i4023b/Macro_1.scala +++ b/tests/pos/i4023b/Macro_1.scala @@ -1,5 +1,5 @@ import scala.quoted._ object Macro { - inline def ff[T](implicit t: Type[T]): Int = ~impl[T] + inline def ff[T](implicit t: Type[T]): Int = ${ impl[T] } def impl[T]: Expr[Int] = '{4} } diff --git a/tests/pos/i4380a.scala b/tests/pos/i4380a.scala index fefd5cc8b0f0..be0a710ff55c 100644 --- a/tests/pos/i4380a.scala +++ b/tests/pos/i4380a.scala @@ -14,7 +14,7 @@ object Test { case Bar(producer, nestedf) => { new Producer[Expr[A]] { def step(k: Expr[A] => Expr[Unit]): Expr[Unit] = '{ - val adv: Unit => Unit = { _ => ~producer.step((el) => nestedf(el))} + val adv: Unit => Unit = { _ => ${producer.step((el) => nestedf(el))} } } } } diff --git a/tests/pos/i4380b.scala b/tests/pos/i4380b.scala index ab8fff08c9fd..864d02d21885 100644 --- a/tests/pos/i4380b.scala +++ b/tests/pos/i4380b.scala @@ -3,6 +3,6 @@ import scala.quoted._ object Test { def step(k: (String => Expr[Unit])): Expr[Unit] = '{} def meth(): Unit = '{ - (i: Int) => ~step(el => '{} ) + (i: Int) => ${ step(el => '{} ) } } } diff --git a/tests/pos/i4514.scala b/tests/pos/i4514.scala index b7922db64445..ee9084eea2de 100644 --- a/tests/pos/i4514.scala +++ b/tests/pos/i4514.scala @@ -1,4 +1,4 @@ object Foo { - inline def foo[X](x: X): Unit = ~fooImpl('{x}) + inline def foo[X](x: X): Unit = ${fooImpl('{x})} def fooImpl[X: quoted.Type](x: X): quoted.Expr[Unit] = '{} } diff --git a/tests/pos/i4734/Macro_1.scala b/tests/pos/i4734/Macro_1.scala index 03bd4117dc01..71462b7d246b 100644 --- a/tests/pos/i4734/Macro_1.scala +++ b/tests/pos/i4734/Macro_1.scala @@ -3,7 +3,7 @@ import scala.quoted._ object Macros { inline def unrolledForeach(f: Int => Int): Int = - ~unrolledForeachImpl('{f}) + ${unrolledForeachImpl('{f})} def unrolledForeachImpl(f: Expr[Int => Int]): Expr[Int] = '{ val size: Int = 5 diff --git a/tests/pos/i4773.scala b/tests/pos/i4773.scala index 5dbccb5b7b19..63e73f910586 100644 --- a/tests/pos/i4773.scala +++ b/tests/pos/i4773.scala @@ -1,7 +1,7 @@ import scala.quoted._ object Foo { - inline def foo2(): Unit = ~foo2Impl() + inline def foo2(): Unit = ${foo2Impl()} def foo2Impl(): Expr[Unit] = '{} inline def foo(): Unit = foo2() } diff --git a/tests/pos/i4774a.scala b/tests/pos/i4774a.scala index 4f1535272a20..da92ac562fd4 100644 --- a/tests/pos/i4774a.scala +++ b/tests/pos/i4774a.scala @@ -4,6 +4,6 @@ import scala.quoted._ object Test { def loop[T](x: Expr[T])(implicit t: Type[T]): Expr[T] = '{ val y: $t = $x - ~loop('{y}) + ${loop('{y})} } } diff --git a/tests/pos/i4774c.scala b/tests/pos/i4774c.scala index 55be40815fdd..417baba571b9 100644 --- a/tests/pos/i4774c.scala +++ b/tests/pos/i4774c.scala @@ -2,5 +2,5 @@ import scala.quoted._ object Test { - def loop[T](x: Expr[T])(implicit t: Type[T]): Expr[T] = '{ val y = $x; ~loop('{y}) } + def loop[T](x: Expr[T])(implicit t: Type[T]): Expr[T] = '{ val y = $x; ${loop('{y})} } } diff --git a/tests/pos/i4774d.scala b/tests/pos/i4774d.scala index bc945397f11b..87b48343349a 100644 --- a/tests/pos/i4774d.scala +++ b/tests/pos/i4774d.scala @@ -3,5 +3,5 @@ import scala.quoted._ object Test { def loop[T](x: Expr[T])(implicit t: Type[T]): Expr[T] = - '{ val y: T = $x; ~loop('{y}) } + '{ val y: T = $x; ${loop('{y})} } } diff --git a/tests/pos/i4846.scala b/tests/pos/i4846.scala index 53c5c64e4d9f..87d6fa76849a 100644 --- a/tests/pos/i4846.scala +++ b/tests/pos/i4846.scala @@ -1,6 +1,6 @@ import scala.quoted._ object Test { - inline def foo(inline x: Int): Int = ~fooImpl(x, '{x}, '{ '{x} }, '{ '{ '{x} } }) + inline def foo(inline x: Int): Int = ${fooImpl(x, '{x}, '{ '{x} }, '{ '{ '{x} } })} def fooImpl(a: Int, b: Expr[Int], c: Expr[Expr[Int]], d: Expr[Expr[Expr[Int]]]): Expr[Int] = ??? } diff --git a/tests/pos/macro-with-type/Macro_1.scala b/tests/pos/macro-with-type/Macro_1.scala index 72eb9fee3978..c515c8a51ccc 100644 --- a/tests/pos/macro-with-type/Macro_1.scala +++ b/tests/pos/macro-with-type/Macro_1.scala @@ -1,5 +1,5 @@ import scala.quoted._ object Macro { - inline def ff: Unit = ~impl('[Int]) + inline def ff: Unit = ${impl('[Int])} def impl(t: Type[Int]): Expr[Unit] = '{} } diff --git a/tests/pos/power-macro/Macro_1.scala b/tests/pos/power-macro/Macro_1.scala index 59b7f7731b09..375332b253a2 100644 --- a/tests/pos/power-macro/Macro_1.scala +++ b/tests/pos/power-macro/Macro_1.scala @@ -3,10 +3,10 @@ import scala.quoted.Expr object PowerMacro { - inline def power(inline n: Long, x: Double) = ~powerCode(n, '{x}) + inline def power(inline n: Long, x: Double) = ${powerCode(n, '{x})} def powerCode(n: Long, x: Expr[Double]): Expr[Double] = if (n == 0) '{1.0} - else if (n % 2 == 0) '{ { val y = $x * $x; ~powerCode(n / 2, '{y}) } } - else '{ $x * ~powerCode(n - 1, x) } + else if (n % 2 == 0) '{ { val y = $x * $x; ${powerCode(n / 2, '{y})} } } + else '{ $x * ${powerCode(n - 1, x)} } } diff --git a/tests/pos/quote-1.scala b/tests/pos/quote-1.scala index 006c0562dbee..5772b7d49c1e 100644 --- a/tests/pos/quote-1.scala +++ b/tests/pos/quote-1.scala @@ -3,7 +3,7 @@ import scala.quoted._ object Test { def f[T](x: Expr[T])(implicit t: Type[T]) = '{ - val y: t.unary_~ = x.unary_~ + val y: $t = $x val z = $x } diff --git a/tests/pos/quote-bind-T.scala b/tests/pos/quote-bind-T.scala index 482eafc0a49e..2884ec6e22d5 100644 --- a/tests/pos/quote-bind-T.scala +++ b/tests/pos/quote-bind-T.scala @@ -3,7 +3,7 @@ import scala.quoted._ object Test { def matchX[T](x: Expr[T])(implicit t: Type[T]): Expr[T] = '{ - (~x) match { + $x match { case y: T => y } } diff --git a/tests/pos/quote-lift.scala b/tests/pos/quote-lift.scala index 716631a6bace..7d3a00322a14 100644 --- a/tests/pos/quote-lift.scala +++ b/tests/pos/quote-lift.scala @@ -2,12 +2,12 @@ import scala.quoted._ object Test { - '{ ~implicitly[Liftable[Int]].toExpr(1) } + '{ ${implicitly[Liftable[Int]].toExpr(1)} } { import Liftable._ - '{ ~IntIsLiftable.toExpr(1) } + '{ ${IntIsLiftable.toExpr(1)} } '{ ${1.toExpr} } diff --git a/tests/pos/quote-nested-object/Macro_1.scala b/tests/pos/quote-nested-object/Macro_1.scala index 34e59e4e09d1..1ee308d1297a 100644 --- a/tests/pos/quote-nested-object/Macro_1.scala +++ b/tests/pos/quote-nested-object/Macro_1.scala @@ -6,15 +6,15 @@ object Macro { object Implementation { - inline def plus(inline n: Int, m: Int): Int = ~plus(n, '{m}) + inline def plus(inline n: Int, m: Int): Int = ${ plus(n, '{m}) } def plus(n: Int, m: Expr[Int]): Expr[Int] = if (n == 0) m - else '{ ~{n.toExpr} + $m } + else '{ ${n.toExpr} + $m } object Implementation2 { - inline def plus(inline n: Int, m: Int): Int = ~plus(n, '{m}) + inline def plus(inline n: Int, m: Int): Int = ${ plus(n, '{m}) } def plus(n: Int, m: Expr[Int]): Expr[Int] = if (n == 0) m diff --git a/tests/pos/quote-non-static-macro.scala b/tests/pos/quote-non-static-macro.scala index 706c4ee59fc6..5b2bcb19a05d 100644 --- a/tests/pos/quote-non-static-macro.scala +++ b/tests/pos/quote-non-static-macro.scala @@ -1,18 +1,18 @@ import scala.quoted._ class Foo { - inline def foo: Unit = ~Foo.impl + inline def foo: Unit = ${Foo.impl} object Bar { - inline def foo: Unit = ~Foo.impl + inline def foo: Unit = ${Foo.impl} } } object Foo { class Baz { - inline def foo: Unit = ~impl + inline def foo: Unit = ${impl} } object Quox { - inline def foo: Unit = ~Foo.impl + inline def foo: Unit = ${Foo.impl} } def impl: Expr[Unit] = '{} } diff --git a/tests/run-custom-args/Yretain-trees/tasty-extractors-owners.check b/tests/run-custom-args/Yretain-trees/tasty-extractors-owners.check index 114de84021de..03ae9c799944 100644 --- a/tests/run-custom-args/Yretain-trees/tasty-extractors-owners.check +++ b/tests/run-custom-args/Yretain-trees/tasty-extractors-owners.check @@ -1,5 +1,5 @@ foo -DefDef("main", Nil, List(List(ValDef("args", TypeTree.Applied(TypeTree.Ident("Array"), List(TypeTree.Ident("String"))), None))), TypeTree.Ident("Unit"), Some(Term.Block(Nil, Term.Inlined(Some(TypeTree.Ident("Macros$")), Nil, Term.Typed(Term.Select(Term.Apply(Term.Apply(Term.TypeApply(Term.Ident("impl"), List(TypeTree.Inferred())), List(Term.Apply(Term.TypeApply(Term.Ident("apply"), List(TypeTree.Inferred())), List(Term.Inlined(None, Nil, Term.Block(List(DefDef("foo", Nil, Nil, TypeTree.Inferred(), Some(Term.Block(List(DefDef("bar", Nil, Nil, TypeTree.Inferred(), Some(Term.Literal(Constant.Int(1)))), ValDef("bar2", TypeTree.Inferred(), Some(Term.Literal(Constant.Int(2))))), Term.Typed(Term.Ident("bar"), TypeTree.Inferred())))), ValDef("foo2", TypeTree.Inferred(), Some(Term.Block(List(DefDef("baz", Nil, Nil, TypeTree.Inferred(), Some(Term.Literal(Constant.Int(3)))), ValDef("baz2", TypeTree.Inferred(), Some(Term.Literal(Constant.Int(4))))), Term.Typed(Term.Ident("baz"), TypeTree.Inferred())))), ClassDef("A", DefDef("", Nil, List(Nil), TypeTree.Inferred(), None), List(Term.Apply(Term.Select(Term.New(TypeTree.Inferred()), ""), Nil)), Nil, None, List(TypeDef("B", TypeTree.Ident("Int")), DefDef("b", Nil, Nil, TypeTree.Inferred(), Some(Term.Literal(Constant.Int(5)))), ValDef("b2", TypeTree.Inferred(), Some(Term.Literal(Constant.Int(6))))))), Term.Literal(Constant.Unit()))))))), List(Term.Ident("macroContext"))), "unary_~"), TypeTree.Ident("Unit")))))) +DefDef("main", Nil, List(List(ValDef("args", TypeTree.Applied(TypeTree.Ident("Array"), List(TypeTree.Ident("String"))), None))), TypeTree.Ident("Unit"), Some(Term.Block(Nil, Term.Inlined(Some(TypeTree.Ident("Macros$")), Nil, Term.Typed(Term.Select(Term.Apply(Term.Apply(Term.TypeApply(Term.Ident("impl"), List(TypeTree.Inferred())), List(Term.Apply(Term.TypeApply(Term.Ident("apply"), List(TypeTree.Inferred())), List(Term.Inlined(None, Nil, Term.Block(List(DefDef("foo", Nil, Nil, TypeTree.Inferred(), Some(Term.Block(List(DefDef("bar", Nil, Nil, TypeTree.Inferred(), Some(Term.Literal(Constant.Int(1)))), ValDef("bar2", TypeTree.Inferred(), Some(Term.Literal(Constant.Int(2))))), Term.Typed(Term.Ident("bar"), TypeTree.Inferred())))), ValDef("foo2", TypeTree.Inferred(), Some(Term.Block(List(DefDef("baz", Nil, Nil, TypeTree.Inferred(), Some(Term.Literal(Constant.Int(3)))), ValDef("baz2", TypeTree.Inferred(), Some(Term.Literal(Constant.Int(4))))), Term.Typed(Term.Ident("baz"), TypeTree.Inferred())))), ClassDef("A", DefDef("", Nil, List(Nil), TypeTree.Inferred(), None), List(Term.Apply(Term.Select(Term.New(TypeTree.Inferred()), ""), Nil)), Nil, None, List(TypeDef("B", TypeTree.Ident("Int")), DefDef("b", Nil, Nil, TypeTree.Inferred(), Some(Term.Literal(Constant.Int(5)))), ValDef("b2", TypeTree.Inferred(), Some(Term.Literal(Constant.Int(6))))))), Term.Literal(Constant.Unit()))))))), List(Term.Ident("macroContext"))), "splice"), TypeTree.Ident("Unit")))))) bar DefDef("foo", Nil, Nil, TypeTree.Inferred(), Some(Term.Block(List(DefDef("bar", Nil, Nil, TypeTree.Inferred(), Some(Term.Literal(Constant.Int(1)))), ValDef("bar2", TypeTree.Inferred(), Some(Term.Literal(Constant.Int(2))))), Term.Typed(Term.Ident("bar"), TypeTree.Inferred())))) @@ -8,7 +8,7 @@ bar2 DefDef("foo", Nil, Nil, TypeTree.Inferred(), Some(Term.Block(List(DefDef("bar", Nil, Nil, TypeTree.Inferred(), Some(Term.Literal(Constant.Int(1)))), ValDef("bar2", TypeTree.Inferred(), Some(Term.Literal(Constant.Int(2))))), Term.Typed(Term.Ident("bar"), TypeTree.Inferred())))) foo2 -DefDef("main", Nil, List(List(ValDef("args", TypeTree.Applied(TypeTree.Ident("Array"), List(TypeTree.Ident("String"))), None))), TypeTree.Ident("Unit"), Some(Term.Block(Nil, Term.Inlined(Some(TypeTree.Ident("Macros$")), Nil, Term.Typed(Term.Select(Term.Apply(Term.Apply(Term.TypeApply(Term.Ident("impl"), List(TypeTree.Inferred())), List(Term.Apply(Term.TypeApply(Term.Ident("apply"), List(TypeTree.Inferred())), List(Term.Inlined(None, Nil, Term.Block(List(DefDef("foo", Nil, Nil, TypeTree.Inferred(), Some(Term.Block(List(DefDef("bar", Nil, Nil, TypeTree.Inferred(), Some(Term.Literal(Constant.Int(1)))), ValDef("bar2", TypeTree.Inferred(), Some(Term.Literal(Constant.Int(2))))), Term.Typed(Term.Ident("bar"), TypeTree.Inferred())))), ValDef("foo2", TypeTree.Inferred(), Some(Term.Block(List(DefDef("baz", Nil, Nil, TypeTree.Inferred(), Some(Term.Literal(Constant.Int(3)))), ValDef("baz2", TypeTree.Inferred(), Some(Term.Literal(Constant.Int(4))))), Term.Typed(Term.Ident("baz"), TypeTree.Inferred())))), ClassDef("A", DefDef("", Nil, List(Nil), TypeTree.Inferred(), None), List(Term.Apply(Term.Select(Term.New(TypeTree.Inferred()), ""), Nil)), Nil, None, List(TypeDef("B", TypeTree.Ident("Int")), DefDef("b", Nil, Nil, TypeTree.Inferred(), Some(Term.Literal(Constant.Int(5)))), ValDef("b2", TypeTree.Inferred(), Some(Term.Literal(Constant.Int(6))))))), Term.Literal(Constant.Unit()))))))), List(Term.Ident("macroContext"))), "unary_~"), TypeTree.Ident("Unit")))))) +DefDef("main", Nil, List(List(ValDef("args", TypeTree.Applied(TypeTree.Ident("Array"), List(TypeTree.Ident("String"))), None))), TypeTree.Ident("Unit"), Some(Term.Block(Nil, Term.Inlined(Some(TypeTree.Ident("Macros$")), Nil, Term.Typed(Term.Select(Term.Apply(Term.Apply(Term.TypeApply(Term.Ident("impl"), List(TypeTree.Inferred())), List(Term.Apply(Term.TypeApply(Term.Ident("apply"), List(TypeTree.Inferred())), List(Term.Inlined(None, Nil, Term.Block(List(DefDef("foo", Nil, Nil, TypeTree.Inferred(), Some(Term.Block(List(DefDef("bar", Nil, Nil, TypeTree.Inferred(), Some(Term.Literal(Constant.Int(1)))), ValDef("bar2", TypeTree.Inferred(), Some(Term.Literal(Constant.Int(2))))), Term.Typed(Term.Ident("bar"), TypeTree.Inferred())))), ValDef("foo2", TypeTree.Inferred(), Some(Term.Block(List(DefDef("baz", Nil, Nil, TypeTree.Inferred(), Some(Term.Literal(Constant.Int(3)))), ValDef("baz2", TypeTree.Inferred(), Some(Term.Literal(Constant.Int(4))))), Term.Typed(Term.Ident("baz"), TypeTree.Inferred())))), ClassDef("A", DefDef("", Nil, List(Nil), TypeTree.Inferred(), None), List(Term.Apply(Term.Select(Term.New(TypeTree.Inferred()), ""), Nil)), Nil, None, List(TypeDef("B", TypeTree.Ident("Int")), DefDef("b", Nil, Nil, TypeTree.Inferred(), Some(Term.Literal(Constant.Int(5)))), ValDef("b2", TypeTree.Inferred(), Some(Term.Literal(Constant.Int(6))))))), Term.Literal(Constant.Unit()))))))), List(Term.Ident("macroContext"))), "splice"), TypeTree.Ident("Unit")))))) baz ValDef("foo2", TypeTree.Inferred(), Some(Term.Block(List(DefDef("baz", Nil, Nil, TypeTree.Inferred(), Some(Term.Literal(Constant.Int(3)))), ValDef("baz2", TypeTree.Inferred(), Some(Term.Literal(Constant.Int(4))))), Term.Typed(Term.Ident("baz"), TypeTree.Inferred())))) diff --git a/tests/run-custom-args/Yretain-trees/tasty-extractors-owners/quoted_1.scala b/tests/run-custom-args/Yretain-trees/tasty-extractors-owners/quoted_1.scala index 65f98e5806f7..da3eadb062fd 100644 --- a/tests/run-custom-args/Yretain-trees/tasty-extractors-owners/quoted_1.scala +++ b/tests/run-custom-args/Yretain-trees/tasty-extractors-owners/quoted_1.scala @@ -5,7 +5,7 @@ import scala.tasty._ object Macros { implicit inline def printOwners[T](x: => T): Unit = - ~impl('{x}) + ${ impl('{x}) } def impl[T](x: Expr[T])(implicit reflect: Reflection): Expr[Unit] = { import reflect._ diff --git a/tests/run-custom-args/Yretain-trees/tasty-load-tree-1/quoted_1.scala b/tests/run-custom-args/Yretain-trees/tasty-load-tree-1/quoted_1.scala index c367f49666aa..471371ca32bf 100644 --- a/tests/run-custom-args/Yretain-trees/tasty-load-tree-1/quoted_1.scala +++ b/tests/run-custom-args/Yretain-trees/tasty-load-tree-1/quoted_1.scala @@ -5,7 +5,7 @@ import scala.tasty._ object Foo { inline def inspectBody(i: => Int): String = - ~inspectBodyImpl('{i}) + ${ inspectBodyImpl('{i}) } def inspectBodyImpl(x: Expr[Int])(implicit reflect: Reflection): Expr[String] = { import reflect._ diff --git a/tests/run-custom-args/Yretain-trees/tasty-load-tree-2/quoted_1.scala b/tests/run-custom-args/Yretain-trees/tasty-load-tree-2/quoted_1.scala index 5b76aa58918f..9169c3ca2777 100644 --- a/tests/run-custom-args/Yretain-trees/tasty-load-tree-2/quoted_1.scala +++ b/tests/run-custom-args/Yretain-trees/tasty-load-tree-2/quoted_1.scala @@ -5,7 +5,7 @@ import scala.tasty._ object Foo { inline def inspectBody(i: => Int): String = - ~inspectBodyImpl('{i}) + ${ inspectBodyImpl('{i}) } def inspectBodyImpl(x: Expr[Int])(implicit reflect: Reflection): Expr[String] = { import reflect._ diff --git a/tests/run-with-compiler-custom-args/staged-streams_1.scala b/tests/run-with-compiler-custom-args/staged-streams_1.scala index 42948d34b45f..dcb6f1bdb922 100644 --- a/tests/run-with-compiler-custom-args/staged-streams_1.scala +++ b/tests/run-with-compiler-custom-args/staged-streams_1.scala @@ -14,13 +14,15 @@ object Test { object Var { def apply[T: Type, U: Type](init: Expr[T])(body: Var[T] => Expr[U]): Expr[U] = '{ - var x = ~init - ~body( - new Var[T] { - def get: Expr[T] = '{x} - def update(e: Expr[T]): Expr[Unit] = '{ x = ~e } - } - ) + var x = $init + ${ + body( + new Var[T] { + def get: Expr[T] = '{x} + def update(e: Expr[T]): Expr[Unit] = '{ x = $e } + } + ) + } } } @@ -95,16 +97,17 @@ object Test { * @tparam W the type of the accumulator * @return */ - def fold[W: Type](z: Expr[W], f: ((Expr[W], Expr[A]) => Expr[W])): Expr[W] = { - Var(z) { s: Var[W] => '{ - ~foldRaw[Expr[A]]((a: Expr[A]) => '{ - ~s.update(f(s.get, a)) - }, stream) - - ~s.get - } - } - } + def fold[W: Type](z: Expr[W], f: ((Expr[W], Expr[A]) => Expr[W])): Expr[W] = { + Var(z) { s: Var[W] => '{ + ${ + foldRaw[Expr[A]]((a: Expr[A]) => '{ + ${ s.update(f(s.get, a)) } + }, stream) + } + ${ s.get } + } + } + } private def foldRaw[A](consumer: A => Expr[Unit], stream: StagedStream[A]): Expr[Unit] = { stream match { @@ -112,14 +115,14 @@ object Test { producer.card match { case Many => producer.init(sp => '{ - while(~producer.hasNext(sp)) { - ~producer.step(sp, consumer) + while(${producer.hasNext(sp)}) { + ${producer.step(sp, consumer)} } }) case AtMost1 => producer.init(sp => '{ - if (~producer.hasNext(sp)) { - ~producer.step(sp, consumer) + if (${producer.hasNext(sp)}) { + ${producer.step(sp, consumer)} } }) } @@ -137,7 +140,7 @@ object Test { * @return a new stream resulting from applying `mapRaw` and threading the element of the first stream downstream. */ def map[B : Type](f: (Expr[A] => Expr[B])): Stream[B] = { - Stream(mapRaw[Expr[A], Expr[B]](a => k => '{ ~k(f(a)) }, stream)) + Stream(mapRaw[Expr[A], Expr[B]](a => k => k(f(a)), stream)) } /** Handles generically the mapping of elements from one producer to another. @@ -299,15 +302,15 @@ object Test { def step(st: St, k: (((Var[Int], A)) => Expr[Unit])): Expr[Unit] = { val (counter, currentState) = st producer.step(currentState, el => '{ - ~k((counter, el)) + ${k((counter, el))} }) } def hasNext(st: St): Expr[Boolean] = { val (counter, currentState) = st producer.card match { - case Many => '{ ~counter.get > 0 && ~producer.hasNext(currentState) } - case AtMost1 => '{ ~producer.hasNext(currentState) } + case Many => '{ ${counter.get} > 0 && ${producer.hasNext(currentState)} } + case AtMost1 => producer.hasNext(currentState) } } } @@ -329,8 +332,8 @@ object Test { // Map an enhanced stream to a stream that produces the elements. Before // invoking the continuation for the element, "use" the variable accordingly. mapRaw[(Var[Int], A), A]((t: (Var[Int], A)) => k => '{ - ~t._1.update('{~t._1.get - 1}) - ~k(t._2) + ${t._1.update('{${t._1.get} - 1})} + ${k(t._2)} }, enhancedStream) } case nested: Nested[A, bt] => { @@ -340,9 +343,9 @@ object Test { // Before invoking the continuation for the element, "use" the variable accordingly. // In contrast to the linear case, the variable is initialized in the originating stream. mapRaw[A, A]((el => k => '{ - ~t._1.update('{~t._1.get - 1}) - ~k(el) - }), addTerminationCondition(b => '{ ~t._1.get > 0 && ~b}, nested.nestedf(t._2))) + ${t._1.update('{${t._1.get} - 1})} + ${k(el)} + }), addTerminationCondition(b => '{ ${t._1.get} > 0 && $b}, nested.nestedf(t._2))) }) } } @@ -361,7 +364,7 @@ object Test { pushLinear[A = Expr[A], C = B](producer1, producer2, nestf2) case (Nested(producer1, nestf1), Linear(producer2)) => - mapRaw[(B, Expr[A]), (Expr[A], B)]((t => k => '{ ~k((t._2, t._1)) }), pushLinear[A = B, C = Expr[A]](producer2, producer1, nestf1)) + mapRaw[(B, Expr[A]), (Expr[A], B)]((t => k => '{ ${k((t._2, t._1))} }), pushLinear[A = B, C = Expr[A]](producer2, producer1, nestf1)) case (Nested(producer1, nestf1), Nested(producer2, nestf2)) => zipRaw[A, B](Linear(makeLinear(stream1)), stream2) @@ -442,27 +445,27 @@ object Test { case Linear(producer) => producer.card match { case AtMost1 => producer.init(st => '{ - if(~producer.hasNext(st)) { - ~producer.step(st, k) + if(${producer.hasNext(st)}) { + ${producer.step(st, k)} } else { - val f = ~nadv.get + val f = ${nadv.get} f(()) } }) case Many => producer.init(st => '{ - val oldnadv: Unit => Unit = ~nadv.get + val oldnadv: Unit => Unit = ${nadv.get} val adv1: Unit => Unit = { _: Unit => { - if(~producer.hasNext(st)) { - ~producer.step(st, k) + if(${producer.hasNext(st)}) { + ${producer.step(st, k)} } else { - ~nadv.update('{oldnadv}) + ${nadv.update('{oldnadv})} oldnadv(()) } }} - ~nadv.update('{adv1}) + ${nadv.update('{adv1})} adv1(()) }) } @@ -486,17 +489,17 @@ object Test { // Code generation of the `adv` function def adv: Unit => Unit = { _ => - ~hasNext.update(producer.hasNext(st)) - if(~hasNext.get) { - ~producer.step(st, el => { + ${hasNext.update(producer.hasNext(st))} + if(${hasNext.get}) { + ${producer.step(st, el => { makeAdvanceFunction[Expr[A]](nadv, (a => curr.update(a)), nestedf(el)) - }) + })} } } - ~nadv.update('{adv}) + ${nadv.update('{adv})} adv(()) - ~k((hasNext, curr, nadv)) + ${k((hasNext, curr, nadv))} }} }} }}) @@ -505,10 +508,10 @@ object Test { def step(st: St, k: Expr[A] => Expr[Unit]): Expr[Unit] = { val (flag, current, nadv) = st '{ - var el = ~current.get - val f: Unit => Unit = ~nadv.get + var el = ${current.get} + val f: Unit => Unit = ${nadv.get} f(()) - ~k('{el}) + ${k('{el})} } } @@ -529,20 +532,20 @@ object Test { val card: Cardinality = Many def init(k: St => Expr[Unit]): Expr[Unit] = { - producer.init(s1 => '{ ~nestedProducer.init(s2 => - Var('{ ~producer.hasNext(s1) }) { flag => + producer.init(s1 => '{ ${nestedProducer.init(s2 => + Var(producer.hasNext(s1)) { flag => k((flag, s1, s2)) - })}) + })}}) } def step(st: St, k: ((Var[Boolean], producer.St, B)) => Expr[Unit]): Expr[Unit] = { val (flag, s1, s2) = st - nestedProducer.step(s2, b => '{ ~k((flag, s1, b)) }) + nestedProducer.step(s2, b => '{ ${k((flag, s1, b))} }) } def hasNext(st: St): Expr[Boolean] = { val (flag, s1, s2) = st - '{ ~flag.get && ~nestedProducer.hasNext(s2) } + '{ ${flag.get} && ${nestedProducer.hasNext(s2)} } } } @@ -550,9 +553,9 @@ object Test { val (flag, s1, b) = t mapRaw[C, (A, C)]((c => k => '{ - ~producer.step(s1, a => '{ ~k((a, c)) }) - ~flag.update(producer.hasNext(s1)) - }), addTerminationCondition((b_flag: Expr[Boolean]) => '{ ~flag.get && ~b_flag }, nestedf(b))) + ${producer.step(s1, a => '{ ${k((a, c))} })} + ${flag.update(producer.hasNext(s1))} + }), addTerminationCondition((b_flag: Expr[Boolean]) => '{ ${flag.get} && $b_flag }, nestedf(b))) }) } @@ -564,17 +567,17 @@ object Test { val card: Cardinality = Many def init(k: St => Expr[Unit]): Expr[Unit] = { - producer1.init(s1 => '{ ~producer2.init(s2 => '{ ~k((s1, s2)) })}) + producer1.init(s1 => producer2.init(s2 => k((s1, s2)) )) } def step(st: St, k: ((A, B)) => Expr[Unit]): Expr[Unit] = { val (s1, s2) = st - producer1.step(s1, el1 => '{ ~producer2.step(s2, el2 => '{ ~k((el1, el2)) })}) + producer1.step(s1, el1 => producer2.step(s2, el2 => k((el1, el2)) )) } def hasNext(st: St): Expr[Boolean] = { val (s1, s2) = st - '{ ~producer1.hasNext(s1) && ~producer2.hasNext(s2) } + '{ ${producer1.hasNext(s1)} && ${producer2.hasNext(s2)} } } } } @@ -582,7 +585,7 @@ object Test { /** zip **/ def zip[B: Type, C: Type](f: (Expr[A] => Expr[B] => Expr[C]), stream2: Stream[B]): Stream[C] = { val Stream(stream_b) = stream2 - Stream(mapRaw[(Expr[A], Expr[B]), Expr[C]]((t => k => '{ ~k(f(t._1)(t._2)) }), zipRaw[A, Expr[B]](stream, stream_b))) + Stream(mapRaw[(Expr[A], Expr[B]), Expr[C]]((t => k => k(f(t._1)(t._2))), zipRaw[A, Expr[B]](stream, stream_b))) } } @@ -594,7 +597,7 @@ object Test { val card = Many def init(k: St => Expr[Unit]): Expr[Unit] = { - Var('{(~arr).length}) { n => + Var('{($arr).length}) { n => Var(0.toExpr){ i => k((i, n, arr)) } @@ -604,16 +607,16 @@ object Test { def step(st: St, k: (Expr[A] => Expr[Unit])): Expr[Unit] = { val (i, _, arr) = st '{ - val el = (~arr).apply(~i.get) - ~i.update('{ ~i.get + 1 }) - ~k('{el}) + val el = ($arr).apply(${i.get}) + ${i.update('{ ${i.get} + 1 })} + ${k('{el})} } } def hasNext(st: St): Expr[Boolean] = { val (i, n, _) = st '{ - (~i.get < ~n.get) + (${i.get} < ${n.get}) } } } @@ -624,53 +627,53 @@ object Test { def test1() = Stream .of('{Array(1, 2, 3)}) - .fold('{0}, ((a: Expr[Int], b : Expr[Int]) => '{ ~a + ~b })) + .fold('{0}, ((a: Expr[Int], b : Expr[Int]) => '{ $a + $b })) def test2() = Stream .of('{Array(1, 2, 3)}) - .map((a: Expr[Int]) => '{ ~a * 2 }) - .fold('{0}, ((a: Expr[Int], b : Expr[Int]) => '{ ~a + ~b })) + .map((a: Expr[Int]) => '{ $a * 2 }) + .fold('{0}, ((a: Expr[Int], b : Expr[Int]) => '{ $a + $b })) def test3() = Stream .of('{Array(1, 2, 3)}) - .flatMap((d: Expr[Int]) => Stream.of('{Array(1, 2, 3)}).map((dp: Expr[Int]) => '{ ~d * ~dp })) - .fold('{0}, ((a: Expr[Int], b : Expr[Int]) => '{ ~a + ~b })) + .flatMap((d: Expr[Int]) => Stream.of('{Array(1, 2, 3)}).map((dp: Expr[Int]) => '{ $d * $dp })) + .fold('{0}, ((a: Expr[Int], b : Expr[Int]) => '{ $a + $b })) def test4() = Stream .of('{Array(1, 2, 3)}) - .filter((d: Expr[Int]) => '{ ~d % 2 == 0 }) - .fold('{0}, ((a: Expr[Int], b : Expr[Int]) => '{ ~a + ~b })) + .filter((d: Expr[Int]) => '{ $d % 2 == 0 }) + .fold('{0}, ((a: Expr[Int], b : Expr[Int]) => '{ $a + $b })) def test5() = Stream .of('{Array(1, 2, 3)}) .take('{2}) - .fold('{0}, ((a: Expr[Int], b : Expr[Int]) => '{ ~a + ~b })) + .fold('{0}, ((a: Expr[Int], b : Expr[Int]) => '{ $a + $b })) def test6() = Stream .of('{Array(1, 1, 1)}) .flatMap((d: Expr[Int]) => Stream.of('{Array(1, 2, 3)}).take('{2})) .take('{5}) - .fold('{0}, ((a: Expr[Int], b : Expr[Int]) => '{ ~a + ~b })) + .fold('{0}, ((a: Expr[Int], b : Expr[Int]) => '{ $a + $b })) def test7() = Stream .of('{Array(1, 2, 3)}) - .zip(((a : Expr[Int]) => (b : Expr[Int]) => '{ ~a + ~b }), Stream.of('{Array(1, 2, 3)})) - .fold('{0}, ((a: Expr[Int], b : Expr[Int]) => '{ ~a + ~b })) + .zip(((a : Expr[Int]) => (b : Expr[Int]) => '{ $a + $b }), Stream.of('{Array(1, 2, 3)})) + .fold('{0}, ((a: Expr[Int], b : Expr[Int]) => '{ $a + $b })) def test8() = Stream .of('{Array(1, 2, 3)}) - .zip(((a : Expr[Int]) => (b : Expr[Int]) => '{ ~a + ~b }), Stream.of('{Array(1, 2, 3)}).flatMap((d: Expr[Int]) => Stream.of('{Array(1, 2, 3)}).map((dp: Expr[Int]) => '{ ~d + ~dp }))) - .fold('{0}, ((a: Expr[Int], b : Expr[Int]) => '{ ~a + ~b })) + .zip(((a : Expr[Int]) => (b : Expr[Int]) => '{ $a + $b }), Stream.of('{Array(1, 2, 3)}).flatMap((d: Expr[Int]) => Stream.of('{Array(1, 2, 3)}).map((dp: Expr[Int]) => '{ $d + $dp }))) + .fold('{0}, ((a: Expr[Int], b : Expr[Int]) => '{ $a + $b })) def test9() = Stream - .of('{Array(1, 2, 3)}).flatMap((d: Expr[Int]) => Stream.of('{Array(1, 2, 3)}).map((dp: Expr[Int]) => '{ ~d + ~dp })) - .zip(((a : Expr[Int]) => (b : Expr[Int]) => '{ ~a + ~b }), Stream.of('{Array(1, 2, 3)}) ) - .fold('{0}, ((a: Expr[Int], b : Expr[Int]) => '{ ~a + ~b })) + .of('{Array(1, 2, 3)}).flatMap((d: Expr[Int]) => Stream.of('{Array(1, 2, 3)}).map((dp: Expr[Int]) => '{ $d + $dp })) + .zip(((a : Expr[Int]) => (b : Expr[Int]) => '{ $a + $b }), Stream.of('{Array(1, 2, 3)}) ) + .fold('{0}, ((a: Expr[Int], b : Expr[Int]) => '{ $a + $b })) def test10() = Stream - .of('{Array(1, 2, 3)}).flatMap((d: Expr[Int]) => Stream.of('{Array(1, 2, 3)}).map((dp: Expr[Int]) => '{ ~d + ~dp })) - .zip(((a : Expr[Int]) => (b : Expr[Int]) => '{ ~a + ~b }), Stream.of('{Array(1, 2, 3)}).flatMap((d: Expr[Int]) => Stream.of('{Array(1, 2, 3)}).map((dp: Expr[Int]) => '{ ~d + ~dp })) ) - .fold('{0}, ((a: Expr[Int], b : Expr[Int]) => '{ ~a + ~b })) + .of('{Array(1, 2, 3)}).flatMap((d: Expr[Int]) => Stream.of('{Array(1, 2, 3)}).map((dp: Expr[Int]) => '{ $d + $dp })) + .zip(((a : Expr[Int]) => (b : Expr[Int]) => '{ $a + $b }), Stream.of('{Array(1, 2, 3)}).flatMap((d: Expr[Int]) => Stream.of('{Array(1, 2, 3)}).map((dp: Expr[Int]) => '{ $d + $dp })) ) + .fold('{0}, ((a: Expr[Int], b : Expr[Int]) => '{ $a + $b })) def main(args: Array[String]): Unit = { implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make diff --git a/tests/run-with-compiler/i3823-b.scala b/tests/run-with-compiler/i3823-b.scala index 51f13b739e6f..75e35d6ca619 100644 --- a/tests/run-with-compiler/i3823-b.scala +++ b/tests/run-with-compiler/i3823-b.scala @@ -3,7 +3,7 @@ import scala.quoted._ object Test { def main(args: Array[String]): Unit = { def f[T](x: Expr[T])(implicit t: Type[T]) = '{ - val z: t.unary_~ = ~x + val z: $t = $x } println(f('{2})(Type.IntTag).show) } diff --git a/tests/run-with-compiler/i3823-c.scala b/tests/run-with-compiler/i3823-c.scala index df1009cd5857..bccae95b5278 100644 --- a/tests/run-with-compiler/i3823-c.scala +++ b/tests/run-with-compiler/i3823-c.scala @@ -3,7 +3,7 @@ import scala.quoted._ object Test { def main(args: Array[String]): Unit = { def f[T](x: Expr[T])(implicit t: Type[T]) = '{ - val z = ~x + val z = $x } println(f('{2})(Type.IntTag).show) } diff --git a/tests/run-with-compiler/i3823.scala b/tests/run-with-compiler/i3823.scala index 111de3c0e232..ad43cc70e6d5 100644 --- a/tests/run-with-compiler/i3823.scala +++ b/tests/run-with-compiler/i3823.scala @@ -3,7 +3,7 @@ import scala.quoted._ object Test { def main(args: Array[String]): Unit = { def f[T: Type](x: Expr[T])(t: Type[T]) = '{ - val z: t.unary_~ = ~x + val z: $t = $x } println(f('{2})('[Int]).show) } diff --git a/tests/run-with-compiler/i3847.scala b/tests/run-with-compiler/i3847.scala index d0420824e4a8..02be34330a9b 100644 --- a/tests/run-with-compiler/i3847.scala +++ b/tests/run-with-compiler/i3847.scala @@ -6,7 +6,7 @@ object Arrays { implicit def ArrayIsLiftable[T: Liftable](implicit t: Type[T], ct: Expr[ClassTag[T]]): Liftable[Array[T]] = { new Liftable[Array[T]] { def toExpr(arr: Array[T]): Expr[Array[T]] = '{ - new Array[$t](${arr.length.toExpr})(~ct) + new Array[$t](${arr.length.toExpr})($ct) // TODO add elements } } diff --git a/tests/run-with-compiler/i3947.scala b/tests/run-with-compiler/i3947.scala index e498cfe9f618..45d3971f90b8 100644 --- a/tests/run-with-compiler/i3947.scala +++ b/tests/run-with-compiler/i3947.scala @@ -9,7 +9,7 @@ object Test { def test[T: Type](clazz: java.lang.Class[T]): Unit = { val lclazz = clazz.toExpr - val name = '{ (~lclazz).getCanonicalName } + val name = '{ ($lclazz).getCanonicalName } println() println(name.show) println(name.run) diff --git a/tests/run-with-compiler/i3947b.scala b/tests/run-with-compiler/i3947b.scala index ab30d1fd9847..4b4460daf5d4 100644 --- a/tests/run-with-compiler/i3947b.scala +++ b/tests/run-with-compiler/i3947b.scala @@ -9,7 +9,7 @@ object Test { def test[T: Type](clazz: java.lang.Class[T]): Unit = { val lclazz = clazz.toExpr - val name = '{ (~lclazz).getCanonicalName } + val name = '{ ($lclazz).getCanonicalName } println() println(name.show) println(name.run) diff --git a/tests/run-with-compiler/i3947b2.scala b/tests/run-with-compiler/i3947b2.scala index aad8ab6d7dc2..8007f5607f9f 100644 --- a/tests/run-with-compiler/i3947b2.scala +++ b/tests/run-with-compiler/i3947b2.scala @@ -9,7 +9,7 @@ object Test { def test[T: Type](clazz: java.lang.Class[T]): Unit = { val lclazz = clazz.toExpr - val name = '{ (~lclazz).getCanonicalName } + val name = '{ ($lclazz).getCanonicalName } println() println(name.show) println(name.run) diff --git a/tests/run-with-compiler/i3947b3.scala b/tests/run-with-compiler/i3947b3.scala index 0d34734a7aa0..4ba6643491d3 100644 --- a/tests/run-with-compiler/i3947b3.scala +++ b/tests/run-with-compiler/i3947b3.scala @@ -9,7 +9,7 @@ object Test { def test[T: Type](clazz: java.lang.Class[T]): Unit = { val lclazz = clazz.toExpr - val name = '{ (~lclazz).getCanonicalName } + val name = '{ ($lclazz).getCanonicalName } println() println(name.show) println(name.run) diff --git a/tests/run-with-compiler/i3947c.scala b/tests/run-with-compiler/i3947c.scala index 4bb6a829605f..1fed62b8832f 100644 --- a/tests/run-with-compiler/i3947c.scala +++ b/tests/run-with-compiler/i3947c.scala @@ -9,7 +9,7 @@ object Test { def test[T: Type](clazz: java.lang.Class[T]): Unit = { val lclazz = clazz.toExpr - val name = '{ (~lclazz).getCanonicalName } + val name = '{ ($lclazz).getCanonicalName } println() println(name.show) println(name.run) diff --git a/tests/run-with-compiler/i3947d.scala b/tests/run-with-compiler/i3947d.scala index 33466ceccede..fa73e2bd217e 100644 --- a/tests/run-with-compiler/i3947d.scala +++ b/tests/run-with-compiler/i3947d.scala @@ -9,7 +9,7 @@ object Test { def test[T: Type](clazz: java.lang.Class[T]): Unit = { val lclazz = clazz.toExpr - val name = '{ (~lclazz).getCanonicalName } + val name = '{ ($lclazz).getCanonicalName } println() println(name.show) println(name.run) diff --git a/tests/run-with-compiler/i3947d2.scala b/tests/run-with-compiler/i3947d2.scala index cac86cfa42f9..f86a52ad9a37 100644 --- a/tests/run-with-compiler/i3947d2.scala +++ b/tests/run-with-compiler/i3947d2.scala @@ -9,7 +9,7 @@ object Test { def test[T: Type](clazz: java.lang.Class[T]): Unit = { val lclazz = clazz.toExpr - val name = '{ (~lclazz).getCanonicalName } + val name = '{ ($lclazz).getCanonicalName } println() println(name.show) println(name.run) diff --git a/tests/run-with-compiler/i3947e.scala b/tests/run-with-compiler/i3947e.scala index 1a84025cbb32..25f41fe0789a 100644 --- a/tests/run-with-compiler/i3947e.scala +++ b/tests/run-with-compiler/i3947e.scala @@ -9,7 +9,7 @@ object Test { def test[T: Type](clazz: java.lang.Class[T]): Unit = { val lclazz = clazz.toExpr - val name = '{ (~lclazz).getCanonicalName } + val name = '{ ($lclazz).getCanonicalName } println() println(name.show) println(name.run) diff --git a/tests/run-with-compiler/i3947f.scala b/tests/run-with-compiler/i3947f.scala index 67b83d7edcfa..6d1c6239759e 100644 --- a/tests/run-with-compiler/i3947f.scala +++ b/tests/run-with-compiler/i3947f.scala @@ -9,7 +9,7 @@ object Test { def test[T: Type](clazz: java.lang.Class[T]): Unit = { val lclazz = clazz.toExpr - val name = '{ (~lclazz).getCanonicalName } + val name = '{ ($lclazz).getCanonicalName } println() println(name.show) println(name.run) diff --git a/tests/run-with-compiler/i3947g.scala b/tests/run-with-compiler/i3947g.scala index 9132a459d1c3..0d1fa78978f2 100644 --- a/tests/run-with-compiler/i3947g.scala +++ b/tests/run-with-compiler/i3947g.scala @@ -9,7 +9,7 @@ object Test { def test[T: Type](clazz: java.lang.Class[T]): Unit = { val lclazz = clazz.toExpr - val name = '{ (~lclazz).getCanonicalName } + val name = '{ ($lclazz).getCanonicalName } println() println(name.show) println(name.run) diff --git a/tests/run-with-compiler/i3947i.scala b/tests/run-with-compiler/i3947i.scala index ae07aaebfed9..3c0918392cd1 100644 --- a/tests/run-with-compiler/i3947i.scala +++ b/tests/run-with-compiler/i3947i.scala @@ -9,7 +9,7 @@ object Test { def test[T: Type](clazz: java.lang.Class[T]): Unit = { val lclazz = clazz.toExpr - val name = '{ (~lclazz).getCanonicalName } + val name = '{ ($lclazz).getCanonicalName } println() println(name.show) println(name.run) diff --git a/tests/run-with-compiler/i3947j.scala b/tests/run-with-compiler/i3947j.scala index 2e4045ac5a6f..c9c2b1dcf6d4 100644 --- a/tests/run-with-compiler/i3947j.scala +++ b/tests/run-with-compiler/i3947j.scala @@ -9,7 +9,7 @@ object Test { def test[T: Type](clazz: java.lang.Class[T]): Unit = { val lclazz = clazz.toExpr - val name = '{ (~lclazz).getCanonicalName } + val name = '{ ($lclazz).getCanonicalName } println() println(name.show) println(name.run) diff --git a/tests/run-with-compiler/i4044a.scala b/tests/run-with-compiler/i4044a.scala index b89f7456d632..e8ff3d67979e 100644 --- a/tests/run-with-compiler/i4044a.scala +++ b/tests/run-with-compiler/i4044a.scala @@ -4,7 +4,7 @@ import scala.quoted.Toolbox.Default._ class Foo { def foo: Unit = { val e: Expr[Int] = '{3} - val q = '{ ~( '{ ~e } ) } + val q = '{ ${ '{ $e } } } println(q.show) } } diff --git a/tests/run-with-compiler/i4044b.scala b/tests/run-with-compiler/i4044b.scala index bf5955838acd..52de2ab072b4 100644 --- a/tests/run-with-compiler/i4044b.scala +++ b/tests/run-with-compiler/i4044b.scala @@ -9,20 +9,20 @@ sealed abstract class VarRef[T] { object VarRef { def apply[T: Type, U: Type](init: Expr[T])(body: VarRef[T] => Expr[U]): Expr[U] = '{ - var x = ~init - ~body( + var x = $init + ${body( new VarRef { - def update(e: Expr[T]): Expr[Unit] = '{ x = ~e } + def update(e: Expr[T]): Expr[Unit] = '{ x = $e } def expr: Expr[T] = '{x} } - ) + )} } } object Test { def main(args: Array[String]): Unit = { - val q = VarRef('{4})(varRef => '{ ~varRef.update('{3}); ~varRef.expr }) + val q = VarRef('{4})(varRef => '{ ${varRef.update('{3})}; ${varRef.expr} }) println(q.show) } } diff --git a/tests/run-with-compiler/i4044c.scala b/tests/run-with-compiler/i4044c.scala index 0071624d7ece..5a38da369e6a 100644 --- a/tests/run-with-compiler/i4044c.scala +++ b/tests/run-with-compiler/i4044c.scala @@ -3,7 +3,7 @@ import scala.quoted.Toolbox.Default._ class Foo { def foo: Unit = { - val q = '{ ~( '{ ~( '{ 5 } ) } ) } + val q = '{ ${ '{ ${ '{ 5 } } } } } println(q.show) } } diff --git a/tests/run-with-compiler/i4044d.scala b/tests/run-with-compiler/i4044d.scala index 74f425456d66..05e177a80f89 100644 --- a/tests/run-with-compiler/i4044d.scala +++ b/tests/run-with-compiler/i4044d.scala @@ -9,7 +9,7 @@ class Foo { ${ println("evaluating inner quote") '{ - b + ~a + b + $a } } } diff --git a/tests/run-with-compiler/i4044f.scala b/tests/run-with-compiler/i4044f.scala index 26c0abf5c88b..2b63f6d2bd12 100644 --- a/tests/run-with-compiler/i4044f.scala +++ b/tests/run-with-compiler/i4044f.scala @@ -5,13 +5,13 @@ class Foo { def foo: Unit = { val e: Expr[Int] = '{3} val f: Expr[Int] = '{5} - def foo(x: Expr[Int], y: Expr[Int]): Expr[Int] = '{ ~x + ~y } + def foo(x: Expr[Int], y: Expr[Int]): Expr[Int] = '{ $x + $y } val q = '{ - val e1 = ~e - val f1 = ~f + val e1 = $e + val f1 = $f ${ val u = '{2} - foo('{e1 + ~u}, '{f1}) + foo('{e1 + $u}, '{f1}) } } println(q.show) diff --git a/tests/run-with-compiler/i4591.scala b/tests/run-with-compiler/i4591.scala index 079a9da26243..6ae5ac944dac 100644 --- a/tests/run-with-compiler/i4591.scala +++ b/tests/run-with-compiler/i4591.scala @@ -4,7 +4,7 @@ import scala.quoted._ object Test { def foo[T: Type](init: Expr[T]): Expr[Unit] = '{ - var x = ~init + var x = $init println(x) } diff --git a/tests/run-with-compiler/i5144b.scala b/tests/run-with-compiler/i5144b.scala index 716bcf49ac75..63d2ff6958a7 100644 --- a/tests/run-with-compiler/i5144b.scala +++ b/tests/run-with-compiler/i5144b.scala @@ -6,7 +6,7 @@ object Test { def eval1(ff: Expr[Int => Int]): Expr[Int] = ff('{42}) def peval1(): Expr[Unit] = '{ - def f(x: Int): Int = ~eval1('{f}) + def f(x: Int): Int = ${eval1('{f})} } def main(args: Array[String]): Unit = { diff --git a/tests/run-with-compiler/quote-ackermann-1.scala b/tests/run-with-compiler/quote-ackermann-1.scala index abb10434f648..998c045cfa14 100644 --- a/tests/run-with-compiler/quote-ackermann-1.scala +++ b/tests/run-with-compiler/quote-ackermann-1.scala @@ -15,7 +15,7 @@ object Test { def ackermann(m: Int): Expr[Int => Int] = { if (m == 0) '{ n => n + 1 } else '{ n => - def `ackermann(m-1)`(n: Int): Int = ~ackermann(m - 1)('{n}) // Expr[Int => Int] applied to Expr[Int] + def `ackermann(m-1)`(n: Int): Int = ${ackermann(m - 1)('{n})} // Expr[Int => Int] applied to Expr[Int] def `ackermann(m)`(n: Int): Int = if (n == 0) `ackermann(m-1)`(1) else `ackermann(m-1)`(`ackermann(m)`(n - 1)) `ackermann(m)`(n) diff --git a/tests/run-with-compiler/quote-fun-app-1.scala b/tests/run-with-compiler/quote-fun-app-1.scala index 02fdbaf0b9ee..26237222f630 100644 --- a/tests/run-with-compiler/quote-fun-app-1.scala +++ b/tests/run-with-compiler/quote-fun-app-1.scala @@ -10,8 +10,8 @@ object Test { println(f(43)) } - def f1: Expr[Int => Int] = '{ n => ~f2('{n}) } - def f2: Expr[Int => Int] = '{ n => ~f3('{n}) } - def f3: Expr[Int => Int] = '{ n => ~f4('{n}) } + def f1: Expr[Int => Int] = '{ n => ${f2('{n})} } + def f2: Expr[Int => Int] = '{ n => ${f3('{n})} } + def f3: Expr[Int => Int] = '{ n => ${f4('{n})} } def f4: Expr[Int => Int] = '{ n => n } } diff --git a/tests/run-with-compiler/quote-impure-by-name/quoted_1.scala b/tests/run-with-compiler/quote-impure-by-name/quoted_1.scala index da6f367e8d86..2996918546d3 100644 --- a/tests/run-with-compiler/quote-impure-by-name/quoted_1.scala +++ b/tests/run-with-compiler/quote-impure-by-name/quoted_1.scala @@ -9,7 +9,7 @@ object Index { implicit def zero[K, T]: Index[K, (K, T)] = new Index("0") - implicit inline def succ[K, H, T](implicit prev: => Index[K, T]): Index[K, (H, T)] = ~succImpl('{prev})('[K], '[H], '[T]) + implicit inline def succ[K, H, T](implicit prev: => Index[K, T]): Index[K, (H, T)] = ${ succImpl('{prev})('[K], '[H], '[T]) } def succImpl[K, H, T](prev: Expr[Index[K, T]])(implicit k: Type[K], h: Type[H], t: Type[T]): Expr[Index[K, (H, T)]] = { val value = s"1 + {${prev.show}}" diff --git a/tests/run-with-compiler/quote-inline-function/quoted_1.scala b/tests/run-with-compiler/quote-inline-function/quoted_1.scala index 01c4b654d4f8..b9c9d29f1456 100644 --- a/tests/run-with-compiler/quote-inline-function/quoted_1.scala +++ b/tests/run-with-compiler/quote-inline-function/quoted_1.scala @@ -4,19 +4,19 @@ import scala.quoted.Toolbox.Default._ object Macros { - inline def foreach1(start: Int, end: Int, f: Int => Unit): String = ~impl('{start}, '{end}, '{f}) - inline def foreach2(start: Int, end: Int, f: => Int => Unit): String = ~impl('{start}, '{end}, '{f}) + inline def foreach1(start: Int, end: Int, f: Int => Unit): String = ${impl('{start}, '{end}, '{f})} + inline def foreach2(start: Int, end: Int, f: => Int => Unit): String = ${impl('{start}, '{end}, '{f})} def impl(start: Expr[Int], end: Expr[Int], f: Expr[Int => Unit]): Expr[String] = { val res = '{ - var i = ~start - val j = ~end + var i = $start + val j = $end while (i < j) { - ~f.apply('{i}) + ${f.apply('{i})} i += 1 } do { - ~f.apply('{i}) + ${f.apply('{i})} i += 1 } while (i < j) } diff --git a/tests/run-with-compiler/quote-lambda.scala b/tests/run-with-compiler/quote-lambda.scala index fcae39d63d68..694d69238e98 100644 --- a/tests/run-with-compiler/quote-lambda.scala +++ b/tests/run-with-compiler/quote-lambda.scala @@ -2,6 +2,6 @@ import scala.quoted._ object Test { def main(args: Array[String]): Unit = { - '{ (x: Int) => ~('{x}) } + '{ (x: Int) => ${'{x}} } } } diff --git a/tests/run-with-compiler/quote-lib.scala b/tests/run-with-compiler/quote-lib.scala index 2c7a35b00f6c..133102603bc5 100644 --- a/tests/run-with-compiler/quote-lib.scala +++ b/tests/run-with-compiler/quote-lib.scala @@ -15,9 +15,9 @@ object Test { val liftedUnit: Expr[Unit] = '{} - letVal('{1})(a => '{ ~a + 1 }).show - letLazyVal('{1})(a => '{ ~a + 1 }).show - letDef('{1})(a => '{ ~a + 1 }).show + letVal('{1})(a => '{ $a + 1 }).show + letLazyVal('{1})(a => '{ $a + 1 }).show + letDef('{1})(a => '{ $a + 1 }).show liftedWhile('{true})('{ println(1) }).show liftedDoWhile('{ println(1) })('{true}).show diff --git a/tests/run-with-compiler/quote-nested-2.scala b/tests/run-with-compiler/quote-nested-2.scala index d5e98e708727..eb141e0025e5 100644 --- a/tests/run-with-compiler/quote-nested-2.scala +++ b/tests/run-with-compiler/quote-nested-2.scala @@ -5,7 +5,7 @@ object Test { def main(args: Array[String]): Unit = { val q = '{ val a = '{4} - '{~a} + '{${a}} } println(q.show) diff --git a/tests/run-with-compiler/quote-nested-3.scala b/tests/run-with-compiler/quote-nested-3.scala index e745d3b16ef5..d6139c4ba53c 100644 --- a/tests/run-with-compiler/quote-nested-3.scala +++ b/tests/run-with-compiler/quote-nested-3.scala @@ -9,7 +9,7 @@ object Test { val x = "foo" ${ val y = '{x} - '{ val z: T = ~y } + '{ val z: T = $y } } x } diff --git a/tests/run-with-compiler/quote-nested-5.scala b/tests/run-with-compiler/quote-nested-5.scala index 3ab1defddf42..22effdaa9026 100644 --- a/tests/run-with-compiler/quote-nested-5.scala +++ b/tests/run-with-compiler/quote-nested-5.scala @@ -5,9 +5,9 @@ object Test { def main(args: Array[String]): Unit = { val q = '{ val a = '{4} - ~('{ - '{~a} - }) + ${'{ + '{${a}} + }} } diff --git a/tests/run-with-compiler/quote-owners.scala b/tests/run-with-compiler/quote-owners.scala index 3c8496604694..093480065dbb 100644 --- a/tests/run-with-compiler/quote-owners.scala +++ b/tests/run-with-compiler/quote-owners.scala @@ -12,7 +12,7 @@ object Test { def f: Expr[Int] = '{ def ff: Int = { - ~g + $g } ff } diff --git a/tests/run-with-compiler/quote-run-2.scala b/tests/run-with-compiler/quote-run-2.scala index 8dac1fbfac17..145ac068cc04 100644 --- a/tests/run-with-compiler/quote-run-2.scala +++ b/tests/run-with-compiler/quote-run-2.scala @@ -10,8 +10,8 @@ object Test { def powerCode(n: Int, x: Expr[Double]): Expr[Double] = if (n == 0) '{1.0} else if (n == 1) x - else if (n % 2 == 0) '{ { val y = ~x * ~x; ~powerCode(n / 2, '{y}) } } - else '{ ~x * ~powerCode(n - 1, x) } + else if (n % 2 == 0) '{ { val y = $x * $x; ${powerCode(n / 2, '{y})} } } + else '{ $x * ${powerCode(n - 1, x)} } println(powerCode(0, '{5}).show) println(powerCode(1, '{5}).show) diff --git a/tests/run-with-compiler/quote-show-blocks.scala b/tests/run-with-compiler/quote-show-blocks.scala index 3db9dffbb471..0c551c29a24e 100644 --- a/tests/run-with-compiler/quote-show-blocks.scala +++ b/tests/run-with-compiler/quote-show-blocks.scala @@ -6,14 +6,14 @@ object Test { def a(n: Int, x: Expr[Unit]): Expr[Unit] = if (n == 0) x - else a(n - 1, '{ println(${n.toExpr}); ~x }) + else a(n - 1, '{ println(${n.toExpr}); $x }) println(a(5, '{}).show) def b(n: Int, x: Expr[Unit]): Expr[Unit] = if (n == 0) x - else b(n - 1, '{ ~x; println(~n.toExpr) }) + else b(n - 1, '{ $x; println(${n.toExpr}) }) println(b(5, '{}).show) } diff --git a/tests/run-with-compiler/quote-two-captured-ref.scala b/tests/run-with-compiler/quote-two-captured-ref.scala index aea5a10a2c5b..1f4687489a2c 100644 --- a/tests/run-with-compiler/quote-two-captured-ref.scala +++ b/tests/run-with-compiler/quote-two-captured-ref.scala @@ -10,7 +10,7 @@ object Test { println(1) val a = '{x} val b = '{x} - '{ ~a + ~b } + '{ $a + $b } }) } diff --git a/tests/run-with-compiler/quote-var.scala b/tests/run-with-compiler/quote-var.scala index f882567d63aa..88a1f13386e9 100644 --- a/tests/run-with-compiler/quote-var.scala +++ b/tests/run-with-compiler/quote-var.scala @@ -9,21 +9,23 @@ object Test { object Var { def apply(init: Expr[String])(body: Var => Expr[String]): Expr[String] = '{ - var x = ~init - ~body( - new Var { - def get: Expr[String] = '{x} - def update(e: Expr[String]): Expr[Unit] = '{ x = ~e } - } - ) + var x = $init + ${ + body( + new Var { + def get: Expr[String] = '{x} + def update(e: Expr[String]): Expr[Unit] = '{ x = $e } + } + ) + } } } def test1(): Expr[String] = Var('{"abc"}) { x => '{ - ~x.update('{"xyz"}) - ~x.get + ${ x.update('{"xyz"}) } + ${ x.get } } } diff --git a/tests/run-with-compiler/shonan-hmm/Ring.scala b/tests/run-with-compiler/shonan-hmm/Ring.scala index 9c14b0271375..3763017d8424 100644 --- a/tests/run-with-compiler/shonan-hmm/Ring.scala +++ b/tests/run-with-compiler/shonan-hmm/Ring.scala @@ -27,9 +27,9 @@ object RingInt extends Ring[Int] { object RingIntExpr extends Ring[Expr[Int]] { val zero = '{0} val one = '{1} - val add = (x, y) => '{~x + ~y} - val sub = (x, y) => '{~x - ~y} - val mul = (x, y) => '{~x * ~y} + val add = (x, y) => '{$x + $y} + val sub = (x, y) => '{$x - $y} + val mul = (x, y) => '{$x * $y} override def toString(): String = "RingIntExpr" } diff --git a/tests/run-with-compiler/shonan-hmm/UnrolledExpr.scala b/tests/run-with-compiler/shonan-hmm/UnrolledExpr.scala index 179bd50d96fb..56ab8a676740 100644 --- a/tests/run-with-compiler/shonan-hmm/UnrolledExpr.scala +++ b/tests/run-with-compiler/shonan-hmm/UnrolledExpr.scala @@ -10,7 +10,7 @@ object UnrolledExpr { // TODO support blocks in the compiler to avoid creating trees of blocks? def block[T: Type](stats: Iterable[Expr[_]], expr: Expr[T]): Expr[T] = { def rec(stats: List[Expr[_]]): Expr[T] = stats match { - case x :: xs => '{ ~x; ~rec(xs) } + case x :: xs => '{ $x; ${rec(xs)} } case Nil => expr } rec(stats.toList) diff --git a/tests/run-with-compiler/shonan-hmm/VecOp.scala b/tests/run-with-compiler/shonan-hmm/VecOp.scala index c57ef2ad632a..7f5f9719f3a3 100644 --- a/tests/run-with-compiler/shonan-hmm/VecOp.scala +++ b/tests/run-with-compiler/shonan-hmm/VecOp.scala @@ -15,8 +15,8 @@ class VecSta extends VecOp[Int, Unit] { class VecDyn extends VecOp[Expr[Int], Expr[Unit]] { def iter: Vec[Expr[Int], Expr[Unit]] => Expr[Unit] = arr => '{ var i = 0 - while (i < ~arr.size) { - ~arr('{i}) + while (i < ${arr.size}) { + ${arr('{i})} i += 1 } } diff --git a/tests/run-with-compiler/shonan-hmm/VecROp.scala b/tests/run-with-compiler/shonan-hmm/VecROp.scala index 2d0be63a9684..acfea459dff0 100644 --- a/tests/run-with-compiler/shonan-hmm/VecROp.scala +++ b/tests/run-with-compiler/shonan-hmm/VecROp.scala @@ -19,9 +19,9 @@ class StaticVecR[T](r: Ring[T]) extends VecSta with VecROp[Int, T, Unit] { class VecRDyn[T: Type] extends VecDyn with VecROp[Expr[Int], Expr[T], Expr[Unit]] { def reduce: ((Expr[T], Expr[T]) => Expr[T], Expr[T], Vec[Expr[Int], Expr[T]]) => Expr[T] = { (plus, zero, vec) => '{ - var sum = ~zero + var sum = $zero var i = 0 - while (i < ~vec.size) { + while (i < ${vec.size}) { sum = ${ plus('{sum}, vec('{i})) } i += 1 } @@ -34,11 +34,11 @@ class VecRDyn[T: Type] extends VecDyn with VecROp[Expr[Int], Expr[T], Expr[Unit] class VecRStaDim[T: Type](r: Ring[T]) extends VecROp[Int, T, Expr[Unit]] { val M = new StaticVecR[T](r) def reduce: ((T, T) => T, T, Vec[Int, T]) => T = M.reduce - val seq: (Expr[Unit], Expr[Unit]) => Expr[Unit] = (e1, e2) => '{ ~e1; ~e2 } + val seq: (Expr[Unit], Expr[Unit]) => Expr[Unit] = (e1, e2) => '{ $e1; $e2 } // val iter: (arr: Vec[]) = reduce seq .<()>. arr def iter: Vec[Int, Expr[Unit]] => Expr[Unit] = arr => { def loop(i: Int, acc: Expr[Unit]): Expr[Unit] = - if (i < arr.size) loop(i + 1, '{ ~acc; ~arr.get(i) }) + if (i < arr.size) loop(i + 1, '{ $acc; ${arr.get(i)} }) else acc loop(0, '{}) } @@ -58,7 +58,7 @@ class VecRStaDyn[T : Type : Liftable](r: Ring[PV[T]]) extends VecROp[PV[Int], PV arr.size match { case Sta(n) => def loop(i: Int, acc: Expr[Unit]): Expr[Unit] = - if (i < n) loop(i + 1, '{ ~acc; ~arr.get(Sta(i)) }) + if (i < n) loop(i + 1, '{ $acc; ${arr.get(Sta(i))} }) else acc loop(0, '{}) case Dyn(n) => diff --git a/tests/run-with-compiler/tasty-extractors-constants-2/quoted_1.scala b/tests/run-with-compiler/tasty-extractors-constants-2/quoted_1.scala index bbc1e7fbfbeb..6f92612b3674 100644 --- a/tests/run-with-compiler/tasty-extractors-constants-2/quoted_1.scala +++ b/tests/run-with-compiler/tasty-extractors-constants-2/quoted_1.scala @@ -6,7 +6,7 @@ import scala.tasty.util._ object Macros { - inline def testMacro: Unit = ~impl + inline def testMacro: Unit = ${impl} def impl(implicit reflect: Reflection): Expr[Unit] = { // 2 is a lifted constant @@ -49,15 +49,15 @@ object Macros { val Constant = new ConstantExtractor(reflect) n match { case Constant(n1) => powerCode(n1, x) - case _ => '{ dynamicPower(~n, ~x) } + case _ => '{ dynamicPower($n, $x) } } } def powerCode(n: Int, x: Expr[Double]): Expr[Double] = if (n == 0) '{1.0} else if (n == 1) x - else if (n % 2 == 0) '{ { val y = ~x * ~x; ~powerCode(n / 2, '{y}) } } - else '{ ~x * ~powerCode(n - 1, x) } + else if (n % 2 == 0) '{ { val y = $x * $x; ${powerCode(n / 2, '{y})} } } + else '{ $x * ${powerCode(n - 1, x)} } def dynamicPower(n: Int, x: Double): Double = if (n == 0) 1.0 diff --git a/tests/run-with-compiler/tasty-unsafe-let/quoted_1.scala b/tests/run-with-compiler/tasty-unsafe-let/quoted_1.scala index 337ad2059f45..b6edf050e4df 100644 --- a/tests/run-with-compiler/tasty-unsafe-let/quoted_1.scala +++ b/tests/run-with-compiler/tasty-unsafe-let/quoted_1.scala @@ -5,7 +5,7 @@ import scala.tasty._ object Macros { inline def let[T](rhs: T)(body: => T => Unit): Unit = - ~impl('{rhs}, '{body}) + ${ impl('{rhs}, '{body}) } private def impl[T](rhs: Expr[T], body: Expr[T => Unit])(implicit reflect: Reflection): Expr[Unit] = { import reflect._ diff --git a/tests/run/f-interpolation-1/FQuote_1.scala b/tests/run/f-interpolation-1/FQuote_1.scala index 3f639a91f1fc..4df72b0e27d0 100644 --- a/tests/run/f-interpolation-1/FQuote_1.scala +++ b/tests/run/f-interpolation-1/FQuote_1.scala @@ -6,7 +6,7 @@ import scala.language.implicitConversions object FQuote { implicit class SCOps(ctx: StringContext) { - inline def ff(args: => Any*): String = ~impl('{this}, '{args}) + inline def ff(args: => Any*): String = ${impl('{this}, '{args})} } /*private*/ def impl(receiver: Expr[SCOps], args: Expr[Seq[Any]])(implicit reflect: Reflection): Expr[String] = { @@ -16,7 +16,7 @@ object FQuote { case x :: xs => val head = x.seal[Any] val tail = liftListOfAny(xs) - '{ ~head :: ~tail } + '{ $head :: $tail } case Nil => '{Nil} } @@ -53,6 +53,6 @@ object FQuote { } val string = parts.mkString("") - '{ new collection.immutable.StringOps(${string.toExpr}).format(~args: _*) } + '{ new collection.immutable.StringOps(${string.toExpr}).format($args: _*) } } } diff --git a/tests/run/gestalt-optional-staging/Macro_1.scala b/tests/run/gestalt-optional-staging/Macro_1.scala index 400dc2455766..5ff4b5aa277b 100644 --- a/tests/run/gestalt-optional-staging/Macro_1.scala +++ b/tests/run/gestalt-optional-staging/Macro_1.scala @@ -7,9 +7,9 @@ final class Optional[+A >: Null](val value: A) extends AnyVal { def get: A = value def isEmpty = value == null - inline def getOrElse[B >: A](alt: => B): B = ~Optional.getOrElseImpl('{this}, '{alt}) + inline def getOrElse[B >: A](alt: => B): B = ${ Optional.getOrElseImpl('{this}, '{alt}) } - inline def map[B >: Null](f: A => B): Optional[B] = ~Optional.mapImpl('{this}, '{f}) + inline def map[B >: Null](f: A => B): Optional[B] = ${ Optional.mapImpl('{this}, '{f}) } override def toString = if (isEmpty) "" else s"$value" } diff --git a/tests/run/i4431/quoted_1.scala b/tests/run/i4431/quoted_1.scala index e433ec5677a6..245c60680cf7 100644 --- a/tests/run/i4431/quoted_1.scala +++ b/tests/run/i4431/quoted_1.scala @@ -1,5 +1,5 @@ import scala.quoted._ object Macros { - inline def h(f: => Int => String): String = ~{'{f(42)}} + inline def h(f: => Int => String): String = ${'{f(42)}} } diff --git a/tests/run/i4455/Macro_1.scala b/tests/run/i4455/Macro_1.scala index ec78c82b6d85..60950ea035ed 100644 --- a/tests/run/i4455/Macro_1.scala +++ b/tests/run/i4455/Macro_1.scala @@ -1,8 +1,8 @@ import scala.quoted._ object Macros { - inline def foo(inline i: Int): Int = ~bar('{i}) + inline def foo(inline i: Int): Int = ${ bar('{i}) } - inline def foo2(inline i: Int): Int = ~bar('{i + 1}) + inline def foo2(inline i: Int): Int = ${ bar('{i + 1}) } def bar(x: Expr[Int]): Expr[Int] = x } diff --git a/tests/run/i4515/Macro_1.scala b/tests/run/i4515/Macro_1.scala index 905ca5279721..6d5524e120e6 100644 --- a/tests/run/i4515/Macro_1.scala +++ b/tests/run/i4515/Macro_1.scala @@ -1,5 +1,5 @@ object Macro { - inline def foo[X](x: X): Unit = ~fooImpl('{x}) + inline def foo[X](x: X): Unit = ${fooImpl('{x})} def fooImpl[X: quoted.Type](x: quoted.Expr[X]): quoted.Expr[Unit] = '{} } diff --git a/tests/run/i4515b/Macro_1.scala b/tests/run/i4515b/Macro_1.scala index a3e8f0be055f..ed345bd69bb5 100644 --- a/tests/run/i4515b/Macro_1.scala +++ b/tests/run/i4515b/Macro_1.scala @@ -1,6 +1,6 @@ import scala.tasty.Reflection object Macro { - inline def foo: Unit = ~fooImpl + inline def foo: Unit = ${ fooImpl } def fooImpl(implicit reflect: Reflection): quoted.Expr[Unit] = '{} } diff --git a/tests/run/i4734/Macro_1.scala b/tests/run/i4734/Macro_1.scala index eadea10600d4..c74ac861444b 100644 --- a/tests/run/i4734/Macro_1.scala +++ b/tests/run/i4734/Macro_1.scala @@ -3,18 +3,18 @@ import scala.quoted._ object Macros { inline def unrolledForeach(seq: IndexedSeq[Int], f: => Int => Unit, inline unrollSize: Int): Unit = // or f: Int => Unit - ~unrolledForeachImpl('{seq}, '{f}, unrollSize) + ${ unrolledForeachImpl('{seq}, '{f}, unrollSize) } def unrolledForeachImpl(seq: Expr[IndexedSeq[Int]], f: Expr[Int => Unit], unrollSize: Int): Expr[Unit] = '{ - val size = (~seq).length + val size = ($seq).length assert(size % (${unrollSize.toExpr}) == 0) // for simplicity of the implementation var i = 0 while (i < size) { ${ for (j <- new UnrolledRange(0, unrollSize)) '{ val index = i + ${j.toExpr} - val element = (~seq)(index) - ~f('{element}) // or `(~f)(element)` if `f` should not be inlined + val element = ($seq)(index) + ${ f('{element}) } // or `($f)(element)` if `f` should not be inlined } } i += ${unrollSize.toExpr} @@ -25,7 +25,7 @@ object Macros { class UnrolledRange(start: Int, end: Int) { def foreach(f: Int => Expr[Unit]): Expr[Unit] = { @tailrec def loop(i: Int, acc: Expr[Unit]): Expr[Unit] = - if (i >= 0) loop(i - 1, '{ ~f(i); ~acc }) + if (i >= 0) loop(i - 1, '{ ${f(i)}; $acc }) else acc loop(end - 1, '{}) } diff --git a/tests/run/i4735/Macro_1.scala b/tests/run/i4735/Macro_1.scala index 9b87f08c3853..189f02331180 100644 --- a/tests/run/i4735/Macro_1.scala +++ b/tests/run/i4735/Macro_1.scala @@ -4,10 +4,10 @@ import scala.quoted._ object Macro { inline def unrolledForeach(inline unrollSize: Int, seq: Array[Int], f: => Int => Unit): Unit = // or f: Int => Unit - ~unrolledForeachImpl(unrollSize, '{seq}, '{f}) + ${ unrolledForeachImpl(unrollSize, '{seq}, '{f}) } private def unrolledForeachImpl(unrollSize: Int, seq: Expr[Array[Int]], f: Expr[Int => Unit]): Expr[Unit] = '{ - val size = (~seq).length + val size = ($seq).length assert(size % (${unrollSize.toExpr}) == 0) // for simplicity of the implementation var i = 0 while (i < size) { @@ -15,7 +15,7 @@ object Macro { ${ for (j <- new UnrolledRange(0, unrollSize)) '{ val element = ($seq)(i + ${j.toExpr}) - ~f('{element}) // or `(~f)(element)` if `f` should not be inlined + ${f('{element})} // or `($f)(element)` if `f` should not be inlined } } i += ${unrollSize.toExpr} @@ -26,7 +26,7 @@ object Macro { private class UnrolledRange(start: Int, end: Int) { def foreach(f: Int => Expr[Unit]): Expr[Unit] = { @tailrec def loop(i: Int, acc: Expr[Unit]): Expr[Unit] = - if (i >= 0) loop(i - 1, '{ ~f(i); ~acc }) + if (i >= 0) loop(i - 1, '{ ${f(i)}; $acc }) else acc loop(end - 1, '{}) } diff --git a/tests/run/i4803/App_2.scala b/tests/run/i4803/App_2.scala index a2526b7158b8..dbe18eb46103 100644 --- a/tests/run/i4803/App_2.scala +++ b/tests/run/i4803/App_2.scala @@ -1,6 +1,6 @@ class Num2(x: Double) { - inline def power(inline n: Long) = ~PowerMacro.powerCode('{x}, n) + inline def power(inline n: Long) = ${ PowerMacro.powerCode('{x}, n) } } object Test { diff --git a/tests/run/i4803/Macro_1.scala b/tests/run/i4803/Macro_1.scala index 93b5f260ffba..c79900f74868 100644 --- a/tests/run/i4803/Macro_1.scala +++ b/tests/run/i4803/Macro_1.scala @@ -3,10 +3,10 @@ import scala.quoted._ object PowerMacro { def powerCode(x: Expr[Double], n: Long): Expr[Double] = if (n == 0) '{1.0} - else if (n % 2 == 0) '{ val y = ~x * ~x; ~powerCode('{y}, n / 2) } - else '{ ~x * ~powerCode(x, n - 1) } + else if (n % 2 == 0) '{ val y = $x * $x; ${ powerCode('{y}, n / 2) } } + else '{ $x * ${ powerCode(x, n - 1) } } } class Num(x: Double) { - inline def power(inline n: Long) = ~PowerMacro.powerCode('{x}, n) + inline def power(inline n: Long) = ${ PowerMacro.powerCode('{x}, n) } } diff --git a/tests/run/i4803b/App_2.scala b/tests/run/i4803b/App_2.scala index 478a7183ecf5..955341ee4292 100644 --- a/tests/run/i4803b/App_2.scala +++ b/tests/run/i4803b/App_2.scala @@ -2,7 +2,7 @@ class Nums { class Num(x: Double) { - inline def power(inline n: Long) = ~PowerMacro.powerCode('{x}, n) + inline def power(inline n: Long) = ${ PowerMacro.powerCode('{x}, n) } } } diff --git a/tests/run/i4803b/Macro_1.scala b/tests/run/i4803b/Macro_1.scala index b0690dac9eac..cf3f6add0252 100644 --- a/tests/run/i4803b/Macro_1.scala +++ b/tests/run/i4803b/Macro_1.scala @@ -3,6 +3,6 @@ import scala.quoted._ object PowerMacro { def powerCode(x: Expr[Double], n: Long): Expr[Double] = if (n == 0) '{1.0} - else if (n % 2 == 0) '{ val y = ~x * ~x; ~powerCode('{y}, n / 2) } - else '{ ~x * ~powerCode(x, n - 1) } + else if (n % 2 == 0) '{ val y = $x * $x; ${ powerCode('{y}, n / 2) } } + else '{ $x * ${ powerCode(x, n - 1) } } } diff --git a/tests/run/i4803c/App_2.scala b/tests/run/i4803c/App_2.scala index 41debe518ea3..50a1cf267d70 100644 --- a/tests/run/i4803c/App_2.scala +++ b/tests/run/i4803c/App_2.scala @@ -2,7 +2,7 @@ object Test { def main(args: Array[String]): Unit = { class Num(x: Double) { - inline def power(inline n: Long) = ~PowerMacro.powerCode('{x}, n) + inline def power(inline n: Long) = ${ PowerMacro.powerCode('{x}, n) } } val n = new Num(1.5) println(n.power(0)) @@ -10,7 +10,7 @@ object Test { println(n.power(2)) println(n.power(5)) - inline def power(x: Double, inline n: Long) = ~PowerMacro.powerCode('{x}, n) + inline def power(x: Double, inline n: Long) = ${ PowerMacro.powerCode('{x}, n) } val x: Double = 1.5 diff --git a/tests/run/i4803c/Macro_1.scala b/tests/run/i4803c/Macro_1.scala index b0690dac9eac..5c146d1f2a7b 100644 --- a/tests/run/i4803c/Macro_1.scala +++ b/tests/run/i4803c/Macro_1.scala @@ -3,6 +3,6 @@ import scala.quoted._ object PowerMacro { def powerCode(x: Expr[Double], n: Long): Expr[Double] = if (n == 0) '{1.0} - else if (n % 2 == 0) '{ val y = ~x * ~x; ~powerCode('{y}, n / 2) } - else '{ ~x * ~powerCode(x, n - 1) } + else if (n % 2 == 0) '{ val y = $x * $x; ${powerCode('{y}, n / 2)} } + else '{ $x * ${powerCode(x, n - 1)} } } diff --git a/tests/run/i4803e/App_2.scala b/tests/run/i4803e/App_2.scala index 343284775631..515ee43057ad 100644 --- a/tests/run/i4803e/App_2.scala +++ b/tests/run/i4803e/App_2.scala @@ -10,5 +10,5 @@ object Test { println(power2(x3)) } - inline def power2(x: Double) = ~PowerMacro.power2('{x}) + inline def power2(x: Double) = ${PowerMacro.power2('{x})} } diff --git a/tests/run/i4803e/Macro_1.scala b/tests/run/i4803e/Macro_1.scala index f4392c41a3b1..4ccfa8c0e0f4 100644 --- a/tests/run/i4803e/Macro_1.scala +++ b/tests/run/i4803e/Macro_1.scala @@ -6,6 +6,6 @@ object PowerMacro { if (n == 0) 1.0 else if (n % 2 == 0) { val y = x * x; power(y, n / 2) } else x * power(x, n - 1) - power(~x, 2) + power($x, 2) } } diff --git a/tests/run/i4803f/App_2.scala b/tests/run/i4803f/App_2.scala index 343284775631..515ee43057ad 100644 --- a/tests/run/i4803f/App_2.scala +++ b/tests/run/i4803f/App_2.scala @@ -10,5 +10,5 @@ object Test { println(power2(x3)) } - inline def power2(x: Double) = ~PowerMacro.power2('{x}) + inline def power2(x: Double) = ${PowerMacro.power2('{x})} } diff --git a/tests/run/i4803f/Macro_1.scala b/tests/run/i4803f/Macro_1.scala index c6958091055f..e391752ae48c 100644 --- a/tests/run/i4803f/Macro_1.scala +++ b/tests/run/i4803f/Macro_1.scala @@ -3,11 +3,11 @@ import scala.quoted._ object PowerMacro { def powerCode(x: Expr[Double], n: Long): Expr[Double] = if (n == 0) '{1.0} - else if (n % 2 == 0) '{ val y = ~x * ~x; ~powerCode('{y}, n / 2) } - else '{ ~x * ~powerCode(x, n - 1) } + else if (n % 2 == 0) '{ val y = $x * $x; ${powerCode('{y}, n / 2)} } + else '{ $x * ${powerCode(x, n - 1)} } def power2(x: Expr[Double]) = '{ - inline def power(x: Double): Double = ~powerCode('{x}, 2) - power(~x) + inline def power(x: Double): Double = ${powerCode('{x}, 2)} + power($x) } } diff --git a/tests/run/i4947e/Macro_1.scala b/tests/run/i4947e/Macro_1.scala index 175a642be819..7e08adf6d076 100644 --- a/tests/run/i4947e/Macro_1.scala +++ b/tests/run/i4947e/Macro_1.scala @@ -6,6 +6,6 @@ object Macros { } def assertImpl(expr: Expr[Boolean]) = '{ printStack("assertImpl") - println(~expr) + println($expr) } } diff --git a/tests/run/i4947e/Test_2.scala b/tests/run/i4947e/Test_2.scala index f7594f2f0e0e..295b00a75ea9 100644 --- a/tests/run/i4947e/Test_2.scala +++ b/tests/run/i4947e/Test_2.scala @@ -1,6 +1,6 @@ object Test { - inline def assert2(expr: => Boolean): Unit = ~Macros.assertImpl('{expr}) + inline def assert2(expr: => Boolean): Unit = ${ Macros.assertImpl('{expr}) } def main(args: Array[String]): Unit = { val x = 1 diff --git a/tests/run/i4947f/Macro_1.scala b/tests/run/i4947f/Macro_1.scala index 97dbed912dd7..4915c43e57e2 100644 --- a/tests/run/i4947f/Macro_1.scala +++ b/tests/run/i4947f/Macro_1.scala @@ -6,9 +6,9 @@ object Macros { } def assertImpl(expr: Expr[Boolean]) = '{ printStack("assertImpl") - println(~expr) + println($expr) } - inline def assert2(expr: => Boolean): Unit = ~Macros.assertImpl('{expr}) + inline def assert2(expr: => Boolean): Unit = ${ Macros.assertImpl('{expr}) } } diff --git a/tests/run/i5119/Macro_1.scala b/tests/run/i5119/Macro_1.scala index 6041252d2f6c..d6b2728fab03 100644 --- a/tests/run/i5119/Macro_1.scala +++ b/tests/run/i5119/Macro_1.scala @@ -3,7 +3,7 @@ import scala.tasty.Reflection object Macro { class StringContextOps(sc: => StringContext) { - inline def ff(args: => Any*): String = ~Macro.impl('{sc}, '{args}) + inline def ff(args: => Any*): String = ${ Macro.impl('{sc}, '{args}) } } implicit inline def XmlQuote(sc: => StringContext): StringContextOps = new StringContextOps(sc) def impl(sc: Expr[StringContext], args: Expr[Seq[Any]])(implicit reflect: Reflection): Expr[String] = { diff --git a/tests/run/i5119b/Macro_1.scala b/tests/run/i5119b/Macro_1.scala index be398f2c457d..31dfb675a15b 100644 --- a/tests/run/i5119b/Macro_1.scala +++ b/tests/run/i5119b/Macro_1.scala @@ -3,7 +3,7 @@ import scala.tasty.Reflection object Macro { - inline def ff(arg1: Any, arg2: Any): String = ~Macro.impl('{arg1}, '{arg2}) + inline def ff(arg1: Any, arg2: Any): String = ${ Macro.impl('{arg1}, '{arg2}) } def impl(arg1: Expr[Any], arg2: Expr[Any])(implicit reflect: Reflection): Expr[String] = { import reflect._ diff --git a/tests/run/i5188a/Macro_1.scala b/tests/run/i5188a/Macro_1.scala index 77f6183df67c..7c6e2c716143 100644 --- a/tests/run/i5188a/Macro_1.scala +++ b/tests/run/i5188a/Macro_1.scala @@ -1,6 +1,6 @@ import scala.quoted._ object Lib { - inline def sum(inline args: Int*): Int = ~impl(args: _*) + inline def sum(inline args: Int*): Int = ${ impl(args: _*) } def impl(args: Int*): Expr[Int] = args.sum.toExpr } diff --git a/tests/run/i5386.check b/tests/run/i5386.check index 343e36be2164..6d4e249851c1 100644 --- a/tests/run/i5386.check +++ b/tests/run/i5386.check @@ -1,7 +1,6 @@ ! ! ! -! 1 2 ! diff --git a/tests/run/i5386.scala b/tests/run/i5386.scala index 1543fa3f6938..a1718a2dc0f3 100644 --- a/tests/run/i5386.scala +++ b/tests/run/i5386.scala @@ -1,10 +1,5 @@ object Test extends App { - ${ - println("!") - 1 - } - +{ println("!") 1 diff --git a/tests/run/i5533b/Macro_1.scala b/tests/run/i5533b/Macro_1.scala index 3af4d58fde05..932ee7bfe374 100644 --- a/tests/run/i5533b/Macro_1.scala +++ b/tests/run/i5533b/Macro_1.scala @@ -5,7 +5,7 @@ object scalatest { def f(x: Int): Int = x def f(x: String): String = x - inline def assert(condition: => Boolean): Unit = ~assertImpl('{condition}) + inline def assert(condition: => Boolean): Unit = ${assertImpl('{condition})} def assertImpl(condition: Expr[Boolean])(implicit refl: Reflection): Expr[Unit] = { import refl._ @@ -21,8 +21,8 @@ object scalatest { op match { case "==" => '{ - val _left = ~left - val _right = ~right + val _left = $left + val _right = $right val _result = _left == _right println(_left) println(_right) diff --git a/tests/run/i5536/Macro_1.scala b/tests/run/i5536/Macro_1.scala index e4e0e67a09b0..e9fee636b459 100644 --- a/tests/run/i5536/Macro_1.scala +++ b/tests/run/i5536/Macro_1.scala @@ -2,7 +2,7 @@ import scala.quoted._ import scala.tasty._ object scalatest { - inline def assert(condition: => Boolean): Unit = ~assertImpl('{condition}) + inline def assert(condition: => Boolean): Unit = ${assertImpl('{condition})} def assertImpl(condition: Expr[Boolean])(implicit refl: Reflection): Expr[Unit] = { import refl._ @@ -18,8 +18,8 @@ object scalatest { op match { case "===" => '{ - val _left = ~left - val _right = ~right + val _left = $left + val _right = $right val _result = _left == _right scala.Predef.assert(_result) } diff --git a/tests/run/inline-case-objects/Main_2.scala b/tests/run/inline-case-objects/Main_2.scala index 7f03be8a15c4..170efdebcc6a 100644 --- a/tests/run/inline-case-objects/Main_2.scala +++ b/tests/run/inline-case-objects/Main_2.scala @@ -10,6 +10,6 @@ object Test { println(fooString(foo.Bar.Baz)) } - inline def fooString(inline x: Any): String = ~Macros.impl(x) + inline def fooString(inline x: Any): String = ${Macros.impl(x)} } diff --git a/tests/run/inline-macro-staged-interpreter/Macro_1.scala b/tests/run/inline-macro-staged-interpreter/Macro_1.scala index c22c8dd72f1d..6d4948f691a4 100644 --- a/tests/run/inline-macro-staged-interpreter/Macro_1.scala +++ b/tests/run/inline-macro-staged-interpreter/Macro_1.scala @@ -3,7 +3,7 @@ import scala.quoted._ object E { - inline def eval[T](inline x: E[T]): T = ~impl(x) + inline def eval[T](inline x: E[T]): T = ${ impl(x) } def impl[T](x: E[T]): Expr[T] = x.lift @@ -36,21 +36,21 @@ trait Op2[T] { trait Plus2[T] extends Op2[T] object Plus2 { implicit case object IPlus extends Plus2[Int] { - def apply(x: Expr[Int], y: Expr[Int]): Expr[Int] = '{~x + ~y} + def apply(x: Expr[Int], y: Expr[Int]): Expr[Int] = '{$x + $y} } implicit case object DPlus extends Plus2[Double] { - def apply(x: Expr[Double], y: Expr[Double]): Expr[Double] = '{~x + ~y} + def apply(x: Expr[Double], y: Expr[Double]): Expr[Double] = '{$x + $y} } } trait Times2[T] extends Op2[T] object Times2 { implicit case object ITimes extends Times2[Int] { - def apply(x: Expr[Int], y: Expr[Int]): Expr[Int] = '{~x * ~y} + def apply(x: Expr[Int], y: Expr[Int]): Expr[Int] = '{$x * $y} } implicit case object DTimes extends Times2[Double] { - def apply(x: Expr[Double], y: Expr[Double]): Expr[Double] = '{~x * ~y} + def apply(x: Expr[Double], y: Expr[Double]): Expr[Double] = '{$x * $y} } } diff --git a/tests/run/inline-option/Main_2.scala b/tests/run/inline-option/Main_2.scala index 0050e2bdf89e..915678b9c54e 100644 --- a/tests/run/inline-option/Main_2.scala +++ b/tests/run/inline-option/Main_2.scala @@ -15,14 +15,14 @@ object Test { println(size5(Some(Some(6)))) } - inline def size(inline opt: Option[Int]): Int = ~Macros.impl(opt) + inline def size(inline opt: Option[Int]): Int = ${ Macros.impl(opt) } - inline def size2(inline i: Int): Int = ~Macros.impl(None) + inline def size2(inline i: Int): Int = ${ Macros.impl(None) } - inline def size3(inline i: Int): Int = ~Macros.impl(Some(i)) + inline def size3(inline i: Int): Int = ${ Macros.impl(Some(i)) } - inline def size4(inline i: Int): Int = ~Macros.impl2(Some(Some(i))) + inline def size4(inline i: Int): Int = ${ Macros.impl2(Some(Some(i))) } - inline def size5(inline opt: Option[Option[Int]]): Int = ~Macros.impl2(opt) + inline def size5(inline opt: Option[Option[Int]]): Int = ${ Macros.impl2(opt) } } diff --git a/tests/run/inline-tuples-1/Main_2.scala b/tests/run/inline-tuples-1/Main_2.scala index 54971154d29e..13ba486a6ed5 100644 --- a/tests/run/inline-tuples-1/Main_2.scala +++ b/tests/run/inline-tuples-1/Main_2.scala @@ -26,27 +26,27 @@ object Test { println(sum(Tuple22(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22))) } - inline def sum(inline tup: Tuple1[Int]): Int = ~Macros.tup1(tup) - inline def sum(inline tup: Tuple2[Int, Int]): Int = ~Macros.tup2(tup) - inline def sum(inline tup: Tuple3[Int, Int, Int]): Int = ~Macros.tup3(tup) - inline def sum(inline tup: Tuple4[Int, Int, Int, Int]): Int = ~Macros.tup4(tup) - inline def sum(inline tup: Tuple5[Int, Int, Int, Int, Int]): Int = ~Macros.tup5(tup) - inline def sum(inline tup: Tuple6[Int, Int, Int, Int, Int, Int]): Int = ~Macros.tup6(tup) - inline def sum(inline tup: Tuple7[Int, Int, Int, Int, Int, Int, Int]): Int = ~Macros.tup7(tup) - inline def sum(inline tup: Tuple8[Int, Int, Int, Int, Int, Int, Int, Int]): Int = ~Macros.tup8(tup) - inline def sum(inline tup: Tuple9[Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ~Macros.tup9(tup) - inline def sum(inline tup: Tuple10[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ~Macros.tup10(tup) - inline def sum(inline tup: Tuple11[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ~Macros.tup11(tup) - inline def sum(inline tup: Tuple12[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ~Macros.tup12(tup) - inline def sum(inline tup: Tuple13[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ~Macros.tup13(tup) - inline def sum(inline tup: Tuple14[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ~Macros.tup14(tup) - inline def sum(inline tup: Tuple15[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ~Macros.tup15(tup) - inline def sum(inline tup: Tuple16[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ~Macros.tup16(tup) - inline def sum(inline tup: Tuple17[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ~Macros.tup17(tup) - inline def sum(inline tup: Tuple18[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ~Macros.tup18(tup) - inline def sum(inline tup: Tuple19[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ~Macros.tup19(tup) - inline def sum(inline tup: Tuple20[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ~Macros.tup20(tup) - inline def sum(inline tup: Tuple21[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ~Macros.tup21(tup) - inline def sum(inline tup: Tuple22[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ~Macros.tup22(tup) + inline def sum(inline tup: Tuple1[Int]): Int = ${ Macros.tup1(tup) } + inline def sum(inline tup: Tuple2[Int, Int]): Int = ${ Macros.tup2(tup) } + inline def sum(inline tup: Tuple3[Int, Int, Int]): Int = ${ Macros.tup3(tup) } + inline def sum(inline tup: Tuple4[Int, Int, Int, Int]): Int = ${ Macros.tup4(tup) } + inline def sum(inline tup: Tuple5[Int, Int, Int, Int, Int]): Int = ${ Macros.tup5(tup) } + inline def sum(inline tup: Tuple6[Int, Int, Int, Int, Int, Int]): Int = ${ Macros.tup6(tup) } + inline def sum(inline tup: Tuple7[Int, Int, Int, Int, Int, Int, Int]): Int = ${ Macros.tup7(tup) } + inline def sum(inline tup: Tuple8[Int, Int, Int, Int, Int, Int, Int, Int]): Int = ${ Macros.tup8(tup) } + inline def sum(inline tup: Tuple9[Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ${ Macros.tup9(tup) } + inline def sum(inline tup: Tuple10[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ${ Macros.tup10(tup) } + inline def sum(inline tup: Tuple11[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ${ Macros.tup11(tup) } + inline def sum(inline tup: Tuple12[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ${ Macros.tup12(tup) } + inline def sum(inline tup: Tuple13[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ${ Macros.tup13(tup) } + inline def sum(inline tup: Tuple14[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ${ Macros.tup14(tup) } + inline def sum(inline tup: Tuple15[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ${ Macros.tup15(tup) } + inline def sum(inline tup: Tuple16[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ${ Macros.tup16(tup) } + inline def sum(inline tup: Tuple17[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ${ Macros.tup17(tup) } + inline def sum(inline tup: Tuple18[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ${ Macros.tup18(tup) } + inline def sum(inline tup: Tuple19[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ${ Macros.tup19(tup) } + inline def sum(inline tup: Tuple20[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ${ Macros.tup20(tup) } + inline def sum(inline tup: Tuple21[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ${ Macros.tup21(tup) } + inline def sum(inline tup: Tuple22[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ${ Macros.tup22(tup) } } diff --git a/tests/run/inline-tuples-2/Main_2.scala b/tests/run/inline-tuples-2/Main_2.scala index d250d919f941..7e29333e8bfb 100644 --- a/tests/run/inline-tuples-2/Main_2.scala +++ b/tests/run/inline-tuples-2/Main_2.scala @@ -11,12 +11,12 @@ object Test { println(get4(Tuple1(Tuple1(6)))) } - inline def get1(inline tup: Tuple1[Int]): Int = ~Macros.impl(tup) + inline def get1(inline tup: Tuple1[Int]): Int = ${ Macros.impl(tup) } - inline def get2(inline i: Int): Int = ~Macros.impl(Tuple1(i)) + inline def get2(inline i: Int): Int = ${ Macros.impl(Tuple1(i)) } - inline def get3(inline i: Int): Int = ~Macros.impl2(Tuple1(Tuple1(i))) + inline def get3(inline i: Int): Int = ${ Macros.impl2(Tuple1(Tuple1(i))) } - inline def get4(inline tup: Tuple1[Tuple1[Int]]): Int = ~Macros.impl2(tup) + inline def get4(inline tup: Tuple1[Tuple1[Int]]): Int = ${ Macros.impl2(tup) } } diff --git a/tests/run/inline-varargs-1/Main_2.scala b/tests/run/inline-varargs-1/Main_2.scala index 95edcdf19a8d..16b90860dd7c 100644 --- a/tests/run/inline-varargs-1/Main_2.scala +++ b/tests/run/inline-varargs-1/Main_2.scala @@ -5,5 +5,5 @@ object Test { println(sum(1, 2, 3)) } - inline def sum(inline i: Int, inline j: Int, inline k: Int): Int = ~Macros.sum(i, j, k) + inline def sum(inline i: Int, inline j: Int, inline k: Int): Int = ${ Macros.sum(i, j, k) } } diff --git a/tests/run/quote-and-splice/Macros_1.scala b/tests/run/quote-and-splice/Macros_1.scala index 652f8f6b1e70..9ef6732de3fc 100644 --- a/tests/run/quote-and-splice/Macros_1.scala +++ b/tests/run/quote-and-splice/Macros_1.scala @@ -2,26 +2,26 @@ import scala.quoted._ object Macros { - inline def macro1 = ~ macro1Impl + inline def macro1 = ${ macro1Impl } def macro1Impl = '{3} - inline def macro2(inline p: Boolean) = ~ macro2Impl(p) + inline def macro2(inline p: Boolean) = ${ macro2Impl(p) } def macro2Impl(p: Boolean) = if (p) '{3} else '{4} - inline def macro3(n: Int) = ~ macro3Impl('{n}) - def macro3Impl(p: Expr[Int]) = '{ 2 + ~p } + inline def macro3(n: Int) = ${ macro3Impl('{n}) } + def macro3Impl(p: Expr[Int]) = '{ 2 + $p } - inline def macro4(i: Int)(j: Int) = ~ macro4Impl('{i})('{j}) - def macro4Impl(i: Expr[Int])(j: Expr[Int]) = '{ ~i + ~j } + inline def macro4(i: Int)(j: Int) = ${ macro4Impl('{i})('{j}) } + def macro4Impl(i: Expr[Int])(j: Expr[Int]) = '{ $i + $j } - inline def macro5(i: Int, j: Int) = ~ macro5Impl(j = '{j}, i = '{i}) - def macro5Impl(i: Expr[Int], j: Expr[Int]) = '{ ~i + ~j } + inline def macro5(i: Int, j: Int) = ${ macro5Impl(j = '{j}, i = '{i}) } + def macro5Impl(i: Expr[Int], j: Expr[Int]) = '{ $i + $j } - inline def power(inline n: Int, x: Double) = ~powerCode(n, '{x}) + inline def power(inline n: Int, x: Double) = ${ powerCode(n, '{x}) } def powerCode(n: Int, x: Expr[Double]): Expr[Double] = if (n == 0) '{1.0} else if (n == 1) x - else if (n % 2 == 0) '{ { val y = ~x * ~x; ~powerCode(n / 2, '{y}) } } - else '{ ~x * ~powerCode(n - 1, x) } + else if (n % 2 == 0) '{ { val y = $x * $x; ${powerCode(n / 2, '{y})} } } + else '{ $x * ${ powerCode(n - 1, x) } } } diff --git a/tests/run/quote-change-owner/Macro_1.scala b/tests/run/quote-change-owner/Macro_1.scala index fe41e653efe7..d94512128858 100644 --- a/tests/run/quote-change-owner/Macro_1.scala +++ b/tests/run/quote-change-owner/Macro_1.scala @@ -1,8 +1,8 @@ import scala.quoted._ object Macros { - inline def assert2(expr: => Boolean): Unit = ~ assertImpl('{expr}) + inline def assert2(expr: => Boolean): Unit = ${ assertImpl('{expr}) } def assertImpl(expr: Expr[Boolean]) = '{ - def foo(): Unit = ~expr + def foo(): Unit = $expr foo() } } diff --git a/tests/run/quote-sep-comp-2/Macro_1.scala b/tests/run/quote-sep-comp-2/Macro_1.scala index dadd4d890a99..eac46498d15f 100644 --- a/tests/run/quote-sep-comp-2/Macro_1.scala +++ b/tests/run/quote-sep-comp-2/Macro_1.scala @@ -1,5 +1,5 @@ import scala.quoted._ object Macros { - def assertImpl(expr: Expr[Boolean]) = '{ println(~expr) } + def assertImpl(expr: Expr[Boolean]) = '{ println($expr) } } diff --git a/tests/run/quote-sep-comp-2/Test_2.scala b/tests/run/quote-sep-comp-2/Test_2.scala index c756443b4848..9cf8c197792d 100644 --- a/tests/run/quote-sep-comp-2/Test_2.scala +++ b/tests/run/quote-sep-comp-2/Test_2.scala @@ -1,7 +1,7 @@ object Test { - inline def assert2(expr: => Boolean): Unit = ~Macros.assertImpl('{expr}) + inline def assert2(expr: => Boolean): Unit = ${ Macros.assertImpl('{expr}) } def main(args: Array[String]): Unit = { val x = 1 diff --git a/tests/run/quote-sep-comp/Macro_1.scala b/tests/run/quote-sep-comp/Macro_1.scala index b8b73c3016fc..055589347f16 100644 --- a/tests/run/quote-sep-comp/Macro_1.scala +++ b/tests/run/quote-sep-comp/Macro_1.scala @@ -1,5 +1,5 @@ import scala.quoted._ object Macros { - inline def assert2(expr: => Boolean): Unit = ~ assertImpl('{expr}) - def assertImpl(expr: Expr[Boolean]) = '{ println(~expr) } + inline def assert2(expr: => Boolean): Unit = ${ assertImpl('{expr}) } + def assertImpl(expr: Expr[Boolean]) = '{ println($expr) } } diff --git a/tests/run/quote-simple-macro/quoted_1.scala b/tests/run/quote-simple-macro/quoted_1.scala index 87109ebd4070..60c1b1edeec9 100644 --- a/tests/run/quote-simple-macro/quoted_1.scala +++ b/tests/run/quote-simple-macro/quoted_1.scala @@ -1,6 +1,6 @@ import scala.quoted._ object Macros { - inline def foo(inline i: Int, dummy: Int, j: Int): Int = ~bar(i, '{j}) - def bar(x: Int, y: Expr[Int]): Expr[Int] = '{ ${x.toExpr} + ~y } + inline def foo(inline i: Int, dummy: Int, j: Int): Int = ${ bar(i, '{j}) } + def bar(x: Int, y: Expr[Int]): Expr[Int] = '{ ${x.toExpr} + $y } } diff --git a/tests/run/reflect-select-copy/assert_1.scala b/tests/run/reflect-select-copy/assert_1.scala index a127be649336..2e6ca7e944ea 100644 --- a/tests/run/reflect-select-copy/assert_1.scala +++ b/tests/run/reflect-select-copy/assert_1.scala @@ -3,7 +3,7 @@ import scala.tasty._ object scalatest { - inline def assert(condition: => Boolean): Unit = ~assertImpl('{condition}, '{""}) + inline def assert(condition: => Boolean): Unit = ${ assertImpl('{condition}, '{""}) } def assertImpl(cond: Expr[Boolean], clue: Expr[Any])(implicit refl: Reflection): Expr[Unit] = { import refl._ @@ -13,9 +13,9 @@ object scalatest { case Term.Apply(sel @ Term.Select(lhs, op), rhs :: Nil) => val Term.IsSelect(select) = sel val cond = Term.Apply(Term.Select.copy(select)(lhs, ">"), rhs :: Nil).seal[Boolean] - '{ scala.Predef.assert(~cond) } + '{ scala.Predef.assert($cond) } case _ => - '{ scala.Predef.assert(~cond) } + '{ scala.Predef.assert($cond) } } } } \ No newline at end of file diff --git a/tests/run/tasty-argument-tree-1/quoted_1.scala b/tests/run/tasty-argument-tree-1/quoted_1.scala index 5b20542b2467..ec30d619445b 100644 --- a/tests/run/tasty-argument-tree-1/quoted_1.scala +++ b/tests/run/tasty-argument-tree-1/quoted_1.scala @@ -3,7 +3,7 @@ import scala.tasty._ object Macros { - inline def inspect[T](x: T): Unit = ~impl('{x}) + inline def inspect[T](x: T): Unit = ${ impl('{x}) } def impl[T](x: Expr[T])(implicit reflect: Reflection): Expr[Unit] = { import reflect._ diff --git a/tests/run/tasty-custom-show/quoted_1.scala b/tests/run/tasty-custom-show/quoted_1.scala index 7bec29d426cd..1106081d2078 100644 --- a/tests/run/tasty-custom-show/quoted_1.scala +++ b/tests/run/tasty-custom-show/quoted_1.scala @@ -5,7 +5,7 @@ import scala.tasty.Reflection object Macros { implicit inline def printOwners[T](x: => T): Unit = - ~impl('{x}) + ${ impl('{x}) } def impl[T](x: Expr[T])(implicit reflect: Reflection): Expr[Unit] = { import reflect._ diff --git a/tests/run/tasty-eval/quoted_1.scala b/tests/run/tasty-eval/quoted_1.scala index dd4e5ee98d0c..170dda20d343 100644 --- a/tests/run/tasty-eval/quoted_1.scala +++ b/tests/run/tasty-eval/quoted_1.scala @@ -5,7 +5,7 @@ import scala.tasty._ object Macros { implicit inline def foo(i: Int): String = - ~impl('{i}) + ${ impl('{i}) } def impl(i: Expr[Int])(implicit reflect: Reflection): Expr[String] = { value(i).toString.toExpr diff --git a/tests/run/tasty-extractors-1/quoted_1.scala b/tests/run/tasty-extractors-1/quoted_1.scala index df20178d8a97..9c369361f546 100644 --- a/tests/run/tasty-extractors-1/quoted_1.scala +++ b/tests/run/tasty-extractors-1/quoted_1.scala @@ -5,7 +5,7 @@ import scala.tasty._ object Macros { implicit inline def printTree[T](x: => T): Unit = - ~impl('{x}) + ${ impl('{x}) } def impl[T](x: Expr[T])(implicit reflect: Reflection): Expr[Unit] = { import reflect._ diff --git a/tests/run/tasty-extractors-2/quoted_1.scala b/tests/run/tasty-extractors-2/quoted_1.scala index 89ac3994e81e..394c83bf037c 100644 --- a/tests/run/tasty-extractors-2/quoted_1.scala +++ b/tests/run/tasty-extractors-2/quoted_1.scala @@ -5,7 +5,7 @@ import scala.tasty._ object Macros { implicit inline def printTree[T](x: => T): Unit = - ~impl('{x}) + ${ impl('{x}) } def impl[T](x: Expr[T])(implicit reflect: Reflection): Expr[Unit] = { import reflect._ diff --git a/tests/run/tasty-extractors-types/quoted_1.scala b/tests/run/tasty-extractors-types/quoted_1.scala index 9c720dbb5859..ca4526fab7dd 100644 --- a/tests/run/tasty-extractors-types/quoted_1.scala +++ b/tests/run/tasty-extractors-types/quoted_1.scala @@ -4,7 +4,7 @@ import scala.tasty._ object Macros { - implicit inline def printType[T]: Unit = ~impl('[T]) + implicit inline def printType[T]: Unit = ${ impl('[T]) } def impl[T](x: Type[T])(implicit reflect: Reflection): Expr[Unit] = { import reflect._ diff --git a/tests/run/tasty-getfile-implicit-fun-context/Macro_1.scala b/tests/run/tasty-getfile-implicit-fun-context/Macro_1.scala index ae0fef057ab6..e00418e88077 100644 --- a/tests/run/tasty-getfile-implicit-fun-context/Macro_1.scala +++ b/tests/run/tasty-getfile-implicit-fun-context/Macro_1.scala @@ -7,7 +7,7 @@ object SourceFiles { def tastyContext(implicit ctx: Reflection): Reflection = ctx implicit inline def getThisFile: String = - ~getThisFileImpl + ${getThisFileImpl} def getThisFileImpl: Macro[String] = { val reflect = tastyContext diff --git a/tests/run/tasty-getfile/Macro_1.scala b/tests/run/tasty-getfile/Macro_1.scala index 8a4e0dca1c1b..dfe7b50e0f3a 100644 --- a/tests/run/tasty-getfile/Macro_1.scala +++ b/tests/run/tasty-getfile/Macro_1.scala @@ -4,7 +4,7 @@ import scala.tasty.Reflection object SourceFiles { implicit inline def getThisFile: String = - ~getThisFileImpl + ${getThisFileImpl} private def getThisFileImpl(implicit reflect: Reflection): Expr[String] = { import reflect._ diff --git a/tests/run/tasty-implicit-fun-context-2/Macro_1.scala b/tests/run/tasty-implicit-fun-context-2/Macro_1.scala index a34036a6b2a6..9d1713005148 100644 --- a/tests/run/tasty-implicit-fun-context-2/Macro_1.scala +++ b/tests/run/tasty-implicit-fun-context-2/Macro_1.scala @@ -7,7 +7,7 @@ object Foo { type Tastier[X] = given Reflection => X implicit inline def foo: String = - ~fooImpl + ${fooImpl} def fooImpl(implicit reflect: Reflection): given Reflection => Tastier[given Reflection => Macro[String]] = { '{"abc"} diff --git a/tests/run/tasty-original-source/Macros_1.scala b/tests/run/tasty-original-source/Macros_1.scala index c463f35be58c..28700f921695 100644 --- a/tests/run/tasty-original-source/Macros_1.scala +++ b/tests/run/tasty-original-source/Macros_1.scala @@ -3,7 +3,7 @@ import scala.tasty._ object Macros { - implicit inline def withSource(arg: Any): (String, Any) = ~impl('{arg}) + implicit inline def withSource(arg: Any): (String, Any) = ${ impl('{arg}) } private def impl(arg: Expr[Any])(implicit reflect: Reflection): Expr[(String, Any)] = { import reflect._ diff --git a/tests/run/tasty-seal-method/quoted_1.scala b/tests/run/tasty-seal-method/quoted_1.scala index b71ed47598ab..ba7e250919bf 100644 --- a/tests/run/tasty-seal-method/quoted_1.scala +++ b/tests/run/tasty-seal-method/quoted_1.scala @@ -5,7 +5,7 @@ import scala.tasty._ object Asserts { inline def zeroLastArgs(x: => Int): Int = - ~zeroLastArgsImpl('{x}) + ${ zeroLastArgsImpl('{x}) } /** Replaces last argument list by 0s */ def zeroLastArgsImpl(x: Expr[Int])(implicit reflect: Reflection): Expr[Int] = { @@ -27,7 +27,7 @@ object Asserts { } inline def zeroAllArgs(x: => Int): Int = - ~zeroAllArgsImpl('{x}) + ${ zeroAllArgsImpl('{x}) } /** Replaces all argument list by 0s */ def zeroAllArgsImpl(x: Expr[Int])(implicit reflect: Reflection): Expr[Int] = { diff --git a/tests/run/tasty-tree-map/quoted_1.scala b/tests/run/tasty-tree-map/quoted_1.scala index fc9216017e01..f99b077b8a29 100644 --- a/tests/run/tasty-tree-map/quoted_1.scala +++ b/tests/run/tasty-tree-map/quoted_1.scala @@ -3,7 +3,7 @@ import scala.tasty._ object Macros { - implicit inline def identityMaped[T](x: => T): T = ~impl('{x}) + implicit inline def identityMaped[T](x: => T): T = ${ impl('{x}) } def impl[T: Type](x: Expr[T])(implicit reflection: Reflection): Expr[T] = { import reflection._ diff --git a/tests/run/tasty-typeof/Macro_1.scala b/tests/run/tasty-typeof/Macro_1.scala index efa49c533282..3dcc4394b3c2 100644 --- a/tests/run/tasty-typeof/Macro_1.scala +++ b/tests/run/tasty-typeof/Macro_1.scala @@ -3,7 +3,7 @@ import scala.tasty._ object Macros { - inline def testTypeOf(): Unit = ~testTypeOfImpl + inline def testTypeOf(): Unit = ${ testTypeOfImpl } private def testTypeOfImpl(implicit reflect: Reflection): Expr[Unit] = { import reflect._ diff --git a/tests/run/xml-interpolation-2/XmlQuote_1.scala b/tests/run/xml-interpolation-2/XmlQuote_1.scala index 6cb5d363c8fb..b6c762f4142f 100644 --- a/tests/run/xml-interpolation-2/XmlQuote_1.scala +++ b/tests/run/xml-interpolation-2/XmlQuote_1.scala @@ -10,7 +10,7 @@ case class Xml(parts: String, args: List[Any]) object XmlQuote { class SCOps(ctx: => StringContext) { - inline def xml(args: Any*): Xml = ~XmlQuote.impl('{this}, '{args}) + inline def xml(args: Any*): Xml = ${ XmlQuote.impl('{this}, '{args}) } } implicit inline def SCOps(ctx: => StringContext): SCOps = new SCOps(ctx) From 94e3a034286b9982c4e9abfbab07fe1eb43a2466 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Tue, 19 Feb 2019 10:49:34 +0100 Subject: [PATCH 19/26] Change use of `$` for splices in syntax and parsing - '$' is no longer a keyword. - 'x is treated as a quote instead of a symbol literal inside splices - 'x and $x are single tokens (of kind QUOTEID and IDENTIFIER) This reverts part of commit 8cfa1fbc42e659a89899c3ca4ac276adf82f4dc3. --- .../dotty/tools/dotc/parsing/Parsers.scala | 105 +++++++++++------- .../dotty/tools/dotc/parsing/Scanners.scala | 25 +---- .../src/dotty/tools/dotc/parsing/Tokens.scala | 18 +-- docs/docs/internals/syntax.md | 5 +- 4 files changed, 83 insertions(+), 70 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index ae52ee0348fa..d3272ce639bb 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -21,6 +21,7 @@ import util.Spans._ import Constants._ import ScriptParsers._ import Decorators._ +import scala.tasty.util.Chars.isIdentifierStart import scala.annotation.{tailrec, switch} import rewrites.Rewrites.patch @@ -48,6 +49,13 @@ object Parsers { val Class, Type, TypeParam, Def: Value = Value } + type StageKind = Int + object StageKind { + val None = 0 + val Quoted = 1 + val Spliced = 2 + } + private implicit class AddDeco(val buf: ListBuffer[Tree]) extends AnyVal { def +++=(x: Tree) = x match { case x: Thicket => buf ++= x.trees @@ -199,6 +207,16 @@ object Parsers { def isStatSep: Boolean = in.token == NEWLINE || in.token == NEWLINES || in.token == SEMI + /** A '$' identifier is treated as a splice if followed by a `{`. + * A longer identifier starting with `$` is treated as a splice/id combination + * in a quoted block '{...' + */ + def isSplice: Boolean = + in.token == IDENTIFIER && in.name(0) == '$' && { + if (in.name.length == 1) in.lookaheadIn(BitSet(LBRACE)) + else (staged & StageKind.Quoted) != 0 + } + /* ------------- ERROR HANDLING ------------------------------------------- */ /** The offset of the last time when a statement on a new line was definitely @@ -354,6 +372,14 @@ object Parsers { finally inEnum = saved } + private[this] var staged = StageKind.None + def withinStaged[T](kind: StageKind)(op: => T): T = { + val saved = staged + staged |= kind + try op + finally staged = saved + } + def migrationWarningOrError(msg: String, offset: Int = in.offset): Unit = if (in.isScala2Mode) ctx.migrationWarning(msg, source.atSpan(Span(offset))) @@ -690,14 +716,18 @@ object Parsers { } val isNegated = negOffset < in.offset atSpan(negOffset) { - if (in.token == SYMBOLLIT) { - migrationWarningOrError(em"""symbol literal '${in.name} is no longer supported, - |use a string literal "${in.name}" or an application Symbol("${in.name}") instead.""") - if (in.isScala2Mode) { - patch(source, Span(in.offset, in.offset + 1), "Symbol(\"") - patch(source, Span(in.charOffset - 1), "\")") + if (in.token == QUOTEID) { + if ((staged & StageKind.Spliced) != 0 && isIdentifierStart(in.name(1))) + Quote(atSpan(in.offset + 1)(Ident(in.name.drop(1)))) + else { + migrationWarningOrError(em"""symbol literal '${in.name} is no longer supported, + |use a string literal "${in.name}" or an application Symbol("${in.name}") instead.""") + if (in.isScala2Mode) { + patch(source, Span(in.offset, in.offset + 1), "Symbol(\"") + patch(source, Span(in.charOffset - 1), "\")") + } + atSpan(in.skipToken()) { SymbolLit(in.strVal) } } - atSpan(in.skipToken()) { SymbolLit(in.strVal) } } else if (in.token == INTERPOLATIONID) interpolatedString(inPattern) else finish(in.token match { @@ -919,26 +949,27 @@ object Parsers { else t /** The block in a quote or splice */ - def stagedBlock(isQuote: Boolean) = { - val saved = in.inQuote - in.inQuote = isQuote - inDefScopeBraces { - try - block() match { - case t @ Block(Nil, expr) => - if (expr.isEmpty) t else expr - case t => t - } - finally in.inQuote = saved + def stagedBlock() = + inDefScopeBraces(block()) match { + case t @ Block(Nil, expr) if !expr.isEmpty => expr + case t => t } - } - /** SimpleEpxr ::= ‘$’ (id | ‘{’ Block ‘}’) - * SimpleType ::= ‘$’ (id | ‘{’ Block ‘}’) + /** SimpleEpxr ::= spliceId | ‘$’ ‘{’ Block ‘}’) + * SimpleType ::= spliceId | ‘$’ ‘{’ Block ‘}’) */ def splice(isType: Boolean): Tree = - atSpan(in.skipToken()) { - val expr = if (isIdent) termIdent() else stagedBlock(isQuote = false) + atSpan(in.offset) { + val expr = + if (in.name.length == 1) { + in.nextToken() + withinStaged(StageKind.Spliced)(stagedBlock()) + } + else atSpan(in.offset + 1) { + val id = Ident(in.name.drop(1)) + in.nextToken() + id + } if (isType) TypSplice(expr) else Splice(expr) } @@ -950,7 +981,7 @@ object Parsers { * | `_' TypeBounds * | Refinement * | Literal - * | ‘$’ (id | ‘{’ Block ‘}’) + * | ‘$’ ‘{’ Block ‘}’ */ def simpleType(): Tree = simpleTypeRest { if (in.token == LPAREN) @@ -964,7 +995,7 @@ object Parsers { val start = in.skipToken() typeBounds().withSpan(Span(start, in.lastOffset, start)) } - else if (in.token == SPLICE) + else if (isSplice) splice(isType = true) else path(thisOK = false, handleSingletonType) match { case r @ SingletonTypeTree(_) => r @@ -1426,9 +1457,10 @@ object Parsers { /** SimpleExpr ::= ‘new’ (ConstrApp [TemplateBody] | TemplateBody) * | BlockExpr - * | ‘'’ (id | ‘{’ Block ‘}’) + * | ‘'’ ‘{’ Block ‘}’ * | ‘'’ ‘[’ Type ‘]’ - * | ‘$’ (id | ‘{’ Block ‘}’) + * | ‘$’ ‘{’ Block ‘}’ + * | quoteId * | SimpleExpr1 [`_'] * SimpleExpr1 ::= literal * | xmlLiteral @@ -1443,7 +1475,10 @@ object Parsers { val t = in.token match { case XMLSTART => xmlLiteral() - case IDENTIFIER | BACKQUOTED_IDENT | THIS | SUPER => + case IDENTIFIER => + if (isSplice) splice(isType = false) + else path(thisOK = true) + case BACKQUOTED_IDENT | THIS | SUPER => path(thisOK = true) case USCORE => val start = in.skipToken() @@ -1459,19 +1494,13 @@ object Parsers { blockExpr() case QUOTE => atSpan(in.skipToken()) { - Quote { - if (in.token == LBRACKET) { - val saved = in.inQuote - in.inQuote = true - inBrackets { - try typ() finally in.inQuote = saved - } + withinStaged(StageKind.Quoted) { + Quote { + if (in.token == LBRACKET) inBrackets(typ()) + else stagedBlock() } - else stagedBlock(isQuote = true) } } - case SPLICE => - splice(isType = false) case NEW => canApply = false newExpr() diff --git a/compiler/src/dotty/tools/dotc/parsing/Scanners.scala b/compiler/src/dotty/tools/dotc/parsing/Scanners.scala index f95d27857c52..a129705de59b 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Scanners.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Scanners.scala @@ -184,8 +184,6 @@ object Scanners { /** Return a list of all the comment positions */ def commentSpans: List[Span] = commentPosBuf.toList - var inQuote = false - private[this] def addComment(comment: Comment): Unit = { val lookahead = lookaheadReader() def nextPos: Int = (lookahead.getc(): @switch) match { @@ -417,7 +415,7 @@ object Scanners { 'K' | 'L' | 'M' | 'N' | 'O' | 'P' | 'Q' | 'R' | 'S' | 'T' | 'U' | 'V' | 'W' | 'X' | 'Y' | - 'Z' | '_' | + 'Z' | '$' | '_' | 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | @@ -426,15 +424,9 @@ object Scanners { 'z' => putChar(ch) nextChar() - finishIdent() - case '$' => - putChar(ch) - nextChar() - if (inQuote) { - token = SPLICE - litBuf.clear() - } - else finishIdent() + getIdentRest() + if (ch == '"' && token == IDENTIFIER) + token = INTERPOLATIONID case '<' => // is XMLSTART? def fetchLT() = { val last = if (charOffset >= 2) buf(charOffset - 2) else ' ' @@ -528,9 +520,9 @@ object Scanners { def fetchSingleQuote() = { nextChar() if (isIdentifierStart(ch)) - charLitOr { getIdentRest(); SYMBOLLIT } + charLitOr { getIdentRest(); QUOTEID } else if (isOperatorPart(ch) && (ch != '\\')) - charLitOr { getOperatorRest(); SYMBOLLIT } + charLitOr { getOperatorRest(); QUOTEID } else ch match { case '{' | '[' | ' ' | '\t' if lookaheadChar() != '\'' => token = QUOTE @@ -718,11 +710,6 @@ object Scanners { } } - def finishIdent(): Unit = { - getIdentRest() - if (ch == '"' && token == IDENTIFIER) token = INTERPOLATIONID - } - private def getOperatorRest(): Unit = (ch: @switch) match { case '~' | '!' | '@' | '#' | '%' | '^' | '*' | '+' | '-' | '<' | diff --git a/compiler/src/dotty/tools/dotc/parsing/Tokens.scala b/compiler/src/dotty/tools/dotc/parsing/Tokens.scala index 22b28fe8505b..7c50f77cd1fa 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Tokens.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Tokens.scala @@ -43,7 +43,7 @@ abstract class TokensCommon { final val STRINGLIT = 8; enter(STRINGLIT, "string literal") final val STRINGPART = 9; enter(STRINGPART, "string literal", "string literal part") //final val INTERPOLATIONID = 10; enter(INTERPOLATIONID, "string interpolator") - //final val SYMBOLLIT = 11; enter(SYMBOLLIT, "symbol literal") // TODO: deprecate + //final val QUOTEID = 11; enter(QUOTEID, "quoted identifier") // TODO: deprecate /** identifiers */ final val IDENTIFIER = 12; enter(IDENTIFIER, "identifier") @@ -149,7 +149,7 @@ object Tokens extends TokensCommon { final def maxToken: Int = XMLSTART final val INTERPOLATIONID = 10; enter(INTERPOLATIONID, "string interpolator") - final val SYMBOLLIT = 11; enter(SYMBOLLIT, "symbol literal") // TODO: deprecate + final val QUOTEID = 11; enter(QUOTEID, "quoted identifier") // TODO: deprecate final val BACKQUOTED_IDENT = 13; enter(BACKQUOTED_IDENT, "identifier", "backquoted ident") @@ -193,29 +193,29 @@ object Tokens extends TokensCommon { final val SUPERTYPE = 81; enter(SUPERTYPE, ">:") final val HASH = 82; enter(HASH, "#") final val VIEWBOUND = 84; enter(VIEWBOUND, "<%") // TODO: deprecate - final val SPLICE = 85; enter(SPLICE, "$") - final val QUOTE = 86; enter(QUOTE, "'") + final val QUOTE = 85; enter(QUOTE, "'") /** XML mode */ final val XMLSTART = 96; enter(XMLSTART, "$XMLSTART$<") // TODO: deprecate final val alphaKeywords: TokenSet = tokenRange(IF, GIVEN) - final val symbolicKeywords: TokenSet = tokenRange(USCORE, SPLICE) + final val symbolicKeywords: TokenSet = tokenRange(USCORE, VIEWBOUND) final val keywords: TokenSet = alphaKeywords | symbolicKeywords final val allTokens: TokenSet = tokenRange(minToken, maxToken) - final val simpleLiteralTokens: TokenSet = tokenRange(CHARLIT, STRINGLIT) | BitSet(TRUE, FALSE, SYMBOLLIT) + final val simpleLiteralTokens: TokenSet = + tokenRange(CHARLIT, STRINGLIT) | BitSet(TRUE, FALSE, QUOTEID) // TODO: drop QUOTEID when symbol literals are gone final val literalTokens: TokenSet = simpleLiteralTokens | BitSet(INTERPOLATIONID, NULL) final val atomicExprTokens: TokenSet = literalTokens | identifierTokens | BitSet( - USCORE, NULL, THIS, SUPER, TRUE, FALSE, RETURN, XMLSTART) + USCORE, NULL, THIS, SUPER, TRUE, FALSE, RETURN, QUOTEID, XMLSTART) final val canStartExpressionTokens: TokenSet = atomicExprTokens | BitSet( - LBRACE, LPAREN, QUOTE, SPLICE, IF, DO, WHILE, FOR, NEW, TRY, THROW) + LBRACE, LPAREN, QUOTE, IF, DO, WHILE, FOR, NEW, TRY, THROW) final val canStartTypeTokens: TokenSet = literalTokens | identifierTokens | BitSet( - THIS, SUPER, USCORE, LPAREN, AT, SPLICE) + THIS, SUPER, USCORE, LPAREN, AT) final val canStartBindingTokens: TokenSet = identifierTokens | BitSet(USCORE, LPAREN) diff --git a/docs/docs/internals/syntax.md b/docs/docs/internals/syntax.md index 88e5a3f0e9b8..9e3bf68924c9 100644 --- a/docs/docs/internals/syntax.md +++ b/docs/docs/internals/syntax.md @@ -44,6 +44,7 @@ id ::= plainid | ‘`’ { charNoBackQuoteOrNewline | UnicodeEscape | charEscapeSeq } ‘`’ | INT // interpolation id, only for quasi-quotes idrest ::= {letter | digit} [‘_’ op] +quoteId ::= ‘'’ alphaid integerLiteral ::= (decimalNumeral | hexNumeral) [‘L’ | ‘l’] decimalNumeral ::= ‘0’ | nonZeroDigit {digit} @@ -78,8 +79,6 @@ escape ::= ‘$$’ stringFormat ::= {printableChar \ (‘"’ | ‘}’ | ‘ ’ | ‘\t’ | ‘\n’)} symbolLiteral ::= ‘'’ plainid // until 2.13 -quoteId ::= ‘'’ plainid // from 3.1 -spliceId ::= '$' plainid comment ::= ‘/*’ “any sequence of characters; nested comments are allowed” ‘*/’ | ‘//’ “any sequence of characters up to end of line” @@ -160,7 +159,6 @@ SimpleType ::= SimpleType TypeArgs | ‘_’ SubtypeBounds | Refinement RefinedTypeTree(EmptyTree, refinement) | SimpleLiteral SingletonTypeTree(l) - | spliceId // only inside quotes | ‘$’ ‘{’ Block ‘}’ ArgTypes ::= Type {‘,’ Type} | NamedTypeArg {‘,’ NamedTypeArg} @@ -214,7 +212,6 @@ SimpleExpr ::= ‘new’ (ConstrApp [TemplateBody] | TemplateBody) | ‘'’ ‘{’ Block ‘}’ | ‘'’ ‘[’ Type ‘]’ | ‘$’ ‘{’ Block ‘}’ - | spliceId // only inside quotes | quoteId // only inside splices | SimpleExpr1 [‘_’] PostfixOp(expr, _) SimpleExpr1 ::= Literal From bd17841033dfdcd463961297991e8bf297c3f6e2 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Tue, 19 Feb 2019 14:40:14 +0100 Subject: [PATCH 20/26] Update docs to new syntax --- .../principled-meta-programming.md | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/docs/docs/reference/other-new-features/principled-meta-programming.md b/docs/docs/reference/other-new-features/principled-meta-programming.md index d1a667af9cea..7a1d2019e238 100644 --- a/docs/docs/reference/other-new-features/principled-meta-programming.md +++ b/docs/docs/reference/other-new-features/principled-meta-programming.md @@ -52,8 +52,8 @@ quotation. Quotes and splices can also be applied directly to identifiers. An identifier `$x` starting with a `$` that appears inside a quoted expression or type is treated as a -splice `${x}`. Analogously, an identifier 'x will be treated in the future as a quote `'{x}`. -See the Syntax section below for details. +splice `${x}`. Analogously, an quoted identifier 'x that appears inside a splice +is treated as a quote `'{x}`. See the Syntax section below for details. Quotes and splices are duals of each other. For arbitrary expressions `e` and types `T` we have: @@ -608,18 +608,15 @@ Compared to the [Dotty reference grammar](../../internals/syntax.md) there are the following syntax changes: SimpleExpr ::= ... - | ‘'’ BlockExpr + | ‘'’ ‘{’ Block ‘}’ | ‘'’ ‘[’ Type ‘]’ - | ‘$’ BlockExpr + | ‘$’ ‘{’ Block ‘}’ SimpleType ::= ... - | ‘$’ BlockExpr + | ‘$’ ‘{’ Block ‘}’ In addition, an identifier `$x` starting with a `$` that appears inside -a quoted expression or type is treated as a splice `${x}`. - -In the future, an analogous rule will apply to quoted identifiers. I.e. `'x` -will expand everywhere to `'{x}`. However, we need to wait one language version with this -so that the competing legacy syntax of symbol literals can be phased out safely. +a quoted expression or type is treated as a splice `${x}` and a quoted identifier +`'x` that appears inside a splice is treated as a quote `'{x}` ### Implementation in `dotc` From b32a4a8e96d7e2efbfe276605291db8a3f8f69d1 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Tue, 19 Feb 2019 15:29:07 +0100 Subject: [PATCH 21/26] Fix quote parsing Correctly handle 'this, 'true, 'false, 'null. --- .../tools/dotc/parsing/JavaScanners.scala | 5 +- .../dotty/tools/dotc/parsing/Parsers.scala | 62 ++++++++++++------- .../dotty/tools/dotc/parsing/Scanners.scala | 13 ++-- .../other-new-features/tasty-reflect.md | 2 +- .../src-bootstrapped/scala/StagedTuple.scala | 2 +- library/src-bootstrapped/scala/Tuple.scala | 20 +++--- tests/disabled/run/i4803d/App_2.scala | 2 +- tests/disabled/run/i4803d/Macro_1.scala | 2 +- .../run/xml-interpolation-3/XmlQuote_1.scala | 2 +- .../quote-run-in-macro-1/quoted_1.scala | 2 +- .../quote-run-in-macro-2/quoted_1.scala | 2 +- tests/neg/i4433.scala | 4 +- tests/neg/i4774b.scala | 2 +- tests/neg/i4890.scala | 2 +- tests/neg/quote-interpolator-core-old.scala | 6 +- tests/neg/quote-macro-complex-arg-0.scala | 2 +- tests/neg/quote-macro-splice.scala | 2 +- tests/neg/quote-pcp-in-arg.scala | 2 +- tests/neg/quote-splice-interpret-1.scala | 4 +- tests/neg/quote-this.scala | 4 +- tests/neg/tasty-macro-assert/quoted_1.scala | 2 +- tests/pos-with-compiler/quote-0.scala | 6 +- .../quote-assert/quoted_2.scala | 2 +- tests/pos/i3898/quoted_1.scala | 2 +- tests/pos/i3898b/quoted_1.scala | 2 +- tests/pos/i3898c/quoted_1.scala | 2 +- tests/pos/i4023/Macro_1.scala | 2 +- tests/pos/i4023c/Macro_1.scala | 2 +- tests/pos/i4514.scala | 2 +- tests/pos/i4734/Macro_1.scala | 2 +- tests/pos/i4774a.scala | 2 +- tests/pos/i4774c.scala | 2 +- tests/pos/i4774d.scala | 2 +- tests/pos/i4774e.scala | 2 +- tests/pos/i4774f.scala | 2 +- tests/pos/i4846.scala | 2 +- tests/pos/power-macro/Macro_1.scala | 4 +- tests/pos/quote-lift-inline-params-b.scala | 2 +- .../quote-lift-inline-params/Macro_1.scala | 2 +- tests/pos/quote-nested-object/Macro_1.scala | 4 +- tests/pos/quote-this.scala | 2 +- .../tasty-definitions-2/Macro_1.scala | 2 +- .../tasty-definitions-3/Macro_1.scala | 2 +- .../tasty-extractors-owners/quoted_1.scala | 2 +- .../tasty-load-tree-1/quoted_1.scala | 2 +- .../tasty-load-tree-2/quoted_1.scala | 2 +- .../staged-streams_1.scala | 12 ++-- tests/run-with-compiler/i4044b.scala | 2 +- tests/run-with-compiler/i5144.scala | 2 +- tests/run-with-compiler/i5144b.scala | 2 +- .../run-with-compiler/quote-ackermann-1.scala | 2 +- tests/run-with-compiler/quote-fun-app-1.scala | 6 +- .../quote-impure-by-name/quoted_1.scala | 2 +- .../quote-inline-function/quoted_1.scala | 8 +-- tests/run-with-compiler/quote-lambda.scala | 2 +- tests/run-with-compiler/quote-lib.scala | 6 +- tests/run-with-compiler/quote-nested-3.scala | 2 +- tests/run-with-compiler/quote-run-2.scala | 2 +- .../quote-run-staged-interpreter.scala | 4 +- .../quote-two-captured-ref.scala | 4 +- tests/run-with-compiler/quote-type-tags.scala | 2 +- .../quote-unrolled-foreach.scala | 16 ++--- tests/run-with-compiler/quote-var.scala | 2 +- .../reflect-select-copy/assert_1.scala | 2 +- .../run-with-compiler/shonan-hmm-simple.scala | 2 +- .../shonan-hmm/Lifters.scala | 4 +- .../run-with-compiler/shonan-hmm/MVmult.scala | 14 ++--- .../run-with-compiler/shonan-hmm/VecOp.scala | 2 +- .../run-with-compiler/shonan-hmm/VecROp.scala | 2 +- .../run-with-compiler/shonan-hmm/Vmults.scala | 6 +- .../quoted_1.scala | 2 +- .../tasty-unsafe-let/quoted_1.scala | 2 +- tests/run/f-interpolation-1/FQuote_1.scala | 2 +- .../gestalt-optional-staging/Macro_1.scala | 4 +- .../Macro_1.scala | 2 +- tests/run/i4455/Macro_1.scala | 2 +- tests/run/i4515/Macro_1.scala | 2 +- tests/run/i4734/Macro_1.scala | 4 +- tests/run/i4735/Macro_1.scala | 4 +- tests/run/i4803/App_2.scala | 2 +- tests/run/i4803/Macro_1.scala | 4 +- tests/run/i4803b/App_2.scala | 2 +- tests/run/i4803b/Macro_1.scala | 2 +- tests/run/i4803c/App_2.scala | 4 +- tests/run/i4803c/Macro_1.scala | 2 +- tests/run/i4803e/App_2.scala | 2 +- tests/run/i4803f/App_2.scala | 2 +- tests/run/i4803f/Macro_1.scala | 4 +- tests/run/i4947e/Test_2.scala | 2 +- tests/run/i4947f/Macro_1.scala | 2 +- tests/run/i5119/Macro_1.scala | 2 +- tests/run/i5533/Macro_1.scala | 2 +- tests/run/i5533b/Macro_1.scala | 2 +- tests/run/i5536/Macro_1.scala | 2 +- tests/run/quote-and-splice/Macros_1.scala | 10 +-- tests/run/quote-change-owner/Macro_1.scala | 2 +- tests/run/quote-sep-comp-2/Test_2.scala | 2 +- tests/run/quote-sep-comp/Macro_1.scala | 2 +- tests/run/quote-simple-macro/quoted_1.scala | 2 +- .../run/quote-unrolled-foreach/quoted_1.scala | 2 +- tests/run/reflect-select-copy/assert_1.scala | 2 +- .../run/tasty-argument-tree-1/quoted_1.scala | 2 +- tests/run/tasty-custom-show/quoted_1.scala | 2 +- tests/run/tasty-eval/quoted_1.scala | 2 +- tests/run/tasty-extractors-1/quoted_1.scala | 2 +- tests/run/tasty-extractors-2/quoted_1.scala | 2 +- tests/run/tasty-extractors-3/quoted_1.scala | 2 +- tests/run/tasty-interpolation-1/Macro.scala | 6 +- tests/run/tasty-macro-assert/quoted_1.scala | 2 +- tests/run/tasty-macro-const/quoted_1.scala | 2 +- .../run/tasty-original-source/Macros_1.scala | 2 +- tests/run/tasty-positioned/quoted_1.scala | 2 +- tests/run/tasty-seal-method/quoted_1.scala | 4 +- tests/run/tasty-tree-map/quoted_1.scala | 2 +- .../run/xml-interpolation-1/XmlQuote_1.scala | 2 +- .../run/xml-interpolation-2/XmlQuote_1.scala | 2 +- .../run/xml-interpolation-3/XmlQuote_1.scala | 2 +- 117 files changed, 225 insertions(+), 205 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/parsing/JavaScanners.scala b/compiler/src/dotty/tools/dotc/parsing/JavaScanners.scala index 34c8120921f3..0c415d813889 100644 --- a/compiler/src/dotty/tools/dotc/parsing/JavaScanners.scala +++ b/compiler/src/dotty/tools/dotc/parsing/JavaScanners.scala @@ -3,6 +3,7 @@ package dotc package parsing import core.Contexts._ +import core.Names.SimpleName import Scanners._ import util.SourceFile import JavaTokens._ @@ -13,8 +14,10 @@ object JavaScanners { class JavaScanner(source: SourceFile, override val startFrom: Offset = 0)(implicit ctx: Context) extends ScannerCommon(source)(ctx) { - def toToken(idx: Int): Token = + def toToken(name: SimpleName): Token = { + val idx = name.start if (idx >= 0 && idx <= lastKeywordStart) kwArray(idx) else IDENTIFIER + } private class JavaTokenData0 extends TokenData diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index d3272ce639bb..375df1eace89 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -703,25 +703,50 @@ object Parsers { def qualId(): Tree = dotSelectors(termIdent()) /** SimpleExpr ::= literal - * | symbol + * | 'id | 'this | 'true | 'false | 'null * | null * @param negOffset The offset of a preceding `-' sign, if any. * If the literal is not negated, negOffset = in.offset. */ def literal(negOffset: Int = in.offset, inPattern: Boolean = false): Tree = { - def finish(value: Any): Tree = { - val t = atSpan(negOffset) { Literal(Constant(value)) } - in.nextToken() - t + + def literalOf(token: Token): Literal = { + val isNegated = negOffset < in.offset + val value = token match { + case CHARLIT => in.charVal + case INTLIT => in.intVal(isNegated).toInt + case LONGLIT => in.intVal(isNegated) + case FLOATLIT => in.floatVal(isNegated).toFloat + case DOUBLELIT => in.floatVal(isNegated) + case STRINGLIT | STRINGPART => in.strVal + case TRUE => true + case FALSE => false + case NULL => null + case _ => + syntaxErrorOrIncomplete(IllegalLiteral()) + null + } + Literal(Constant(value)) } - val isNegated = negOffset < in.offset + atSpan(negOffset) { if (in.token == QUOTEID) { - if ((staged & StageKind.Spliced) != 0 && isIdentifierStart(in.name(1))) - Quote(atSpan(in.offset + 1)(Ident(in.name.drop(1)))) + if ((staged & StageKind.Spliced) != 0 && isIdentifierStart(in.name(0))) { + val t = atSpan(in.offset + 1) { + val tok = in.toToken(in.name) + tok match { + case TRUE | FALSE | NULL => literalOf(tok) + case THIS => This(EmptyTypeIdent) + case _ => Ident(in.name) + } + } + in.nextToken() + Quote(t) + } else { migrationWarningOrError(em"""symbol literal '${in.name} is no longer supported, - |use a string literal "${in.name}" or an application Symbol("${in.name}") instead.""") + |use a string literal "${in.name}" or an application Symbol("${in.name}") instead, + |or enclose in braces '{${in.name}} if you want a quoted expression.""") if (in.isScala2Mode) { patch(source, Span(in.offset, in.offset + 1), "Symbol(\"") patch(source, Span(in.charOffset - 1), "\")") @@ -730,20 +755,11 @@ object Parsers { } } else if (in.token == INTERPOLATIONID) interpolatedString(inPattern) - else finish(in.token match { - case CHARLIT => in.charVal - case INTLIT => in.intVal(isNegated).toInt - case LONGLIT => in.intVal(isNegated) - case FLOATLIT => in.floatVal(isNegated).toFloat - case DOUBLELIT => in.floatVal(isNegated) - case STRINGLIT | STRINGPART => in.strVal - case TRUE => true - case FALSE => false - case NULL => null - case _ => - syntaxErrorOrIncomplete(IllegalLiteral()) - null - }) + else { + val t = literalOf(in.token) + in.nextToken() + t + } } } diff --git a/compiler/src/dotty/tools/dotc/parsing/Scanners.scala b/compiler/src/dotty/tools/dotc/parsing/Scanners.scala index a129705de59b..b4cf20536bb6 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Scanners.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Scanners.scala @@ -100,13 +100,12 @@ object Scanners { def finishNamed(idtoken: Token = IDENTIFIER, target: TokenData = this): Unit = { target.name = termName(flushBuf(litBuf)) target.token = idtoken - if (idtoken == IDENTIFIER) { - val idx = target.name.start - target.token = toToken(idx) - } + if (idtoken == IDENTIFIER) + target.token = toToken(target.name) } - def toToken(idx: Int): Token + /** The token for given `name`. Either IDENTIFIER or a keyword. */ + def toToken(name: SimpleName): Token /** Clear buffer and set string */ def setStrVal(): Unit = @@ -215,9 +214,11 @@ object Scanners { IDENTIFIER } - def toToken(idx: Int): Token = + def toToken(name: SimpleName): Token = { + val idx = name.start if (idx >= 0 && idx <= lastKeywordStart) handleMigration(kwArray(idx)) else IDENTIFIER + } private class TokenData0 extends TokenData diff --git a/docs/docs/reference/other-new-features/tasty-reflect.md b/docs/docs/reference/other-new-features/tasty-reflect.md index f7851ed52673..a98010a52991 100644 --- a/docs/docs/reference/other-new-features/tasty-reflect.md +++ b/docs/docs/reference/other-new-features/tasty-reflect.md @@ -24,7 +24,7 @@ To provide reflection capabilities in macros we need to add an implicit paramete import scala.quoted._ import scala.tasty._ -inline def natConst(x: Int): Int = ~natConstImpl('{x}) +inline def natConst(x: Int): Int = ~natConstImpl('x) def natConstImpl(x: Expr[Int])(implicit reflection: Reflection): Expr[Int] = { import reflection._ diff --git a/library/src-bootstrapped/scala/StagedTuple.scala b/library/src-bootstrapped/scala/StagedTuple.scala index 2ce1aaf67c2e..ff65b01770f1 100644 --- a/library/src-bootstrapped/scala/StagedTuple.scala +++ b/library/src-bootstrapped/scala/StagedTuple.scala @@ -253,7 +253,7 @@ object StagedTuple { def bind[T: Type](in: Expr[U] => Expr[T]): Expr[T] = '{ val t: U = $expr - ${in('{t})} + ${in('t)} } } diff --git a/library/src-bootstrapped/scala/Tuple.scala b/library/src-bootstrapped/scala/Tuple.scala index b42c274738fa..03b067d22949 100644 --- a/library/src-bootstrapped/scala/Tuple.scala +++ b/library/src-bootstrapped/scala/Tuple.scala @@ -32,7 +32,7 @@ sealed trait Tuple extends Any { } inline def stagedToArray: Array[Object] = - ${ StagedTuple.toArrayStaged('{this}, constValueOpt[BoundedSize[this.type]]) } + ${ StagedTuple.toArrayStaged('this, constValueOpt[BoundedSize[this.type]]) } inline def *: [H] (x: H): H *: this.type = if (stageIt) stagedCons[H](x) @@ -60,7 +60,7 @@ sealed trait Tuple extends Any { } inline def stagedCons[H] (x: H): H *: this.type = - ${ StagedTuple.stagedCons('{this}, '{x}, constValueOpt[BoundedSize[this.type]]) } + ${ StagedTuple.stagedCons('this, 'x, constValueOpt[BoundedSize[this.type]]) } inline def ++(that: Tuple): Concat[this.type, that.type] = if (stageIt) stagedConcat(that) @@ -104,8 +104,8 @@ sealed trait Tuple extends Any { } inline def stagedConcat(that: Tuple): Concat[this.type, that.type] = - ${ StagedTuple.stagedConcat('{this}, constValueOpt[BoundedSize[this.type]], - '{that}, constValueOpt[BoundedSize[that.type]]) } + ${ StagedTuple.stagedConcat('this, constValueOpt[BoundedSize[this.type]], + 'that, constValueOpt[BoundedSize[that.type]]) } inline def genericConcat[T <: Tuple](xs: Tuple, ys: Tuple): Tuple = fromArray[T](xs.toArray ++ ys.toArray) @@ -121,7 +121,7 @@ sealed trait Tuple extends Any { } inline def stagedSize: Size[this.type] = - ${ StagedTuple.sizeStaged[Size[this.type]]('{this}, constValueOpt[BoundedSize[this.type]]) } + ${ StagedTuple.sizeStaged[Size[this.type]]('this, constValueOpt[BoundedSize[this.type]]) } } object Tuple { @@ -217,7 +217,7 @@ object Tuple { } inline def stagedFromArray[T <: Tuple](xs: Array[Object]): T = - ${ StagedTuple.fromArrayStaged[T]('{xs}, constValueOpt[BoundedSize[this.type]]) } + ${ StagedTuple.fromArrayStaged[T]('xs, constValueOpt[BoundedSize[this.type]]) } def dynamicFromArray[T <: Tuple](xs: Array[Object]): T = xs.length match { case 0 => ().asInstanceOf[T] @@ -340,7 +340,7 @@ sealed trait NonEmptyTuple extends Tuple { } inline def stagedHead: Head[this.type] = - ${ StagedTuple.headStaged[this.type]('{this}, constValueOpt[BoundedSize[this.type]]) } + ${ StagedTuple.headStaged[this.type]('this, constValueOpt[BoundedSize[this.type]]) } inline def tail: Tail[this.type] = if (stageIt) stagedTail @@ -369,7 +369,7 @@ sealed trait NonEmptyTuple extends Tuple { } inline def stagedTail: Tail[this.type] = - ${ StagedTuple.tailStaged[this.type]('{this}, constValueOpt[BoundedSize[this.type]]) } + ${ StagedTuple.tailStaged[this.type]('this, constValueOpt[BoundedSize[this.type]]) } inline def fallbackApply(n: Int) = inline constValueOpt[n.type] match { @@ -430,8 +430,8 @@ sealed trait NonEmptyTuple extends Tuple { inline def stagedApply(n: Int): Elem[this.type, n.type] = ${ StagedTuple.applyStaged[this.type, n.type]( - '{this}, constValueOpt[Size[this.type]], - '{n}, constValueOpt[n.type]) } + 'this, constValueOpt[Size[this.type]], + 'n, constValueOpt[n.type]) } } object NonEmptyTuple { diff --git a/tests/disabled/run/i4803d/App_2.scala b/tests/disabled/run/i4803d/App_2.scala index 16324e9a82bf..4b55e7e49634 100644 --- a/tests/disabled/run/i4803d/App_2.scala +++ b/tests/disabled/run/i4803d/App_2.scala @@ -11,7 +11,7 @@ object Test { } inline def power2(x: Double) = { - inline def power(x: Double, inline n: Long) = ${ PowerMacro.powerCode('{x}, n) } + inline def power(x: Double, inline n: Long) = ${ PowerMacro.powerCode('x, n) } power(x, 2) } } diff --git a/tests/disabled/run/i4803d/Macro_1.scala b/tests/disabled/run/i4803d/Macro_1.scala index 5c146d1f2a7b..8070c3180721 100644 --- a/tests/disabled/run/i4803d/Macro_1.scala +++ b/tests/disabled/run/i4803d/Macro_1.scala @@ -3,6 +3,6 @@ import scala.quoted._ object PowerMacro { def powerCode(x: Expr[Double], n: Long): Expr[Double] = if (n == 0) '{1.0} - else if (n % 2 == 0) '{ val y = $x * $x; ${powerCode('{y}, n / 2)} } + else if (n % 2 == 0) '{ val y = $x * $x; ${powerCode('y, n / 2)} } else '{ $x * ${powerCode(x, n - 1)} } } diff --git a/tests/disabled/run/xml-interpolation-3/XmlQuote_1.scala b/tests/disabled/run/xml-interpolation-3/XmlQuote_1.scala index 9091d2987bd3..4a6c7f2c80b2 100644 --- a/tests/disabled/run/xml-interpolation-3/XmlQuote_1.scala +++ b/tests/disabled/run/xml-interpolation-3/XmlQuote_1.scala @@ -9,7 +9,7 @@ object XmlQuote { implicit object SCOps { inline def xml(this inline ctx: StringContext)(args: => Any*): Xml = - ${XmlQuote.impl(ctx, '{args})} + ${XmlQuote.impl(ctx, 'args)} } def impl(receiver: StringContext, args: Expr[Seq[Any]]): Expr[Xml] = { diff --git a/tests/neg-with-compiler/quote-run-in-macro-1/quoted_1.scala b/tests/neg-with-compiler/quote-run-in-macro-1/quoted_1.scala index 093b8e8f5849..883c2de12f44 100644 --- a/tests/neg-with-compiler/quote-run-in-macro-1/quoted_1.scala +++ b/tests/neg-with-compiler/quote-run-in-macro-1/quoted_1.scala @@ -3,7 +3,7 @@ import scala.quoted._ import scala.quoted.Toolbox.Default._ object Macros { - inline def foo(i: => Int): Int = ${ fooImpl('{i}) } + inline def foo(i: => Int): Int = ${ fooImpl('i) } def fooImpl(i: Expr[Int]): Expr[Int] = { val y: Int = i.run y.toExpr diff --git a/tests/neg-with-compiler/quote-run-in-macro-2/quoted_1.scala b/tests/neg-with-compiler/quote-run-in-macro-2/quoted_1.scala index 093b8e8f5849..883c2de12f44 100644 --- a/tests/neg-with-compiler/quote-run-in-macro-2/quoted_1.scala +++ b/tests/neg-with-compiler/quote-run-in-macro-2/quoted_1.scala @@ -3,7 +3,7 @@ import scala.quoted._ import scala.quoted.Toolbox.Default._ object Macros { - inline def foo(i: => Int): Int = ${ fooImpl('{i}) } + inline def foo(i: => Int): Int = ${ fooImpl('i) } def fooImpl(i: Expr[Int]): Expr[Int] = { val y: Int = i.run y.toExpr diff --git a/tests/neg/i4433.scala b/tests/neg/i4433.scala index 6641fa19849e..7da5fadcc7ad 100644 --- a/tests/neg/i4433.scala +++ b/tests/neg/i4433.scala @@ -1,7 +1,7 @@ object Foo { inline def g(inline p: Int => Boolean): Boolean = ${ // error - if(p(5)) '{true} - else '{false} + if(p(5)) 'true + else 'false } } diff --git a/tests/neg/i4774b.scala b/tests/neg/i4774b.scala index 9f01ba3f0bb5..1f9c16cb1bd5 100644 --- a/tests/neg/i4774b.scala +++ b/tests/neg/i4774b.scala @@ -5,7 +5,7 @@ object Test { def loop[T](x: Expr[T])(implicit t: Type[T]): Expr[T] = '{ val y: $t = $x; ${loop[$t]( // error - '{y} + 'y )} } } diff --git a/tests/neg/i4890.scala b/tests/neg/i4890.scala index 54a738f5486d..d809c54e3a5f 100644 --- a/tests/neg/i4890.scala +++ b/tests/neg/i4890.scala @@ -3,6 +3,6 @@ import scala.quoted._ object Test { def toExpr(x: Option[String]): Expr[String] = x match { case Some(s) => - '{s} // error + 's // error } } diff --git a/tests/neg/quote-interpolator-core-old.scala b/tests/neg/quote-interpolator-core-old.scala index 6ea1662deef8..d01fc5bc6587 100644 --- a/tests/neg/quote-interpolator-core-old.scala +++ b/tests/neg/quote-interpolator-core-old.scala @@ -5,9 +5,9 @@ import scala.quoted._ object FInterpolation { implicit class FInterpolatorHelper(val sc: StringContext) extends AnyVal { - inline def ff(arg1: Any): String = ${fInterpolation(sc, Seq('{arg1}))} // error: Inline macro method must be a static method - inline def ff(arg1: Any, arg2: Any): String = ${fInterpolation(sc, Seq('{arg1}, '{arg2}))} // error: Inline macro method must be a static method - inline def ff(arg1: Any, arg2: Any, arg3: Any): String = ${fInterpolation(sc, Seq('{arg1}, '{arg2}, '{arg3}))} // error: Inline macro method must be a static method + inline def ff(arg1: Any): String = ${fInterpolation(sc, Seq('arg1))} // error: Inline macro method must be a static method + inline def ff(arg1: Any, arg2: Any): String = ${fInterpolation(sc, Seq('arg1, 'arg2))} // error: Inline macro method must be a static method + inline def ff(arg1: Any, arg2: Any, arg3: Any): String = ${fInterpolation(sc, Seq('arg1, 'arg2, 'arg3))} // error: Inline macro method must be a static method // ... } diff --git a/tests/neg/quote-macro-complex-arg-0.scala b/tests/neg/quote-macro-complex-arg-0.scala index 204ba6daefbd..90e202b21a31 100644 --- a/tests/neg/quote-macro-complex-arg-0.scala +++ b/tests/neg/quote-macro-complex-arg-0.scala @@ -1,6 +1,6 @@ import scala.quoted._ object Macros { - inline def foo(inline i: Int, dummy: Int, j: Int): Int = ${ bar(i + 1, '{j}) } // error: i + 1 is not a parameter or field reference + inline def foo(inline i: Int, dummy: Int, j: Int): Int = ${ bar(i + 1, 'j) } // error: i + 1 is not a parameter or field reference def bar(x: Int, y: Expr[Int]): Expr[Int] = '{ ${x.toExpr} + $y } } diff --git a/tests/neg/quote-macro-splice.scala b/tests/neg/quote-macro-splice.scala index 4eda3cc3e8f3..9125f56159ad 100644 --- a/tests/neg/quote-macro-splice.scala +++ b/tests/neg/quote-macro-splice.scala @@ -14,7 +14,7 @@ object Test { inline def foo3: Int = { // error val a = 1 - ${ impl('{a}) } + ${ impl('a) } } inline def foo4: Int = { // error diff --git a/tests/neg/quote-pcp-in-arg.scala b/tests/neg/quote-pcp-in-arg.scala index 4f59039289c2..d864e84272c1 100644 --- a/tests/neg/quote-pcp-in-arg.scala +++ b/tests/neg/quote-pcp-in-arg.scala @@ -1,6 +1,6 @@ import scala.quoted._ object Foo { - inline def foo(x: Int): Int = ${ bar('{ '{x}; x }) } // error + inline def foo(x: Int): Int = ${ bar('{ 'x; x }) } // error def bar(i: Expr[Int]): Expr[Int] = i } diff --git a/tests/neg/quote-splice-interpret-1.scala b/tests/neg/quote-splice-interpret-1.scala index 1735d6093015..dacd3886f9fd 100644 --- a/tests/neg/quote-splice-interpret-1.scala +++ b/tests/neg/quote-splice-interpret-1.scala @@ -3,7 +3,7 @@ import scala.quoted._ object Macros { inline def isZero(inline n: Int): Boolean = ${ // error - if (n == 0) '{true} - else '{false} + if (n == 0) 'true + else 'false } } diff --git a/tests/neg/quote-this.scala b/tests/neg/quote-this.scala index 58ccc6ff4716..ddfc6961661c 100644 --- a/tests/neg/quote-this.scala +++ b/tests/neg/quote-this.scala @@ -12,11 +12,11 @@ class Foo { } inline def i(): Unit = ${ Foo.impl[Any]('{ - '{this} // error + 'this // error }) } inline def j(that: Foo): Unit = ${ Foo.impl[Any]('{ - '{that} // error + 'that // error }) } inline def k(): Unit = ${ Foo.impl[Any](this) } // error diff --git a/tests/neg/tasty-macro-assert/quoted_1.scala b/tests/neg/tasty-macro-assert/quoted_1.scala index d6a2b7297341..801219e3e78b 100644 --- a/tests/neg/tasty-macro-assert/quoted_1.scala +++ b/tests/neg/tasty-macro-assert/quoted_1.scala @@ -12,7 +12,7 @@ object Asserts { object Ops inline def macroAssert(cond: => Boolean): Unit = - ${impl('{cond})} + ${impl('cond)} def impl(cond: Expr[Boolean])(implicit reflect: Reflection): Expr[Unit] = { import reflect._ diff --git a/tests/pos-with-compiler/quote-0.scala b/tests/pos-with-compiler/quote-0.scala index d6ed376ce9d1..020a62e2516d 100644 --- a/tests/pos-with-compiler/quote-0.scala +++ b/tests/pos-with-compiler/quote-0.scala @@ -5,19 +5,19 @@ import scala.quoted.Toolbox.Default._ object Macros { inline def assert(expr: => Boolean): Unit = - ${ assertImpl('{expr}) } + ${ assertImpl('expr) } def assertImpl(expr: Expr[Boolean]) = '{ if !($expr) then throw new AssertionError(s"failed assertion: ${${showExpr(expr)}}") } def showExpr[T](expr: Expr[T]): Expr[String] = expr.toString.toExpr - inline def power(inline n: Int, x: Double) = ${ powerCode(n, '{x}) } + inline def power(inline n: Int, x: Double) = ${ powerCode(n, 'x) } def powerCode(n: Int, x: Expr[Double]): Expr[Double] = if (n == 0) '{1.0} else if (n == 1) x - else if (n % 2 == 0) '{ { val y = $x * $x; ${ powerCode(n / 2, '{y}) } } } + else if (n % 2 == 0) '{ { val y = $x * $x; ${ powerCode(n / 2, 'y) } } } else '{ $x * ${ powerCode(n - 1, x) } } } diff --git a/tests/pos-with-compiler/quote-assert/quoted_2.scala b/tests/pos-with-compiler/quote-assert/quoted_2.scala index 3e609a53ad10..50d835cace3f 100644 --- a/tests/pos-with-compiler/quote-assert/quoted_2.scala +++ b/tests/pos-with-compiler/quote-assert/quoted_2.scala @@ -5,7 +5,7 @@ import Macros._ object Test { inline def assert(expr: => Boolean): Unit = - ${ assertImpl('{expr}) } + ${ assertImpl('expr) } val program = '{ diff --git a/tests/pos/i3898/quoted_1.scala b/tests/pos/i3898/quoted_1.scala index 675ffc1af2fb..8d2b3d2c5d87 100644 --- a/tests/pos/i3898/quoted_1.scala +++ b/tests/pos/i3898/quoted_1.scala @@ -1,5 +1,5 @@ import scala.quoted._ object Macro { - inline def ff(args: Any*): String = ${impl('{args})} + inline def ff(args: Any*): String = ${impl('args)} def impl(args: Expr[Seq[Any]]): Expr[String] = '{""} } diff --git a/tests/pos/i3898b/quoted_1.scala b/tests/pos/i3898b/quoted_1.scala index b609a0b18f68..fa05e2fc2f93 100644 --- a/tests/pos/i3898b/quoted_1.scala +++ b/tests/pos/i3898b/quoted_1.scala @@ -1,5 +1,5 @@ import scala.quoted._ object Macro { - inline def ff(x: Int, inline y: Int): String = ${impl('{x})} + inline def ff(x: Int, inline y: Int): String = ${impl('x)} def impl(x: Expr[Int]): Expr[String] = '{""} } diff --git a/tests/pos/i3898c/quoted_1.scala b/tests/pos/i3898c/quoted_1.scala index b609a0b18f68..fa05e2fc2f93 100644 --- a/tests/pos/i3898c/quoted_1.scala +++ b/tests/pos/i3898c/quoted_1.scala @@ -1,5 +1,5 @@ import scala.quoted._ object Macro { - inline def ff(x: Int, inline y: Int): String = ${impl('{x})} + inline def ff(x: Int, inline y: Int): String = ${impl('x)} def impl(x: Expr[Int]): Expr[String] = '{""} } diff --git a/tests/pos/i4023/Macro_1.scala b/tests/pos/i4023/Macro_1.scala index 546b28fb9a76..34551e3123fc 100644 --- a/tests/pos/i4023/Macro_1.scala +++ b/tests/pos/i4023/Macro_1.scala @@ -1,5 +1,5 @@ import scala.quoted._ object Macro { - inline def ff[T: Type](x: T): T = ${ impl('{x}) } + inline def ff[T: Type](x: T): T = ${ impl('x) } def impl[T](x: Expr[T]): Expr[T] = x } diff --git a/tests/pos/i4023c/Macro_1.scala b/tests/pos/i4023c/Macro_1.scala index eda769b8dd8f..f21f8a9e9012 100644 --- a/tests/pos/i4023c/Macro_1.scala +++ b/tests/pos/i4023c/Macro_1.scala @@ -1,5 +1,5 @@ import scala.quoted._ object Macro { - inline def ff[T](x: T): T = ${ impl('{x})('[T]) } + inline def ff[T](x: T): T = ${ impl('x)('[T]) } def impl[T](x: Expr[T])(implicit t: Type[T]): Expr[T] = '{ $x: $t } } diff --git a/tests/pos/i4514.scala b/tests/pos/i4514.scala index ee9084eea2de..97388c9334f8 100644 --- a/tests/pos/i4514.scala +++ b/tests/pos/i4514.scala @@ -1,4 +1,4 @@ object Foo { - inline def foo[X](x: X): Unit = ${fooImpl('{x})} + inline def foo[X](x: X): Unit = ${fooImpl('x)} def fooImpl[X: quoted.Type](x: X): quoted.Expr[Unit] = '{} } diff --git a/tests/pos/i4734/Macro_1.scala b/tests/pos/i4734/Macro_1.scala index 71462b7d246b..740b70a134e0 100644 --- a/tests/pos/i4734/Macro_1.scala +++ b/tests/pos/i4734/Macro_1.scala @@ -3,7 +3,7 @@ import scala.quoted._ object Macros { inline def unrolledForeach(f: Int => Int): Int = - ${unrolledForeachImpl('{f})} + ${unrolledForeachImpl('f)} def unrolledForeachImpl(f: Expr[Int => Int]): Expr[Int] = '{ val size: Int = 5 diff --git a/tests/pos/i4774a.scala b/tests/pos/i4774a.scala index da92ac562fd4..d8ceda47f7e2 100644 --- a/tests/pos/i4774a.scala +++ b/tests/pos/i4774a.scala @@ -4,6 +4,6 @@ import scala.quoted._ object Test { def loop[T](x: Expr[T])(implicit t: Type[T]): Expr[T] = '{ val y: $t = $x - ${loop('{y})} + ${loop('y)} } } diff --git a/tests/pos/i4774c.scala b/tests/pos/i4774c.scala index 417baba571b9..a67e8abc444e 100644 --- a/tests/pos/i4774c.scala +++ b/tests/pos/i4774c.scala @@ -2,5 +2,5 @@ import scala.quoted._ object Test { - def loop[T](x: Expr[T])(implicit t: Type[T]): Expr[T] = '{ val y = $x; ${loop('{y})} } + def loop[T](x: Expr[T])(implicit t: Type[T]): Expr[T] = '{ val y = $x; ${loop('y)} } } diff --git a/tests/pos/i4774d.scala b/tests/pos/i4774d.scala index 87b48343349a..6ab3239b6625 100644 --- a/tests/pos/i4774d.scala +++ b/tests/pos/i4774d.scala @@ -3,5 +3,5 @@ import scala.quoted._ object Test { def loop[T](x: Expr[T])(implicit t: Type[T]): Expr[T] = - '{ val y: T = $x; ${loop('{y})} } + '{ val y: T = $x; ${loop('y)} } } diff --git a/tests/pos/i4774e.scala b/tests/pos/i4774e.scala index 9d5118aec02c..35ee2dfea9ab 100644 --- a/tests/pos/i4774e.scala +++ b/tests/pos/i4774e.scala @@ -3,7 +3,7 @@ import scala.quoted._ object Test { def loop[T](x: Expr[T])(implicit t: Type[T]): Expr[T] = - '{ def y = $x; ${ loop('{y}) } } + '{ def y = $x; ${ loop('y) } } def loop2[T](x: Expr[T])(implicit t: Type[T]): Expr[T] = '{ def y() = $x; ${ loop('{y()}) } } diff --git a/tests/pos/i4774f.scala b/tests/pos/i4774f.scala index c4bd2bd16aba..c9b76b1b3688 100644 --- a/tests/pos/i4774f.scala +++ b/tests/pos/i4774f.scala @@ -3,7 +3,7 @@ import scala.quoted._ object Test { def loop[T](x: Expr[T])(implicit t: Type[T]): Expr[T] = - '{ def y: T = $x; ${ loop('{y}) } } + '{ def y: T = $x; ${ loop('y) } } def loop2[T](x: Expr[T])(implicit t: Type[T]): Expr[T] = '{ def y(): T = $x; ${ loop('{y()}) } } diff --git a/tests/pos/i4846.scala b/tests/pos/i4846.scala index 87d6fa76849a..a8007c29b7dd 100644 --- a/tests/pos/i4846.scala +++ b/tests/pos/i4846.scala @@ -1,6 +1,6 @@ import scala.quoted._ object Test { - inline def foo(inline x: Int): Int = ${fooImpl(x, '{x}, '{ '{x} }, '{ '{ '{x} } })} + inline def foo(inline x: Int): Int = ${fooImpl(x, 'x, '{ 'x }, '{ '{ 'x } })} def fooImpl(a: Int, b: Expr[Int], c: Expr[Expr[Int]], d: Expr[Expr[Expr[Int]]]): Expr[Int] = ??? } diff --git a/tests/pos/power-macro/Macro_1.scala b/tests/pos/power-macro/Macro_1.scala index 375332b253a2..53179247dd66 100644 --- a/tests/pos/power-macro/Macro_1.scala +++ b/tests/pos/power-macro/Macro_1.scala @@ -3,10 +3,10 @@ import scala.quoted.Expr object PowerMacro { - inline def power(inline n: Long, x: Double) = ${powerCode(n, '{x})} + inline def power(inline n: Long, x: Double) = ${powerCode(n, 'x)} def powerCode(n: Long, x: Expr[Double]): Expr[Double] = if (n == 0) '{1.0} - else if (n % 2 == 0) '{ { val y = $x * $x; ${powerCode(n / 2, '{y})} } } + else if (n % 2 == 0) '{ { val y = $x * $x; ${powerCode(n / 2, 'y)} } } else '{ $x * ${powerCode(n - 1, x)} } } diff --git a/tests/pos/quote-lift-inline-params-b.scala b/tests/pos/quote-lift-inline-params-b.scala index 49507ffa9d27..fd8d0ad25024 100644 --- a/tests/pos/quote-lift-inline-params-b.scala +++ b/tests/pos/quote-lift-inline-params-b.scala @@ -2,6 +2,6 @@ import scala.quoted.Expr import quoted.Liftable.{IntIsLiftable => _} object Macro { inline def foo(inline n: Int): Int = ${ - '{n} + 'n } } \ No newline at end of file diff --git a/tests/pos/quote-lift-inline-params/Macro_1.scala b/tests/pos/quote-lift-inline-params/Macro_1.scala index 19c8b65384e1..980c493558f8 100644 --- a/tests/pos/quote-lift-inline-params/Macro_1.scala +++ b/tests/pos/quote-lift-inline-params/Macro_1.scala @@ -2,6 +2,6 @@ import scala.quoted.Expr object Macro { import quoted.Liftable.{IntIsLiftable => _} inline def foo(inline n: Int): Int = ${ - '{n} + 'n } } \ No newline at end of file diff --git a/tests/pos/quote-nested-object/Macro_1.scala b/tests/pos/quote-nested-object/Macro_1.scala index 1ee308d1297a..cf5fdce507b4 100644 --- a/tests/pos/quote-nested-object/Macro_1.scala +++ b/tests/pos/quote-nested-object/Macro_1.scala @@ -6,7 +6,7 @@ object Macro { object Implementation { - inline def plus(inline n: Int, m: Int): Int = ${ plus(n, '{m}) } + inline def plus(inline n: Int, m: Int): Int = ${ plus(n, 'm) } def plus(n: Int, m: Expr[Int]): Expr[Int] = if (n == 0) m @@ -14,7 +14,7 @@ object Macro { object Implementation2 { - inline def plus(inline n: Int, m: Int): Int = ${ plus(n, '{m}) } + inline def plus(inline n: Int, m: Int): Int = ${ plus(n, 'm) } def plus(n: Int, m: Expr[Int]): Expr[Int] = if (n == 0) m diff --git a/tests/pos/quote-this.scala b/tests/pos/quote-this.scala index 197d3e44e31b..b06e30b29b69 100644 --- a/tests/pos/quote-this.scala +++ b/tests/pos/quote-this.scala @@ -18,7 +18,7 @@ class Foo { } inline def g(): Unit = ${ Foo.impl[this.type](1) } - inline def h(): Unit = ${ Foo.impl[Any]('{this}) } + inline def h(): Unit = ${ Foo.impl[Any]('this) } inline def i(that: Foo): Unit = ${ Foo.impl[that.type](1) } } diff --git a/tests/run-custom-args/Yretain-trees/tasty-definitions-2/Macro_1.scala b/tests/run-custom-args/Yretain-trees/tasty-definitions-2/Macro_1.scala index 1ce3115c1f19..f3c519c1490f 100644 --- a/tests/run-custom-args/Yretain-trees/tasty-definitions-2/Macro_1.scala +++ b/tests/run-custom-args/Yretain-trees/tasty-definitions-2/Macro_1.scala @@ -4,7 +4,7 @@ import scala.tasty._ object Foo { inline def inspectBody(i: => Int): String = - ${ inspectBodyImpl('{i}) } + ${ inspectBodyImpl('i) } def inspectBodyImpl(x: Expr[Int])(implicit reflect: Reflection): Expr[String] = { import reflect._ diff --git a/tests/run-custom-args/Yretain-trees/tasty-definitions-3/Macro_1.scala b/tests/run-custom-args/Yretain-trees/tasty-definitions-3/Macro_1.scala index 5c8a70abad71..a491db7ae672 100644 --- a/tests/run-custom-args/Yretain-trees/tasty-definitions-3/Macro_1.scala +++ b/tests/run-custom-args/Yretain-trees/tasty-definitions-3/Macro_1.scala @@ -4,7 +4,7 @@ import scala.tasty._ object Foo { inline def inspectBody(i: => Int): String = - ${ inspectBodyImpl('{i}) } + ${ inspectBodyImpl('i) } def inspectBodyImpl(x: Expr[Int])(implicit reflect: Reflection): Expr[String] = { import reflect._ diff --git a/tests/run-custom-args/Yretain-trees/tasty-extractors-owners/quoted_1.scala b/tests/run-custom-args/Yretain-trees/tasty-extractors-owners/quoted_1.scala index da3eadb062fd..8825ed30d64c 100644 --- a/tests/run-custom-args/Yretain-trees/tasty-extractors-owners/quoted_1.scala +++ b/tests/run-custom-args/Yretain-trees/tasty-extractors-owners/quoted_1.scala @@ -5,7 +5,7 @@ import scala.tasty._ object Macros { implicit inline def printOwners[T](x: => T): Unit = - ${ impl('{x}) } + ${ impl('x) } def impl[T](x: Expr[T])(implicit reflect: Reflection): Expr[Unit] = { import reflect._ diff --git a/tests/run-custom-args/Yretain-trees/tasty-load-tree-1/quoted_1.scala b/tests/run-custom-args/Yretain-trees/tasty-load-tree-1/quoted_1.scala index 471371ca32bf..d286b1d30bdc 100644 --- a/tests/run-custom-args/Yretain-trees/tasty-load-tree-1/quoted_1.scala +++ b/tests/run-custom-args/Yretain-trees/tasty-load-tree-1/quoted_1.scala @@ -5,7 +5,7 @@ import scala.tasty._ object Foo { inline def inspectBody(i: => Int): String = - ${ inspectBodyImpl('{i}) } + ${ inspectBodyImpl('i) } def inspectBodyImpl(x: Expr[Int])(implicit reflect: Reflection): Expr[String] = { import reflect._ diff --git a/tests/run-custom-args/Yretain-trees/tasty-load-tree-2/quoted_1.scala b/tests/run-custom-args/Yretain-trees/tasty-load-tree-2/quoted_1.scala index 9169c3ca2777..6c7c985c935f 100644 --- a/tests/run-custom-args/Yretain-trees/tasty-load-tree-2/quoted_1.scala +++ b/tests/run-custom-args/Yretain-trees/tasty-load-tree-2/quoted_1.scala @@ -5,7 +5,7 @@ import scala.tasty._ object Foo { inline def inspectBody(i: => Int): String = - ${ inspectBodyImpl('{i}) } + ${ inspectBodyImpl('i) } def inspectBodyImpl(x: Expr[Int])(implicit reflect: Reflection): Expr[String] = { import reflect._ diff --git a/tests/run-with-compiler-custom-args/staged-streams_1.scala b/tests/run-with-compiler-custom-args/staged-streams_1.scala index dcb6f1bdb922..19090889d7bf 100644 --- a/tests/run-with-compiler-custom-args/staged-streams_1.scala +++ b/tests/run-with-compiler-custom-args/staged-streams_1.scala @@ -18,7 +18,7 @@ object Test { ${ body( new Var[T] { - def get: Expr[T] = '{x} + def get: Expr[T] = 'x def update(e: Expr[T]): Expr[Unit] = '{ x = $e } } ) @@ -460,12 +460,12 @@ object Test { ${producer.step(st, k)} } else { - ${nadv.update('{oldnadv})} + ${nadv.update('oldnadv)} oldnadv(()) } }} - ${nadv.update('{adv1})} + ${nadv.update('adv1)} adv1(()) }) } @@ -497,7 +497,7 @@ object Test { } } - ${nadv.update('{adv})} + ${nadv.update('adv)} adv(()) ${k((hasNext, curr, nadv))} }} @@ -511,7 +511,7 @@ object Test { var el = ${current.get} val f: Unit => Unit = ${nadv.get} f(()) - ${k('{el})} + ${k('el)} } } @@ -609,7 +609,7 @@ object Test { '{ val el = ($arr).apply(${i.get}) ${i.update('{ ${i.get} + 1 })} - ${k('{el})} + ${k('el)} } } diff --git a/tests/run-with-compiler/i4044b.scala b/tests/run-with-compiler/i4044b.scala index 52de2ab072b4..e9e474a73934 100644 --- a/tests/run-with-compiler/i4044b.scala +++ b/tests/run-with-compiler/i4044b.scala @@ -13,7 +13,7 @@ object VarRef { ${body( new VarRef { def update(e: Expr[T]): Expr[Unit] = '{ x = $e } - def expr: Expr[T] = '{x} + def expr: Expr[T] = 'x } )} } diff --git a/tests/run-with-compiler/i5144.scala b/tests/run-with-compiler/i5144.scala index 8bb1dc05cefe..316e7c6ca055 100644 --- a/tests/run-with-compiler/i5144.scala +++ b/tests/run-with-compiler/i5144.scala @@ -6,7 +6,7 @@ object Test { def eval1(ff: Expr[Int => Int]): Expr[Int] = '{$ff(42)} def peval1(): Expr[Unit] = '{ - def f(x: Int): Int = ${eval1('{f})} + def f(x: Int): Int = ${eval1('f)} } def main(args: Array[String]): Unit = { diff --git a/tests/run-with-compiler/i5144b.scala b/tests/run-with-compiler/i5144b.scala index 63d2ff6958a7..1ba60137ebd1 100644 --- a/tests/run-with-compiler/i5144b.scala +++ b/tests/run-with-compiler/i5144b.scala @@ -6,7 +6,7 @@ object Test { def eval1(ff: Expr[Int => Int]): Expr[Int] = ff('{42}) def peval1(): Expr[Unit] = '{ - def f(x: Int): Int = ${eval1('{f})} + def f(x: Int): Int = ${eval1('f)} } def main(args: Array[String]): Unit = { diff --git a/tests/run-with-compiler/quote-ackermann-1.scala b/tests/run-with-compiler/quote-ackermann-1.scala index 998c045cfa14..e22d07173014 100644 --- a/tests/run-with-compiler/quote-ackermann-1.scala +++ b/tests/run-with-compiler/quote-ackermann-1.scala @@ -15,7 +15,7 @@ object Test { def ackermann(m: Int): Expr[Int => Int] = { if (m == 0) '{ n => n + 1 } else '{ n => - def `ackermann(m-1)`(n: Int): Int = ${ackermann(m - 1)('{n})} // Expr[Int => Int] applied to Expr[Int] + def `ackermann(m-1)`(n: Int): Int = ${ackermann(m - 1)('n)} // Expr[Int => Int] applied to Expr[Int] def `ackermann(m)`(n: Int): Int = if (n == 0) `ackermann(m-1)`(1) else `ackermann(m-1)`(`ackermann(m)`(n - 1)) `ackermann(m)`(n) diff --git a/tests/run-with-compiler/quote-fun-app-1.scala b/tests/run-with-compiler/quote-fun-app-1.scala index 26237222f630..890de0d14987 100644 --- a/tests/run-with-compiler/quote-fun-app-1.scala +++ b/tests/run-with-compiler/quote-fun-app-1.scala @@ -10,8 +10,8 @@ object Test { println(f(43)) } - def f1: Expr[Int => Int] = '{ n => ${f2('{n})} } - def f2: Expr[Int => Int] = '{ n => ${f3('{n})} } - def f3: Expr[Int => Int] = '{ n => ${f4('{n})} } + def f1: Expr[Int => Int] = '{ n => ${f2('n)} } + def f2: Expr[Int => Int] = '{ n => ${f3('n)} } + def f3: Expr[Int => Int] = '{ n => ${f4('n)} } def f4: Expr[Int => Int] = '{ n => n } } diff --git a/tests/run-with-compiler/quote-impure-by-name/quoted_1.scala b/tests/run-with-compiler/quote-impure-by-name/quoted_1.scala index 2996918546d3..550e34b96b04 100644 --- a/tests/run-with-compiler/quote-impure-by-name/quoted_1.scala +++ b/tests/run-with-compiler/quote-impure-by-name/quoted_1.scala @@ -9,7 +9,7 @@ object Index { implicit def zero[K, T]: Index[K, (K, T)] = new Index("0") - implicit inline def succ[K, H, T](implicit prev: => Index[K, T]): Index[K, (H, T)] = ${ succImpl('{prev})('[K], '[H], '[T]) } + implicit inline def succ[K, H, T](implicit prev: => Index[K, T]): Index[K, (H, T)] = ${ succImpl('prev)('[K], '[H], '[T]) } def succImpl[K, H, T](prev: Expr[Index[K, T]])(implicit k: Type[K], h: Type[H], t: Type[T]): Expr[Index[K, (H, T)]] = { val value = s"1 + {${prev.show}}" diff --git a/tests/run-with-compiler/quote-inline-function/quoted_1.scala b/tests/run-with-compiler/quote-inline-function/quoted_1.scala index b9c9d29f1456..1a17e4f114e5 100644 --- a/tests/run-with-compiler/quote-inline-function/quoted_1.scala +++ b/tests/run-with-compiler/quote-inline-function/quoted_1.scala @@ -4,19 +4,19 @@ import scala.quoted.Toolbox.Default._ object Macros { - inline def foreach1(start: Int, end: Int, f: Int => Unit): String = ${impl('{start}, '{end}, '{f})} - inline def foreach2(start: Int, end: Int, f: => Int => Unit): String = ${impl('{start}, '{end}, '{f})} + inline def foreach1(start: Int, end: Int, f: Int => Unit): String = ${impl('start, 'end, 'f)} + inline def foreach2(start: Int, end: Int, f: => Int => Unit): String = ${impl('start, 'end, 'f)} def impl(start: Expr[Int], end: Expr[Int], f: Expr[Int => Unit]): Expr[String] = { val res = '{ var i = $start val j = $end while (i < j) { - ${f.apply('{i})} + ${f.apply('i)} i += 1 } do { - ${f.apply('{i})} + ${f.apply('i)} i += 1 } while (i < j) } diff --git a/tests/run-with-compiler/quote-lambda.scala b/tests/run-with-compiler/quote-lambda.scala index 694d69238e98..c904c3676a61 100644 --- a/tests/run-with-compiler/quote-lambda.scala +++ b/tests/run-with-compiler/quote-lambda.scala @@ -2,6 +2,6 @@ import scala.quoted._ object Test { def main(args: Array[String]): Unit = { - '{ (x: Int) => ${'{x}} } + '{ (x: Int) => ${'x} } } } diff --git a/tests/run-with-compiler/quote-lib.scala b/tests/run-with-compiler/quote-lib.scala index 133102603bc5..c595684fb7f7 100644 --- a/tests/run-with-compiler/quote-lib.scala +++ b/tests/run-with-compiler/quote-lib.scala @@ -60,11 +60,11 @@ package liftable { object Lets { def letVal[T, U: Type](expr: Expr[T])(body: Expr[T] => Expr[U])(implicit t: Type[T]): Expr[U] = - '{ val letVal: $t = $expr; ${ body('{letVal}) } } + '{ val letVal: $t = $expr; ${ body('letVal) } } def letLazyVal[T, U: Type](expr: Expr[T])(body: Expr[T] => Expr[U])(implicit t: Type[T]): Expr[U] = - '{ lazy val letLazyVal: $t = $expr; ${ body('{letLazyVal}) } } + '{ lazy val letLazyVal: $t = $expr; ${ body('letLazyVal) } } def letDef[T, U: Type](expr: Expr[T])(body: Expr[T] => Expr[U])(implicit t: Type[T]): Expr[U] = - '{ def letDef: $t = $expr; ${ body('{letDef}) } } + '{ def letDef: $t = $expr; ${ body('letDef) } } } object Loops { diff --git a/tests/run-with-compiler/quote-nested-3.scala b/tests/run-with-compiler/quote-nested-3.scala index d6139c4ba53c..de5248a669c8 100644 --- a/tests/run-with-compiler/quote-nested-3.scala +++ b/tests/run-with-compiler/quote-nested-3.scala @@ -8,7 +8,7 @@ object Test { type T = String val x = "foo" ${ - val y = '{x} + val y = 'x '{ val z: T = $y } } x diff --git a/tests/run-with-compiler/quote-run-2.scala b/tests/run-with-compiler/quote-run-2.scala index 145ac068cc04..fcbbf576e03f 100644 --- a/tests/run-with-compiler/quote-run-2.scala +++ b/tests/run-with-compiler/quote-run-2.scala @@ -10,7 +10,7 @@ object Test { def powerCode(n: Int, x: Expr[Double]): Expr[Double] = if (n == 0) '{1.0} else if (n == 1) x - else if (n % 2 == 0) '{ { val y = $x * $x; ${powerCode(n / 2, '{y})} } } + else if (n % 2 == 0) '{ { val y = $x * $x; ${powerCode(n / 2, 'y)} } } else '{ $x * ${powerCode(n - 1, x)} } println(powerCode(0, '{5}).show) diff --git a/tests/run-with-compiler/quote-run-staged-interpreter.scala b/tests/run-with-compiler/quote-run-staged-interpreter.scala index 216e179442d4..d60c58fc31e3 100644 --- a/tests/run-with-compiler/quote-run-staged-interpreter.scala +++ b/tests/run-with-compiler/quote-run-staged-interpreter.scala @@ -19,7 +19,7 @@ object Test { case Var(x) => env(x) case Let(x, e, body) => if (keepLets) - '{ val y = ${compileImpl(e, env)}; ${compileImpl(body, env + (x -> '{y})) } } + '{ val y = ${compileImpl(e, env)}; ${compileImpl(body, env + (x -> 'y)) } } else compileImpl(body, env + (x -> compileImpl(e, env))) } @@ -31,7 +31,7 @@ object Test { val exp = Plus(Plus(Num(2), Var("x")), Num(4)) val letExp = Let("x", Num(3), exp) - val res1 = '{ (x: Int) => ${compile(exp, Map("x" -> '{x}), false)} } + val res1 = '{ (x: Int) => ${compile(exp, Map("x" -> 'x), false)} } println(res1.show) diff --git a/tests/run-with-compiler/quote-two-captured-ref.scala b/tests/run-with-compiler/quote-two-captured-ref.scala index 1f4687489a2c..dc8f2ec3f0f8 100644 --- a/tests/run-with-compiler/quote-two-captured-ref.scala +++ b/tests/run-with-compiler/quote-two-captured-ref.scala @@ -8,8 +8,8 @@ object Test { val x = 1 println(${ println(1) - val a = '{x} - val b = '{x} + val a = 'x + val b = 'x '{ $a + $b } }) } diff --git a/tests/run-with-compiler/quote-type-tags.scala b/tests/run-with-compiler/quote-type-tags.scala index dc33751495d3..70c2326aad42 100644 --- a/tests/run-with-compiler/quote-type-tags.scala +++ b/tests/run-with-compiler/quote-type-tags.scala @@ -8,7 +8,7 @@ object Test { '{$x.asInstanceOf[$t]} println(asof('{}, '[Unit]).show) - println(asof('{true}, '[Boolean]).show) + println(asof('true, '[Boolean]).show) println(asof('{0.toByte}, '[Byte]).show) println(asof('{ 'a' }, '[Char]).show) println(asof('{1.toShort}, '[Short]).show) diff --git a/tests/run-with-compiler/quote-unrolled-foreach.scala b/tests/run-with-compiler/quote-unrolled-foreach.scala index 49ef60b3c1f7..4dc8f56cf628 100644 --- a/tests/run-with-compiler/quote-unrolled-foreach.scala +++ b/tests/run-with-compiler/quote-unrolled-foreach.scala @@ -5,27 +5,27 @@ object Test { implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make def main(args: Array[String]): Unit = { - val code1 = '{ (arr: Array[Int], f: Int => Unit) => ${ foreach1('{arr}, '{f}) } } + val code1 = '{ (arr: Array[Int], f: Int => Unit) => ${ foreach1('arr, 'f) } } println(code1.show) println() - val code1Tpe = '{ (arr: Array[String], f: String => Unit) => ${ foreach1Tpe1('{arr}, '{f}) } } + val code1Tpe = '{ (arr: Array[String], f: String => Unit) => ${ foreach1Tpe1('arr, 'f) } } println(code1Tpe.show) println() - val code1Tpe2 = '{ (arr: Array[String], f: String => Unit) => ${ foreach1Tpe1('{arr}, '{f}) } } + val code1Tpe2 = '{ (arr: Array[String], f: String => Unit) => ${ foreach1Tpe1('arr, 'f) } } println(code1Tpe2.show) println() - val code2 = '{ (arr: Array[Int]) => ${ foreach1('{arr}, '{i => System.out.println(i)}) } } + val code2 = '{ (arr: Array[Int]) => ${ foreach1('arr, '{i => System.out.println(i)}) } } println(code2.show) println() - val code3 = '{ (arr: Array[Int], f: Int => Unit) => ${ foreach3('{arr}, '{f}) } } + val code3 = '{ (arr: Array[Int], f: Int => Unit) => ${ foreach3('arr, 'f) } } println(code3.show) println() - val code4 = '{ (arr: Array[Int], f: Int => Unit) => ${ foreach4('{arr}, '{f}, 4) } } + val code4 = '{ (arr: Array[Int], f: Int => Unit) => ${ foreach4('arr, 'f, 4) } } println(code4.show) println() @@ -36,7 +36,7 @@ object Test { def printAll(arr: Array[Int]) = '{ val arr1 = ${ arr.toExpr } - ${ foreach1('{arr1}, '{x => println(x)}) } + ${ foreach1('arr1, '{x => println(x)}) } } println(printAll(Array(1, 3, 4, 5)).show) @@ -78,7 +78,7 @@ object Test { var i = 0 while (i < size) { val element = ($arrRef)(i) - ${ f('{element}) } // Use AppliedFuntion + ${ f('element) } // Use AppliedFuntion i += 1 } } diff --git a/tests/run-with-compiler/quote-var.scala b/tests/run-with-compiler/quote-var.scala index 88a1f13386e9..895e8ca67b4f 100644 --- a/tests/run-with-compiler/quote-var.scala +++ b/tests/run-with-compiler/quote-var.scala @@ -13,7 +13,7 @@ object Test { ${ body( new Var { - def get: Expr[String] = '{x} + def get: Expr[String] = 'x def update(e: Expr[String]): Expr[Unit] = '{ x = $e } } ) diff --git a/tests/run-with-compiler/reflect-select-copy/assert_1.scala b/tests/run-with-compiler/reflect-select-copy/assert_1.scala index 0157a8875ae5..7b11c5a55ecb 100644 --- a/tests/run-with-compiler/reflect-select-copy/assert_1.scala +++ b/tests/run-with-compiler/reflect-select-copy/assert_1.scala @@ -3,7 +3,7 @@ import scala.tasty._ object scalatest { - inline def assert(condition: => Boolean): Unit = ${ assertImpl('{condition}, '{""}) } + inline def assert(condition: => Boolean): Unit = ${ assertImpl('condition, '{""}) } def assertImpl(cond: Expr[Boolean], clue: Expr[Any])(implicit refl: Reflection): Expr[Unit] = { import refl._ diff --git a/tests/run-with-compiler/shonan-hmm-simple.scala b/tests/run-with-compiler/shonan-hmm-simple.scala index a372fc0543d8..82bf29ede43a 100644 --- a/tests/run-with-compiler/shonan-hmm-simple.scala +++ b/tests/run-with-compiler/shonan-hmm-simple.scala @@ -102,7 +102,7 @@ class ExprVecOps[T: Type] extends VecOps[Expr[Int], Expr[T]] { var sum = $zero var i = 0 while (i < ${vec.size}) { - sum = ${ plus('{sum}, vec.get('{i})) } + sum = ${ plus('sum, vec.get('i)) } i += 1 } sum diff --git a/tests/run-with-compiler/shonan-hmm/Lifters.scala b/tests/run-with-compiler/shonan-hmm/Lifters.scala index 3098391df61f..eead03f2d15d 100644 --- a/tests/run-with-compiler/shonan-hmm/Lifters.scala +++ b/tests/run-with-compiler/shonan-hmm/Lifters.scala @@ -11,12 +11,12 @@ object Lifters { implicit def ArrayIsLiftable[T : Type: ClassTag](implicit l: Liftable[T]): Liftable[Array[T]] = arr => '{ val array = new Array[T](${arr.length.toExpr})(${implicitly[ClassTag[T]].toExpr}) - ${initArray(arr, '{array})} + ${initArray(arr, 'array)} } implicit def IntArrayIsLiftable: Liftable[Array[Int]] = arr => '{ val array = new Array[Int](${arr.length.toExpr}) - ${initArray(arr, '{array})} + ${initArray(arr, 'array)} } private def initArray[T : Liftable : Type](arr: Array[T], array: Expr[Array[T]]): Expr[Array[T]] = { diff --git a/tests/run-with-compiler/shonan-hmm/MVmult.scala b/tests/run-with-compiler/shonan-hmm/MVmult.scala index 149aadd80b98..7c4198a0622b 100644 --- a/tests/run-with-compiler/shonan-hmm/MVmult.scala +++ b/tests/run-with-compiler/shonan-hmm/MVmult.scala @@ -27,9 +27,9 @@ object MVmult { val n = vout.length val m = v.length ${ - val vout_ = OVec('{n}, (i, x: Expr[Int]) => '{vout($i) = $x}) - val a_ = Vec('{n}, (i: Expr[Int]) => Vec('{m}, (j: Expr[Int]) => '{ a($i)($j) } )) - val v_ = Vec('{m}, (i: Expr[Int]) => '{v($i)}) + val vout_ = OVec('n, (i, x: Expr[Int]) => '{vout($i) = $x}) + val a_ = Vec('n, (i: Expr[Int]) => Vec('m, (j: Expr[Int]) => '{ a($i)($j) } )) + val v_ = Vec('m, (i: Expr[Int]) => '{v($i)}) val MV = new MVmult[Expr[Int], Expr[Int], Expr[Unit]](RingIntExpr, new VecRDyn) MV.mvmult(vout_, a_, v_) @@ -59,7 +59,7 @@ object MVmult { '{ val arr = ${a.toExpr} ${ - val (n, m, a2) = amat1(a, '{arr}) + val (n, m, a2) = amat1(a, 'arr) mvmult_abs0(new RingIntPExpr, new VecRStaDyn(new RingIntPExpr))(n, m, a2) } } @@ -70,7 +70,7 @@ object MVmult { '{ val arr = ${a.toExpr} ${ - val (n, m, a2) = amat1(a, '{arr}) + val (n, m, a2) = amat1(a, 'arr) mvmult_abs0(new RingIntOPExpr, new VecRStaDyn(new RingIntPExpr))(n, m, a2) } } @@ -81,7 +81,7 @@ object MVmult { '{ val arr = ${a.toExpr} ${ - val (n, m, a2) = amat1(a, '{arr}) + val (n, m, a2) = amat1(a, 'arr) mvmult_abs0(new RingIntOPExpr, new VecRStaOptDynInt(new RingIntPExpr))(n, m, a2) } } @@ -108,7 +108,7 @@ object MVmult { loop(i + 1, default :: acc) } else '{ val row = ${a(i).toExpr} - ${ loop(i + 1, '{row} :: acc) } + ${ loop(i + 1, 'row :: acc) } } } loop(0, Nil) diff --git a/tests/run-with-compiler/shonan-hmm/VecOp.scala b/tests/run-with-compiler/shonan-hmm/VecOp.scala index 7f5f9719f3a3..d4764b9f4487 100644 --- a/tests/run-with-compiler/shonan-hmm/VecOp.scala +++ b/tests/run-with-compiler/shonan-hmm/VecOp.scala @@ -16,7 +16,7 @@ class VecDyn extends VecOp[Expr[Int], Expr[Unit]] { def iter: Vec[Expr[Int], Expr[Unit]] => Expr[Unit] = arr => '{ var i = 0 while (i < ${arr.size}) { - ${arr('{i})} + ${arr('i)} i += 1 } } diff --git a/tests/run-with-compiler/shonan-hmm/VecROp.scala b/tests/run-with-compiler/shonan-hmm/VecROp.scala index acfea459dff0..2fab7753e964 100644 --- a/tests/run-with-compiler/shonan-hmm/VecROp.scala +++ b/tests/run-with-compiler/shonan-hmm/VecROp.scala @@ -22,7 +22,7 @@ class VecRDyn[T: Type] extends VecDyn with VecROp[Expr[Int], Expr[T], Expr[Unit] var sum = $zero var i = 0 while (i < ${vec.size}) { - sum = ${ plus('{sum}, vec('{i})) } + sum = ${ plus('sum, vec('i)) } i += 1 } sum diff --git a/tests/run-with-compiler/shonan-hmm/Vmults.scala b/tests/run-with-compiler/shonan-hmm/Vmults.scala index bf8005842c6b..0e3b590f3123 100644 --- a/tests/run-with-compiler/shonan-hmm/Vmults.scala +++ b/tests/run-with-compiler/shonan-hmm/Vmults.scala @@ -25,9 +25,9 @@ object Vmults { (vout, v1, v2) => { val n = vout.length ${ - val vout_ = OVec[Expr[Int], Complex[Expr[Int]], Expr[Unit]]('{n}, (i, v) => '{vout($i) = ${Complex.of_expr_complex(v)}}) - val v1_ = Vec ('{n}, i => Complex.of_complex_expr('{v1($i)})) - val v2_ = Vec ('{n}, i => Complex.of_complex_expr('{v2($i)})) + val vout_ = OVec[Expr[Int], Complex[Expr[Int]], Expr[Unit]]('n, (i, v) => '{vout($i) = ${Complex.of_expr_complex(v)}}) + val v1_ = Vec ('n, i => Complex.of_complex_expr('{v1($i)})) + val v2_ = Vec ('n, i => Complex.of_complex_expr('{v2($i)})) val V = new Vmult[Expr[Int], Complex[Expr[Int]], Expr[Unit]](RingComplex(RingIntExpr), new VecDyn) V.vmult(vout_, v1_, v2_) diff --git a/tests/run-with-compiler/tasty-extractors-constants-2/quoted_1.scala b/tests/run-with-compiler/tasty-extractors-constants-2/quoted_1.scala index 6f92612b3674..61fae32cf121 100644 --- a/tests/run-with-compiler/tasty-extractors-constants-2/quoted_1.scala +++ b/tests/run-with-compiler/tasty-extractors-constants-2/quoted_1.scala @@ -56,7 +56,7 @@ object Macros { def powerCode(n: Int, x: Expr[Double]): Expr[Double] = if (n == 0) '{1.0} else if (n == 1) x - else if (n % 2 == 0) '{ { val y = $x * $x; ${powerCode(n / 2, '{y})} } } + else if (n % 2 == 0) '{ { val y = $x * $x; ${powerCode(n / 2, 'y)} } } else '{ $x * ${powerCode(n - 1, x)} } def dynamicPower(n: Int, x: Double): Double = diff --git a/tests/run-with-compiler/tasty-unsafe-let/quoted_1.scala b/tests/run-with-compiler/tasty-unsafe-let/quoted_1.scala index b6edf050e4df..5116979a3b96 100644 --- a/tests/run-with-compiler/tasty-unsafe-let/quoted_1.scala +++ b/tests/run-with-compiler/tasty-unsafe-let/quoted_1.scala @@ -5,7 +5,7 @@ import scala.tasty._ object Macros { inline def let[T](rhs: T)(body: => T => Unit): Unit = - ${ impl('{rhs}, '{body}) } + ${ impl('rhs, 'body) } private def impl[T](rhs: Expr[T], body: Expr[T => Unit])(implicit reflect: Reflection): Expr[Unit] = { import reflect._ diff --git a/tests/run/f-interpolation-1/FQuote_1.scala b/tests/run/f-interpolation-1/FQuote_1.scala index 4df72b0e27d0..e65c48adc772 100644 --- a/tests/run/f-interpolation-1/FQuote_1.scala +++ b/tests/run/f-interpolation-1/FQuote_1.scala @@ -6,7 +6,7 @@ import scala.language.implicitConversions object FQuote { implicit class SCOps(ctx: StringContext) { - inline def ff(args: => Any*): String = ${impl('{this}, '{args})} + inline def ff(args: => Any*): String = ${impl('this, 'args)} } /*private*/ def impl(receiver: Expr[SCOps], args: Expr[Seq[Any]])(implicit reflect: Reflection): Expr[String] = { diff --git a/tests/run/gestalt-optional-staging/Macro_1.scala b/tests/run/gestalt-optional-staging/Macro_1.scala index 5ff4b5aa277b..005a85c95c31 100644 --- a/tests/run/gestalt-optional-staging/Macro_1.scala +++ b/tests/run/gestalt-optional-staging/Macro_1.scala @@ -7,9 +7,9 @@ final class Optional[+A >: Null](val value: A) extends AnyVal { def get: A = value def isEmpty = value == null - inline def getOrElse[B >: A](alt: => B): B = ${ Optional.getOrElseImpl('{this}, '{alt}) } + inline def getOrElse[B >: A](alt: => B): B = ${ Optional.getOrElseImpl('this, 'alt) } - inline def map[B >: Null](f: A => B): Optional[B] = ${ Optional.mapImpl('{this}, '{f}) } + inline def map[B >: Null](f: A => B): Optional[B] = ${ Optional.mapImpl('this, 'f) } override def toString = if (isEmpty) "" else s"$value" } diff --git a/tests/run/gestalt-type-toolbox-reflect/Macro_1.scala b/tests/run/gestalt-type-toolbox-reflect/Macro_1.scala index 6dffdcd3a940..b66e6b987a3d 100644 --- a/tests/run/gestalt-type-toolbox-reflect/Macro_1.scala +++ b/tests/run/gestalt-type-toolbox-reflect/Macro_1.scala @@ -22,7 +22,7 @@ object TypeToolbox { } /** type associated with the tree */ - inline def typeOf[T, Expected](a: T): Boolean = ${typeOfImpl('{a}, '[Expected])} + inline def typeOf[T, Expected](a: T): Boolean = ${typeOfImpl('a, '[Expected])} private def typeOfImpl(a: Expr[_], expected: Type[_])(implicit reflect: Reflection): Expr[Boolean] = { import reflect._ val res = a.unseal.tpe =:= expected.unseal.tpe diff --git a/tests/run/i4455/Macro_1.scala b/tests/run/i4455/Macro_1.scala index 60950ea035ed..6ec8460328b1 100644 --- a/tests/run/i4455/Macro_1.scala +++ b/tests/run/i4455/Macro_1.scala @@ -1,6 +1,6 @@ import scala.quoted._ object Macros { - inline def foo(inline i: Int): Int = ${ bar('{i}) } + inline def foo(inline i: Int): Int = ${ bar('i) } inline def foo2(inline i: Int): Int = ${ bar('{i + 1}) } diff --git a/tests/run/i4515/Macro_1.scala b/tests/run/i4515/Macro_1.scala index 6d5524e120e6..b392bf410b57 100644 --- a/tests/run/i4515/Macro_1.scala +++ b/tests/run/i4515/Macro_1.scala @@ -1,5 +1,5 @@ object Macro { - inline def foo[X](x: X): Unit = ${fooImpl('{x})} + inline def foo[X](x: X): Unit = ${fooImpl('x)} def fooImpl[X: quoted.Type](x: quoted.Expr[X]): quoted.Expr[Unit] = '{} } diff --git a/tests/run/i4734/Macro_1.scala b/tests/run/i4734/Macro_1.scala index c74ac861444b..361e14bc9cf3 100644 --- a/tests/run/i4734/Macro_1.scala +++ b/tests/run/i4734/Macro_1.scala @@ -3,7 +3,7 @@ import scala.quoted._ object Macros { inline def unrolledForeach(seq: IndexedSeq[Int], f: => Int => Unit, inline unrollSize: Int): Unit = // or f: Int => Unit - ${ unrolledForeachImpl('{seq}, '{f}, unrollSize) } + ${ unrolledForeachImpl('seq, 'f, unrollSize) } def unrolledForeachImpl(seq: Expr[IndexedSeq[Int]], f: Expr[Int => Unit], unrollSize: Int): Expr[Unit] = '{ val size = ($seq).length @@ -14,7 +14,7 @@ object Macros { for (j <- new UnrolledRange(0, unrollSize)) '{ val index = i + ${j.toExpr} val element = ($seq)(index) - ${ f('{element}) } // or `($f)(element)` if `f` should not be inlined + ${ f('element) } // or `($f)(element)` if `f` should not be inlined } } i += ${unrollSize.toExpr} diff --git a/tests/run/i4735/Macro_1.scala b/tests/run/i4735/Macro_1.scala index 189f02331180..3a56c8dfa218 100644 --- a/tests/run/i4735/Macro_1.scala +++ b/tests/run/i4735/Macro_1.scala @@ -4,7 +4,7 @@ import scala.quoted._ object Macro { inline def unrolledForeach(inline unrollSize: Int, seq: Array[Int], f: => Int => Unit): Unit = // or f: Int => Unit - ${ unrolledForeachImpl(unrollSize, '{seq}, '{f}) } + ${ unrolledForeachImpl(unrollSize, 'seq, 'f) } private def unrolledForeachImpl(unrollSize: Int, seq: Expr[Array[Int]], f: Expr[Int => Unit]): Expr[Unit] = '{ val size = ($seq).length @@ -15,7 +15,7 @@ object Macro { ${ for (j <- new UnrolledRange(0, unrollSize)) '{ val element = ($seq)(i + ${j.toExpr}) - ${f('{element})} // or `($f)(element)` if `f` should not be inlined + ${f('element)} // or `($f)(element)` if `f` should not be inlined } } i += ${unrollSize.toExpr} diff --git a/tests/run/i4803/App_2.scala b/tests/run/i4803/App_2.scala index dbe18eb46103..ed7f5caaecae 100644 --- a/tests/run/i4803/App_2.scala +++ b/tests/run/i4803/App_2.scala @@ -1,6 +1,6 @@ class Num2(x: Double) { - inline def power(inline n: Long) = ${ PowerMacro.powerCode('{x}, n) } + inline def power(inline n: Long) = ${ PowerMacro.powerCode('x, n) } } object Test { diff --git a/tests/run/i4803/Macro_1.scala b/tests/run/i4803/Macro_1.scala index c79900f74868..9e1455107699 100644 --- a/tests/run/i4803/Macro_1.scala +++ b/tests/run/i4803/Macro_1.scala @@ -3,10 +3,10 @@ import scala.quoted._ object PowerMacro { def powerCode(x: Expr[Double], n: Long): Expr[Double] = if (n == 0) '{1.0} - else if (n % 2 == 0) '{ val y = $x * $x; ${ powerCode('{y}, n / 2) } } + else if (n % 2 == 0) '{ val y = $x * $x; ${ powerCode('y, n / 2) } } else '{ $x * ${ powerCode(x, n - 1) } } } class Num(x: Double) { - inline def power(inline n: Long) = ${ PowerMacro.powerCode('{x}, n) } + inline def power(inline n: Long) = ${ PowerMacro.powerCode('x, n) } } diff --git a/tests/run/i4803b/App_2.scala b/tests/run/i4803b/App_2.scala index 955341ee4292..ab3fe67df501 100644 --- a/tests/run/i4803b/App_2.scala +++ b/tests/run/i4803b/App_2.scala @@ -2,7 +2,7 @@ class Nums { class Num(x: Double) { - inline def power(inline n: Long) = ${ PowerMacro.powerCode('{x}, n) } + inline def power(inline n: Long) = ${ PowerMacro.powerCode('x, n) } } } diff --git a/tests/run/i4803b/Macro_1.scala b/tests/run/i4803b/Macro_1.scala index cf3f6add0252..48eab25d259b 100644 --- a/tests/run/i4803b/Macro_1.scala +++ b/tests/run/i4803b/Macro_1.scala @@ -3,6 +3,6 @@ import scala.quoted._ object PowerMacro { def powerCode(x: Expr[Double], n: Long): Expr[Double] = if (n == 0) '{1.0} - else if (n % 2 == 0) '{ val y = $x * $x; ${ powerCode('{y}, n / 2) } } + else if (n % 2 == 0) '{ val y = $x * $x; ${ powerCode('y, n / 2) } } else '{ $x * ${ powerCode(x, n - 1) } } } diff --git a/tests/run/i4803c/App_2.scala b/tests/run/i4803c/App_2.scala index 50a1cf267d70..953e4a983999 100644 --- a/tests/run/i4803c/App_2.scala +++ b/tests/run/i4803c/App_2.scala @@ -2,7 +2,7 @@ object Test { def main(args: Array[String]): Unit = { class Num(x: Double) { - inline def power(inline n: Long) = ${ PowerMacro.powerCode('{x}, n) } + inline def power(inline n: Long) = ${ PowerMacro.powerCode('x, n) } } val n = new Num(1.5) println(n.power(0)) @@ -10,7 +10,7 @@ object Test { println(n.power(2)) println(n.power(5)) - inline def power(x: Double, inline n: Long) = ${ PowerMacro.powerCode('{x}, n) } + inline def power(x: Double, inline n: Long) = ${ PowerMacro.powerCode('x, n) } val x: Double = 1.5 diff --git a/tests/run/i4803c/Macro_1.scala b/tests/run/i4803c/Macro_1.scala index 5c146d1f2a7b..8070c3180721 100644 --- a/tests/run/i4803c/Macro_1.scala +++ b/tests/run/i4803c/Macro_1.scala @@ -3,6 +3,6 @@ import scala.quoted._ object PowerMacro { def powerCode(x: Expr[Double], n: Long): Expr[Double] = if (n == 0) '{1.0} - else if (n % 2 == 0) '{ val y = $x * $x; ${powerCode('{y}, n / 2)} } + else if (n % 2 == 0) '{ val y = $x * $x; ${powerCode('y, n / 2)} } else '{ $x * ${powerCode(x, n - 1)} } } diff --git a/tests/run/i4803e/App_2.scala b/tests/run/i4803e/App_2.scala index 515ee43057ad..bd5dcd5c1360 100644 --- a/tests/run/i4803e/App_2.scala +++ b/tests/run/i4803e/App_2.scala @@ -10,5 +10,5 @@ object Test { println(power2(x3)) } - inline def power2(x: Double) = ${PowerMacro.power2('{x})} + inline def power2(x: Double) = ${PowerMacro.power2('x)} } diff --git a/tests/run/i4803f/App_2.scala b/tests/run/i4803f/App_2.scala index 515ee43057ad..bd5dcd5c1360 100644 --- a/tests/run/i4803f/App_2.scala +++ b/tests/run/i4803f/App_2.scala @@ -10,5 +10,5 @@ object Test { println(power2(x3)) } - inline def power2(x: Double) = ${PowerMacro.power2('{x})} + inline def power2(x: Double) = ${PowerMacro.power2('x)} } diff --git a/tests/run/i4803f/Macro_1.scala b/tests/run/i4803f/Macro_1.scala index e391752ae48c..25aee2bf00c7 100644 --- a/tests/run/i4803f/Macro_1.scala +++ b/tests/run/i4803f/Macro_1.scala @@ -3,11 +3,11 @@ import scala.quoted._ object PowerMacro { def powerCode(x: Expr[Double], n: Long): Expr[Double] = if (n == 0) '{1.0} - else if (n % 2 == 0) '{ val y = $x * $x; ${powerCode('{y}, n / 2)} } + else if (n % 2 == 0) '{ val y = $x * $x; ${powerCode('y, n / 2)} } else '{ $x * ${powerCode(x, n - 1)} } def power2(x: Expr[Double]) = '{ - inline def power(x: Double): Double = ${powerCode('{x}, 2)} + inline def power(x: Double): Double = ${powerCode('x, 2)} power($x) } } diff --git a/tests/run/i4947e/Test_2.scala b/tests/run/i4947e/Test_2.scala index 295b00a75ea9..13af75fd5009 100644 --- a/tests/run/i4947e/Test_2.scala +++ b/tests/run/i4947e/Test_2.scala @@ -1,6 +1,6 @@ object Test { - inline def assert2(expr: => Boolean): Unit = ${ Macros.assertImpl('{expr}) } + inline def assert2(expr: => Boolean): Unit = ${ Macros.assertImpl('expr) } def main(args: Array[String]): Unit = { val x = 1 diff --git a/tests/run/i4947f/Macro_1.scala b/tests/run/i4947f/Macro_1.scala index 4915c43e57e2..acbf4f25f5a8 100644 --- a/tests/run/i4947f/Macro_1.scala +++ b/tests/run/i4947f/Macro_1.scala @@ -9,6 +9,6 @@ object Macros { println($expr) } - inline def assert2(expr: => Boolean): Unit = ${ Macros.assertImpl('{expr}) } + inline def assert2(expr: => Boolean): Unit = ${ Macros.assertImpl('expr) } } diff --git a/tests/run/i5119/Macro_1.scala b/tests/run/i5119/Macro_1.scala index d6b2728fab03..9c187561aead 100644 --- a/tests/run/i5119/Macro_1.scala +++ b/tests/run/i5119/Macro_1.scala @@ -3,7 +3,7 @@ import scala.tasty.Reflection object Macro { class StringContextOps(sc: => StringContext) { - inline def ff(args: => Any*): String = ${ Macro.impl('{sc}, '{args}) } + inline def ff(args: => Any*): String = ${ Macro.impl('sc, 'args) } } implicit inline def XmlQuote(sc: => StringContext): StringContextOps = new StringContextOps(sc) def impl(sc: Expr[StringContext], args: Expr[Seq[Any]])(implicit reflect: Reflection): Expr[String] = { diff --git a/tests/run/i5533/Macro_1.scala b/tests/run/i5533/Macro_1.scala index afd547f80eda..f4b58630cebf 100644 --- a/tests/run/i5533/Macro_1.scala +++ b/tests/run/i5533/Macro_1.scala @@ -6,7 +6,7 @@ object scalatest { def f(x: Int): Boolean = false def f(x: String): Boolean = true - inline def assert(condition: => Boolean): Unit = ${assertImpl('{condition})} + inline def assert(condition: => Boolean): Unit = ${assertImpl('condition)} def assertImpl(condition: Expr[Boolean])(implicit refl: Reflection): Expr[Unit] = { import refl._ diff --git a/tests/run/i5533b/Macro_1.scala b/tests/run/i5533b/Macro_1.scala index 932ee7bfe374..8c5afb167c15 100644 --- a/tests/run/i5533b/Macro_1.scala +++ b/tests/run/i5533b/Macro_1.scala @@ -5,7 +5,7 @@ object scalatest { def f(x: Int): Int = x def f(x: String): String = x - inline def assert(condition: => Boolean): Unit = ${assertImpl('{condition})} + inline def assert(condition: => Boolean): Unit = ${assertImpl('condition)} def assertImpl(condition: Expr[Boolean])(implicit refl: Reflection): Expr[Unit] = { import refl._ diff --git a/tests/run/i5536/Macro_1.scala b/tests/run/i5536/Macro_1.scala index e9fee636b459..0fe7e9778637 100644 --- a/tests/run/i5536/Macro_1.scala +++ b/tests/run/i5536/Macro_1.scala @@ -2,7 +2,7 @@ import scala.quoted._ import scala.tasty._ object scalatest { - inline def assert(condition: => Boolean): Unit = ${assertImpl('{condition})} + inline def assert(condition: => Boolean): Unit = ${assertImpl('condition)} def assertImpl(condition: Expr[Boolean])(implicit refl: Reflection): Expr[Unit] = { import refl._ diff --git a/tests/run/quote-and-splice/Macros_1.scala b/tests/run/quote-and-splice/Macros_1.scala index 9ef6732de3fc..f74d33359bf4 100644 --- a/tests/run/quote-and-splice/Macros_1.scala +++ b/tests/run/quote-and-splice/Macros_1.scala @@ -8,20 +8,20 @@ object Macros { inline def macro2(inline p: Boolean) = ${ macro2Impl(p) } def macro2Impl(p: Boolean) = if (p) '{3} else '{4} - inline def macro3(n: Int) = ${ macro3Impl('{n}) } + inline def macro3(n: Int) = ${ macro3Impl('n) } def macro3Impl(p: Expr[Int]) = '{ 2 + $p } - inline def macro4(i: Int)(j: Int) = ${ macro4Impl('{i})('{j}) } + inline def macro4(i: Int)(j: Int) = ${ macro4Impl('i)('j) } def macro4Impl(i: Expr[Int])(j: Expr[Int]) = '{ $i + $j } - inline def macro5(i: Int, j: Int) = ${ macro5Impl(j = '{j}, i = '{i}) } + inline def macro5(i: Int, j: Int) = ${ macro5Impl(j = 'j, i = 'i) } def macro5Impl(i: Expr[Int], j: Expr[Int]) = '{ $i + $j } - inline def power(inline n: Int, x: Double) = ${ powerCode(n, '{x}) } + inline def power(inline n: Int, x: Double) = ${ powerCode(n, 'x) } def powerCode(n: Int, x: Expr[Double]): Expr[Double] = if (n == 0) '{1.0} else if (n == 1) x - else if (n % 2 == 0) '{ { val y = $x * $x; ${powerCode(n / 2, '{y})} } } + else if (n % 2 == 0) '{ { val y = $x * $x; ${powerCode(n / 2, 'y)} } } else '{ $x * ${ powerCode(n - 1, x) } } } diff --git a/tests/run/quote-change-owner/Macro_1.scala b/tests/run/quote-change-owner/Macro_1.scala index d94512128858..c388edf03f14 100644 --- a/tests/run/quote-change-owner/Macro_1.scala +++ b/tests/run/quote-change-owner/Macro_1.scala @@ -1,6 +1,6 @@ import scala.quoted._ object Macros { - inline def assert2(expr: => Boolean): Unit = ${ assertImpl('{expr}) } + inline def assert2(expr: => Boolean): Unit = ${ assertImpl('expr) } def assertImpl(expr: Expr[Boolean]) = '{ def foo(): Unit = $expr foo() diff --git a/tests/run/quote-sep-comp-2/Test_2.scala b/tests/run/quote-sep-comp-2/Test_2.scala index 9cf8c197792d..35f9d2cc134e 100644 --- a/tests/run/quote-sep-comp-2/Test_2.scala +++ b/tests/run/quote-sep-comp-2/Test_2.scala @@ -1,7 +1,7 @@ object Test { - inline def assert2(expr: => Boolean): Unit = ${ Macros.assertImpl('{expr}) } + inline def assert2(expr: => Boolean): Unit = ${ Macros.assertImpl('expr) } def main(args: Array[String]): Unit = { val x = 1 diff --git a/tests/run/quote-sep-comp/Macro_1.scala b/tests/run/quote-sep-comp/Macro_1.scala index 055589347f16..e13342ac0dc8 100644 --- a/tests/run/quote-sep-comp/Macro_1.scala +++ b/tests/run/quote-sep-comp/Macro_1.scala @@ -1,5 +1,5 @@ import scala.quoted._ object Macros { - inline def assert2(expr: => Boolean): Unit = ${ assertImpl('{expr}) } + inline def assert2(expr: => Boolean): Unit = ${ assertImpl('expr) } def assertImpl(expr: Expr[Boolean]) = '{ println($expr) } } diff --git a/tests/run/quote-simple-macro/quoted_1.scala b/tests/run/quote-simple-macro/quoted_1.scala index 60c1b1edeec9..66e974d9702e 100644 --- a/tests/run/quote-simple-macro/quoted_1.scala +++ b/tests/run/quote-simple-macro/quoted_1.scala @@ -1,6 +1,6 @@ import scala.quoted._ object Macros { - inline def foo(inline i: Int, dummy: Int, j: Int): Int = ${ bar(i, '{j}) } + inline def foo(inline i: Int, dummy: Int, j: Int): Int = ${ bar(i, 'j) } def bar(x: Int, y: Expr[Int]): Expr[Int] = '{ ${x.toExpr} + $y } } diff --git a/tests/run/quote-unrolled-foreach/quoted_1.scala b/tests/run/quote-unrolled-foreach/quoted_1.scala index e7b3da4e294c..eecf8e094414 100644 --- a/tests/run/quote-unrolled-foreach/quoted_1.scala +++ b/tests/run/quote-unrolled-foreach/quoted_1.scala @@ -4,7 +4,7 @@ import scala.quoted._ object Macro { inline def unrolledForeach(inline unrollSize: Int, seq: Array[Int])(f: => Int => Unit): Unit = // or f: Int => Unit - ${unrolledForeachImpl(unrollSize, '{seq}, '{f})} + ${unrolledForeachImpl(unrollSize, 'seq, 'f)} private def unrolledForeachImpl(unrollSize: Int, seq: Expr[Array[Int]], f: Expr[Int => Unit]): Expr[Unit] = '{ val size = $seq.length diff --git a/tests/run/reflect-select-copy/assert_1.scala b/tests/run/reflect-select-copy/assert_1.scala index 2e6ca7e944ea..56ef7d642d47 100644 --- a/tests/run/reflect-select-copy/assert_1.scala +++ b/tests/run/reflect-select-copy/assert_1.scala @@ -3,7 +3,7 @@ import scala.tasty._ object scalatest { - inline def assert(condition: => Boolean): Unit = ${ assertImpl('{condition}, '{""}) } + inline def assert(condition: => Boolean): Unit = ${ assertImpl('condition, '{""}) } def assertImpl(cond: Expr[Boolean], clue: Expr[Any])(implicit refl: Reflection): Expr[Unit] = { import refl._ diff --git a/tests/run/tasty-argument-tree-1/quoted_1.scala b/tests/run/tasty-argument-tree-1/quoted_1.scala index ec30d619445b..987da2ce9fd0 100644 --- a/tests/run/tasty-argument-tree-1/quoted_1.scala +++ b/tests/run/tasty-argument-tree-1/quoted_1.scala @@ -3,7 +3,7 @@ import scala.tasty._ object Macros { - inline def inspect[T](x: T): Unit = ${ impl('{x}) } + inline def inspect[T](x: T): Unit = ${ impl('x) } def impl[T](x: Expr[T])(implicit reflect: Reflection): Expr[Unit] = { import reflect._ diff --git a/tests/run/tasty-custom-show/quoted_1.scala b/tests/run/tasty-custom-show/quoted_1.scala index 1106081d2078..0011dbc9f5bd 100644 --- a/tests/run/tasty-custom-show/quoted_1.scala +++ b/tests/run/tasty-custom-show/quoted_1.scala @@ -5,7 +5,7 @@ import scala.tasty.Reflection object Macros { implicit inline def printOwners[T](x: => T): Unit = - ${ impl('{x}) } + ${ impl('x) } def impl[T](x: Expr[T])(implicit reflect: Reflection): Expr[Unit] = { import reflect._ diff --git a/tests/run/tasty-eval/quoted_1.scala b/tests/run/tasty-eval/quoted_1.scala index 170dda20d343..e423ec4fdadd 100644 --- a/tests/run/tasty-eval/quoted_1.scala +++ b/tests/run/tasty-eval/quoted_1.scala @@ -5,7 +5,7 @@ import scala.tasty._ object Macros { implicit inline def foo(i: Int): String = - ${ impl('{i}) } + ${ impl('i) } def impl(i: Expr[Int])(implicit reflect: Reflection): Expr[String] = { value(i).toString.toExpr diff --git a/tests/run/tasty-extractors-1/quoted_1.scala b/tests/run/tasty-extractors-1/quoted_1.scala index 9c369361f546..68282ba2840e 100644 --- a/tests/run/tasty-extractors-1/quoted_1.scala +++ b/tests/run/tasty-extractors-1/quoted_1.scala @@ -5,7 +5,7 @@ import scala.tasty._ object Macros { implicit inline def printTree[T](x: => T): Unit = - ${ impl('{x}) } + ${ impl('x) } def impl[T](x: Expr[T])(implicit reflect: Reflection): Expr[Unit] = { import reflect._ diff --git a/tests/run/tasty-extractors-2/quoted_1.scala b/tests/run/tasty-extractors-2/quoted_1.scala index 394c83bf037c..e42a9e991260 100644 --- a/tests/run/tasty-extractors-2/quoted_1.scala +++ b/tests/run/tasty-extractors-2/quoted_1.scala @@ -5,7 +5,7 @@ import scala.tasty._ object Macros { implicit inline def printTree[T](x: => T): Unit = - ${ impl('{x}) } + ${ impl('x) } def impl[T](x: Expr[T])(implicit reflect: Reflection): Expr[Unit] = { import reflect._ diff --git a/tests/run/tasty-extractors-3/quoted_1.scala b/tests/run/tasty-extractors-3/quoted_1.scala index cbf74db9cd7d..4762d885627d 100644 --- a/tests/run/tasty-extractors-3/quoted_1.scala +++ b/tests/run/tasty-extractors-3/quoted_1.scala @@ -5,7 +5,7 @@ import scala.tasty.Reflection object Macros { implicit inline def printTypes[T](x: => T): Unit = - ${impl('{x})} + ${impl('x)} def impl[T](x: Expr[T])(implicit reflect: Reflection): Expr[Unit] = { import reflect._ diff --git a/tests/run/tasty-interpolation-1/Macro.scala b/tests/run/tasty-interpolation-1/Macro.scala index 8bbd1f732013..106ddac78a52 100644 --- a/tests/run/tasty-interpolation-1/Macro.scala +++ b/tests/run/tasty-interpolation-1/Macro.scala @@ -8,9 +8,9 @@ import scala.quoted.Toolbox.Default._ object Macro { class StringContextOps(strCtx: => StringContext) { - inline def s2(args: Any*): String = ${SIntepolator('{strCtx}, '{args})} - inline def raw2(args: Any*): String = ${RawIntepolator('{strCtx}, '{args})} - inline def foo(args: Any*): String = ${FooIntepolator('{strCtx}, '{args})} + inline def s2(args: Any*): String = ${SIntepolator('strCtx, 'args)} + inline def raw2(args: Any*): String = ${RawIntepolator('strCtx, 'args)} + inline def foo(args: Any*): String = ${FooIntepolator('strCtx, 'args)} } implicit inline def SCOps(strCtx: => StringContext): StringContextOps = new StringContextOps(strCtx) } diff --git a/tests/run/tasty-macro-assert/quoted_1.scala b/tests/run/tasty-macro-assert/quoted_1.scala index ea7b121f69f4..feac01ef6173 100644 --- a/tests/run/tasty-macro-assert/quoted_1.scala +++ b/tests/run/tasty-macro-assert/quoted_1.scala @@ -12,7 +12,7 @@ object Asserts { object Ops inline def macroAssert(cond: => Boolean): Unit = - ${impl('{cond})} + ${impl('cond)} def impl(cond: Expr[Boolean])(implicit reflect: Reflection): Expr[Unit] = { import reflect._ diff --git a/tests/run/tasty-macro-const/quoted_1.scala b/tests/run/tasty-macro-const/quoted_1.scala index 73d12d4a3f21..f48da1280d5f 100644 --- a/tests/run/tasty-macro-const/quoted_1.scala +++ b/tests/run/tasty-macro-const/quoted_1.scala @@ -3,7 +3,7 @@ import scala.tasty._ object Macros { - inline def natConst(x: Int): Int = ${ natConstImpl('{x}) } + inline def natConst(x: Int): Int = ${ natConstImpl('x) } def natConstImpl(x: Expr[Int])(implicit reflection: Reflection): Expr[Int] = { import reflection._ diff --git a/tests/run/tasty-original-source/Macros_1.scala b/tests/run/tasty-original-source/Macros_1.scala index 28700f921695..2e04ab6c4091 100644 --- a/tests/run/tasty-original-source/Macros_1.scala +++ b/tests/run/tasty-original-source/Macros_1.scala @@ -3,7 +3,7 @@ import scala.tasty._ object Macros { - implicit inline def withSource(arg: Any): (String, Any) = ${ impl('{arg}) } + implicit inline def withSource(arg: Any): (String, Any) = ${ impl('arg) } private def impl(arg: Expr[Any])(implicit reflect: Reflection): Expr[(String, Any)] = { import reflect._ diff --git a/tests/run/tasty-positioned/quoted_1.scala b/tests/run/tasty-positioned/quoted_1.scala index 8eab35ed86aa..c1c82a7b5231 100644 --- a/tests/run/tasty-positioned/quoted_1.scala +++ b/tests/run/tasty-positioned/quoted_1.scala @@ -9,7 +9,7 @@ case class Positioned[T](value: T, position: Position) object Positioned { - implicit inline def apply[T](x: => T): Positioned[T] = ${impl('{x})} + implicit inline def apply[T](x: => T): Positioned[T] = ${impl('x)} def impl[T](x: Expr[T])(implicit ev: Type[T], reflect: Reflection): Expr[Positioned[T]] = { import reflect.{Position => _, _} diff --git a/tests/run/tasty-seal-method/quoted_1.scala b/tests/run/tasty-seal-method/quoted_1.scala index ba7e250919bf..41cff0a6ccee 100644 --- a/tests/run/tasty-seal-method/quoted_1.scala +++ b/tests/run/tasty-seal-method/quoted_1.scala @@ -5,7 +5,7 @@ import scala.tasty._ object Asserts { inline def zeroLastArgs(x: => Int): Int = - ${ zeroLastArgsImpl('{x}) } + ${ zeroLastArgsImpl('x) } /** Replaces last argument list by 0s */ def zeroLastArgsImpl(x: Expr[Int])(implicit reflect: Reflection): Expr[Int] = { @@ -27,7 +27,7 @@ object Asserts { } inline def zeroAllArgs(x: => Int): Int = - ${ zeroAllArgsImpl('{x}) } + ${ zeroAllArgsImpl('x) } /** Replaces all argument list by 0s */ def zeroAllArgsImpl(x: Expr[Int])(implicit reflect: Reflection): Expr[Int] = { diff --git a/tests/run/tasty-tree-map/quoted_1.scala b/tests/run/tasty-tree-map/quoted_1.scala index f99b077b8a29..af2e7c07a888 100644 --- a/tests/run/tasty-tree-map/quoted_1.scala +++ b/tests/run/tasty-tree-map/quoted_1.scala @@ -3,7 +3,7 @@ import scala.tasty._ object Macros { - implicit inline def identityMaped[T](x: => T): T = ${ impl('{x}) } + implicit inline def identityMaped[T](x: => T): T = ${ impl('x) } def impl[T: Type](x: Expr[T])(implicit reflection: Reflection): Expr[T] = { import reflection._ diff --git a/tests/run/xml-interpolation-1/XmlQuote_1.scala b/tests/run/xml-interpolation-1/XmlQuote_1.scala index 072c42a3c9c5..6986ba42ef8b 100644 --- a/tests/run/xml-interpolation-1/XmlQuote_1.scala +++ b/tests/run/xml-interpolation-1/XmlQuote_1.scala @@ -8,7 +8,7 @@ case class Xml(parts: String, args: List[Any]) object XmlQuote { implicit class SCOps(ctx: StringContext) { - inline def xml(args: => Any*): Xml = ${XmlQuote.impl('{this}, '{args})} + inline def xml(args: => Any*): Xml = ${XmlQuote.impl('this, 'args)} } def impl(receiver: Expr[SCOps], args: Expr[Seq[Any]]) diff --git a/tests/run/xml-interpolation-2/XmlQuote_1.scala b/tests/run/xml-interpolation-2/XmlQuote_1.scala index b6c762f4142f..2d5792a4831f 100644 --- a/tests/run/xml-interpolation-2/XmlQuote_1.scala +++ b/tests/run/xml-interpolation-2/XmlQuote_1.scala @@ -10,7 +10,7 @@ case class Xml(parts: String, args: List[Any]) object XmlQuote { class SCOps(ctx: => StringContext) { - inline def xml(args: Any*): Xml = ${ XmlQuote.impl('{this}, '{args}) } + inline def xml(args: Any*): Xml = ${ XmlQuote.impl('this, 'args) } } implicit inline def SCOps(ctx: => StringContext): SCOps = new SCOps(ctx) diff --git a/tests/run/xml-interpolation-3/XmlQuote_1.scala b/tests/run/xml-interpolation-3/XmlQuote_1.scala index 5316b3589741..eeee5419af37 100644 --- a/tests/run/xml-interpolation-3/XmlQuote_1.scala +++ b/tests/run/xml-interpolation-3/XmlQuote_1.scala @@ -9,7 +9,7 @@ object XmlQuote { implicit object SCOps { inline def (inline ctx: StringContext) xml (args: => Any*): Xml = - ${XmlQuote.impl(ctx, '{args})} + ${XmlQuote.impl(ctx, 'args)} } def impl(receiver: StringContext, args: Expr[Seq[Any]]): Expr[Xml] = { From 3846e49bc7bb53992a243967abe706556b801e4b Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Tue, 19 Feb 2019 17:34:30 +0100 Subject: [PATCH 22/26] Fix test --- tests/run-with-compiler/quote-type-tags.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/run-with-compiler/quote-type-tags.scala b/tests/run-with-compiler/quote-type-tags.scala index 70c2326aad42..dc33751495d3 100644 --- a/tests/run-with-compiler/quote-type-tags.scala +++ b/tests/run-with-compiler/quote-type-tags.scala @@ -8,7 +8,7 @@ object Test { '{$x.asInstanceOf[$t]} println(asof('{}, '[Unit]).show) - println(asof('true, '[Boolean]).show) + println(asof('{true}, '[Boolean]).show) println(asof('{0.toByte}, '[Byte]).show) println(asof('{ 'a' }, '[Char]).show) println(asof('{1.toShort}, '[Short]).show) From ad3f5191158b52b7abf0276d4855ba33bbe0fd69 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Wed, 20 Feb 2019 13:28:35 +0100 Subject: [PATCH 23/26] Revert stdLib213 change after rebase --- community-build/community-projects/stdLib213 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/community-build/community-projects/stdLib213 b/community-build/community-projects/stdLib213 index caba95fa01c6..98710d2160b4 160000 --- a/community-build/community-projects/stdLib213 +++ b/community-build/community-projects/stdLib213 @@ -1 +1 @@ -Subproject commit caba95fa01c6510d0681a4d79e97e79797327bc8 +Subproject commit 98710d2160b40c8302b7b5df1344c1e77bfd9cc6 From b56039240c745c2835a010c6c5cd0f2de30c3ecf Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Thu, 21 Feb 2019 14:45:42 +0100 Subject: [PATCH 24/26] Adapt i5954 tests Adapt splice syntax and modify tests to no cancel quotes and splices before the checks --- tests/neg/i5954.scala | 2 +- tests/pos/i5954.scala | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/neg/i5954.scala b/tests/neg/i5954.scala index e20b33850bdf..73af3b84b2bd 100644 --- a/tests/neg/i5954.scala +++ b/tests/neg/i5954.scala @@ -6,5 +6,5 @@ object MatcherFactory1 { import scala.quoted._ def impl2(a: MatcherFactory1)(self: Expr[a.AndNotWord]) = - '{ ~self } // error: access to value a from wrong staging level + '{ val a: Any = $self } // error: access to value a from wrong staging level } diff --git a/tests/pos/i5954.scala b/tests/pos/i5954.scala index eafc053e6b71..1a291ba21b3e 100644 --- a/tests/pos/i5954.scala +++ b/tests/pos/i5954.scala @@ -6,10 +6,10 @@ object MatcherFactory1 { import scala.quoted._ def impl(self: Expr[MatcherFactory1#AndNotWord]) = - '{ ~self } + '{ val a: Any = $self } def impl2[T: Type](a: MatcherFactory1)(self: Expr[T])(implicit ev: T =:= a.AndNotWord) = - '{ ~self } + '{ val a: Any = $self } } From 2ad3310bcf07e70deea05fa713bebd73de3330ef Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Thu, 21 Feb 2019 17:22:53 +0100 Subject: [PATCH 25/26] Change `splice` member to `$splice` --- compiler/src/dotty/tools/dotc/core/StdNames.scala | 2 +- library/src/scala/quoted/Expr.scala | 2 +- library/src/scala/quoted/Type.scala | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/core/StdNames.scala b/compiler/src/dotty/tools/dotc/core/StdNames.scala index f07cb119246c..83e67d3e8c43 100644 --- a/compiler/src/dotty/tools/dotc/core/StdNames.scala +++ b/compiler/src/dotty/tools/dotc/core/StdNames.scala @@ -521,7 +521,7 @@ object StdNames { val setSymbol: N = "setSymbol" val setType: N = "setType" val setTypeSignature: N = "setTypeSignature" - val splice: N = "splice" + val splice: N = "$splice" val staticClass : N = "staticClass" val staticModule : N = "staticModule" val staticPackage : N = "staticPackage" diff --git a/library/src/scala/quoted/Expr.scala b/library/src/scala/quoted/Expr.scala index 5de5cb1576ae..b61ac8bc6814 100644 --- a/library/src/scala/quoted/Expr.scala +++ b/library/src/scala/quoted/Expr.scala @@ -4,7 +4,7 @@ import scala.runtime.quoted.Unpickler.Pickled sealed abstract class Expr[+T] { - final def splice: T = throw new Error("splice should have been compiled away") + final def `$splice`: T = throw new Error("splice should have been compiled away") /** Evaluate the contents of this expression and return the result. * diff --git a/library/src/scala/quoted/Type.scala b/library/src/scala/quoted/Type.scala index 2a5708475f6c..487b90ce4f8d 100644 --- a/library/src/scala/quoted/Type.scala +++ b/library/src/scala/quoted/Type.scala @@ -5,7 +5,7 @@ import scala.reflect.ClassTag import scala.runtime.quoted.Unpickler.Pickled sealed abstract class Type[T] { - type splice = T + type `$splice` = T } /** Some basic type tags, currently incomplete */ From 4b0c23466238b2b8b7b767496c87c19dfcb91931 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Fri, 22 Feb 2019 19:24:58 +0100 Subject: [PATCH 26/26] Adapt `splice` to `$splice` in test --- .../Yretain-trees/tasty-extractors-owners.check | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/run-custom-args/Yretain-trees/tasty-extractors-owners.check b/tests/run-custom-args/Yretain-trees/tasty-extractors-owners.check index 03ae9c799944..ad142704cb0a 100644 --- a/tests/run-custom-args/Yretain-trees/tasty-extractors-owners.check +++ b/tests/run-custom-args/Yretain-trees/tasty-extractors-owners.check @@ -1,5 +1,5 @@ foo -DefDef("main", Nil, List(List(ValDef("args", TypeTree.Applied(TypeTree.Ident("Array"), List(TypeTree.Ident("String"))), None))), TypeTree.Ident("Unit"), Some(Term.Block(Nil, Term.Inlined(Some(TypeTree.Ident("Macros$")), Nil, Term.Typed(Term.Select(Term.Apply(Term.Apply(Term.TypeApply(Term.Ident("impl"), List(TypeTree.Inferred())), List(Term.Apply(Term.TypeApply(Term.Ident("apply"), List(TypeTree.Inferred())), List(Term.Inlined(None, Nil, Term.Block(List(DefDef("foo", Nil, Nil, TypeTree.Inferred(), Some(Term.Block(List(DefDef("bar", Nil, Nil, TypeTree.Inferred(), Some(Term.Literal(Constant.Int(1)))), ValDef("bar2", TypeTree.Inferred(), Some(Term.Literal(Constant.Int(2))))), Term.Typed(Term.Ident("bar"), TypeTree.Inferred())))), ValDef("foo2", TypeTree.Inferred(), Some(Term.Block(List(DefDef("baz", Nil, Nil, TypeTree.Inferred(), Some(Term.Literal(Constant.Int(3)))), ValDef("baz2", TypeTree.Inferred(), Some(Term.Literal(Constant.Int(4))))), Term.Typed(Term.Ident("baz"), TypeTree.Inferred())))), ClassDef("A", DefDef("", Nil, List(Nil), TypeTree.Inferred(), None), List(Term.Apply(Term.Select(Term.New(TypeTree.Inferred()), ""), Nil)), Nil, None, List(TypeDef("B", TypeTree.Ident("Int")), DefDef("b", Nil, Nil, TypeTree.Inferred(), Some(Term.Literal(Constant.Int(5)))), ValDef("b2", TypeTree.Inferred(), Some(Term.Literal(Constant.Int(6))))))), Term.Literal(Constant.Unit()))))))), List(Term.Ident("macroContext"))), "splice"), TypeTree.Ident("Unit")))))) +DefDef("main", Nil, List(List(ValDef("args", TypeTree.Applied(TypeTree.Ident("Array"), List(TypeTree.Ident("String"))), None))), TypeTree.Ident("Unit"), Some(Term.Block(Nil, Term.Inlined(Some(TypeTree.Ident("Macros$")), Nil, Term.Typed(Term.Select(Term.Apply(Term.Apply(Term.TypeApply(Term.Ident("impl"), List(TypeTree.Inferred())), List(Term.Apply(Term.TypeApply(Term.Ident("apply"), List(TypeTree.Inferred())), List(Term.Inlined(None, Nil, Term.Block(List(DefDef("foo", Nil, Nil, TypeTree.Inferred(), Some(Term.Block(List(DefDef("bar", Nil, Nil, TypeTree.Inferred(), Some(Term.Literal(Constant.Int(1)))), ValDef("bar2", TypeTree.Inferred(), Some(Term.Literal(Constant.Int(2))))), Term.Typed(Term.Ident("bar"), TypeTree.Inferred())))), ValDef("foo2", TypeTree.Inferred(), Some(Term.Block(List(DefDef("baz", Nil, Nil, TypeTree.Inferred(), Some(Term.Literal(Constant.Int(3)))), ValDef("baz2", TypeTree.Inferred(), Some(Term.Literal(Constant.Int(4))))), Term.Typed(Term.Ident("baz"), TypeTree.Inferred())))), ClassDef("A", DefDef("", Nil, List(Nil), TypeTree.Inferred(), None), List(Term.Apply(Term.Select(Term.New(TypeTree.Inferred()), ""), Nil)), Nil, None, List(TypeDef("B", TypeTree.Ident("Int")), DefDef("b", Nil, Nil, TypeTree.Inferred(), Some(Term.Literal(Constant.Int(5)))), ValDef("b2", TypeTree.Inferred(), Some(Term.Literal(Constant.Int(6))))))), Term.Literal(Constant.Unit()))))))), List(Term.Ident("macroContext"))), "$splice"), TypeTree.Ident("Unit")))))) bar DefDef("foo", Nil, Nil, TypeTree.Inferred(), Some(Term.Block(List(DefDef("bar", Nil, Nil, TypeTree.Inferred(), Some(Term.Literal(Constant.Int(1)))), ValDef("bar2", TypeTree.Inferred(), Some(Term.Literal(Constant.Int(2))))), Term.Typed(Term.Ident("bar"), TypeTree.Inferred())))) @@ -8,7 +8,7 @@ bar2 DefDef("foo", Nil, Nil, TypeTree.Inferred(), Some(Term.Block(List(DefDef("bar", Nil, Nil, TypeTree.Inferred(), Some(Term.Literal(Constant.Int(1)))), ValDef("bar2", TypeTree.Inferred(), Some(Term.Literal(Constant.Int(2))))), Term.Typed(Term.Ident("bar"), TypeTree.Inferred())))) foo2 -DefDef("main", Nil, List(List(ValDef("args", TypeTree.Applied(TypeTree.Ident("Array"), List(TypeTree.Ident("String"))), None))), TypeTree.Ident("Unit"), Some(Term.Block(Nil, Term.Inlined(Some(TypeTree.Ident("Macros$")), Nil, Term.Typed(Term.Select(Term.Apply(Term.Apply(Term.TypeApply(Term.Ident("impl"), List(TypeTree.Inferred())), List(Term.Apply(Term.TypeApply(Term.Ident("apply"), List(TypeTree.Inferred())), List(Term.Inlined(None, Nil, Term.Block(List(DefDef("foo", Nil, Nil, TypeTree.Inferred(), Some(Term.Block(List(DefDef("bar", Nil, Nil, TypeTree.Inferred(), Some(Term.Literal(Constant.Int(1)))), ValDef("bar2", TypeTree.Inferred(), Some(Term.Literal(Constant.Int(2))))), Term.Typed(Term.Ident("bar"), TypeTree.Inferred())))), ValDef("foo2", TypeTree.Inferred(), Some(Term.Block(List(DefDef("baz", Nil, Nil, TypeTree.Inferred(), Some(Term.Literal(Constant.Int(3)))), ValDef("baz2", TypeTree.Inferred(), Some(Term.Literal(Constant.Int(4))))), Term.Typed(Term.Ident("baz"), TypeTree.Inferred())))), ClassDef("A", DefDef("", Nil, List(Nil), TypeTree.Inferred(), None), List(Term.Apply(Term.Select(Term.New(TypeTree.Inferred()), ""), Nil)), Nil, None, List(TypeDef("B", TypeTree.Ident("Int")), DefDef("b", Nil, Nil, TypeTree.Inferred(), Some(Term.Literal(Constant.Int(5)))), ValDef("b2", TypeTree.Inferred(), Some(Term.Literal(Constant.Int(6))))))), Term.Literal(Constant.Unit()))))))), List(Term.Ident("macroContext"))), "splice"), TypeTree.Ident("Unit")))))) +DefDef("main", Nil, List(List(ValDef("args", TypeTree.Applied(TypeTree.Ident("Array"), List(TypeTree.Ident("String"))), None))), TypeTree.Ident("Unit"), Some(Term.Block(Nil, Term.Inlined(Some(TypeTree.Ident("Macros$")), Nil, Term.Typed(Term.Select(Term.Apply(Term.Apply(Term.TypeApply(Term.Ident("impl"), List(TypeTree.Inferred())), List(Term.Apply(Term.TypeApply(Term.Ident("apply"), List(TypeTree.Inferred())), List(Term.Inlined(None, Nil, Term.Block(List(DefDef("foo", Nil, Nil, TypeTree.Inferred(), Some(Term.Block(List(DefDef("bar", Nil, Nil, TypeTree.Inferred(), Some(Term.Literal(Constant.Int(1)))), ValDef("bar2", TypeTree.Inferred(), Some(Term.Literal(Constant.Int(2))))), Term.Typed(Term.Ident("bar"), TypeTree.Inferred())))), ValDef("foo2", TypeTree.Inferred(), Some(Term.Block(List(DefDef("baz", Nil, Nil, TypeTree.Inferred(), Some(Term.Literal(Constant.Int(3)))), ValDef("baz2", TypeTree.Inferred(), Some(Term.Literal(Constant.Int(4))))), Term.Typed(Term.Ident("baz"), TypeTree.Inferred())))), ClassDef("A", DefDef("", Nil, List(Nil), TypeTree.Inferred(), None), List(Term.Apply(Term.Select(Term.New(TypeTree.Inferred()), ""), Nil)), Nil, None, List(TypeDef("B", TypeTree.Ident("Int")), DefDef("b", Nil, Nil, TypeTree.Inferred(), Some(Term.Literal(Constant.Int(5)))), ValDef("b2", TypeTree.Inferred(), Some(Term.Literal(Constant.Int(6))))))), Term.Literal(Constant.Unit()))))))), List(Term.Ident("macroContext"))), "$splice"), TypeTree.Ident("Unit")))))) baz ValDef("foo2", TypeTree.Inferred(), Some(Term.Block(List(DefDef("baz", Nil, Nil, TypeTree.Inferred(), Some(Term.Literal(Constant.Int(3)))), ValDef("baz2", TypeTree.Inferred(), Some(Term.Literal(Constant.Int(4))))), Term.Typed(Term.Ident("baz"), TypeTree.Inferred()))))