Skip to content

Commit 7f16383

Browse files
committed
Fix leaks of non-inlined arguments
1 parent b8055a2 commit 7f16383

File tree

16 files changed

+22
-22
lines changed

16 files changed

+22
-22
lines changed

tests/neg-macros/macros-in-same-project-6/Foo.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ object Foo {
55
inline def myMacro(): Unit = ${ aMacroImplementation }
66

77
def aMacroImplementation(using qctx: QuoteContext) : Expr[Unit] = {
8-
import qctx.tasty.{given _, _}
8+
import qctx.tasty._
99
error("some error", rootPosition)
1010
throw new NoClassDefFoundError("Bar$")
1111
}

tests/pos-macros/i8325/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ object A:
1212
def pure[A](a:A):A = ???
1313

1414
def transformImplExpr[A:Type](using qctx: QuoteContext)(expr: Expr[A]): Expr[A] = {
15-
import qctx.tasty.{given _, _}
15+
import qctx.tasty._
1616
expr.unseal match {
1717
case Inlined(x,y,z) => transformImplExpr(z.seal.asInstanceOf[Expr[A]])
1818
case Apply(fun,args) => '{ A.pure(${Apply(fun,args).seal.asInstanceOf[Expr[A]]}) }

tests/pos-macros/i8325b/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ object A:
1212
def pure[A](a:A):A = ???
1313

1414
def transformImplExpr[A:Type](using qctx: QuoteContext)(expr: Expr[A]): Expr[A] = {
15-
import qctx.tasty.{given _, _}
15+
import qctx.tasty._
1616
expr.unseal match {
1717
case Inlined(x,y,z) => transformImplExpr(z.seal.asInstanceOf[Expr[A]])
1818
case r@Apply(fun,args) => '{

tests/pos/i7887.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
def typed[A](using t: quoted.Type[A], qctx: quoted.QuoteContext): Unit = {
2-
import qctx.tasty.{given _, _}
2+
import qctx.tasty._
33
'{
44
type T = $t
55
${'{???}.cast[T]}

tests/run-macros/i6253-b/quoted_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import scala.quoted._
33

44
object Macros {
55

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

88
private def impl(self: Expr[StringContext], args: Expr[Seq[String]])(using QuoteContext): Expr[String] = {
99
self match {

tests/run-macros/i6253/quoted_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import scala.quoted._
33

44
object Macros {
55

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

88
private def impl(self: Expr[StringContext], args: Expr[Seq[String]])(using QuoteContext): Expr[String] = {
99
self match {

tests/run-macros/i6803/Macro_1.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ object AsObject {
99
def unsafe(i: Int): LineNo = new LineNo(i)
1010
inline given LineNo = ${impl}
1111
private def impl(using qctx: QuoteContext): Expr[LineNo] = {
12-
import qctx.tasty.{given _, _}
12+
import qctx.tasty._
1313
'{unsafe(${Expr(rootPosition.startLine)})}
1414
}
1515
}
@@ -21,7 +21,7 @@ package AsPackage {
2121
def unsafe(i: Int): LineNo = new LineNo(i)
2222
inline given LineNo = ${impl}
2323
private def impl(using qctx: QuoteContext): Expr[LineNo] = {
24-
import qctx.tasty.{given _, _}
24+
import qctx.tasty._
2525
'{unsafe(${Expr(rootPosition.startLine)})}
2626
}
2727
}

tests/run-macros/i7025/Macros_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ object Macros {
44
inline def debug: Unit = ${Macros.debugImpl}
55

66
def debugImpl(using qctx: QuoteContext): Expr[Unit] = {
7-
import qctx.tasty.{given _, _}
7+
import qctx.tasty._
88

99
def nearestEnclosingDef(owner: Symbol): Symbol =
1010
if owner.isClassDef then owner

tests/run-macros/quote-matcher-string-interpolator/quoted_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import scala.quoted._
44

55
object Macros {
66

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

99
private def impl(self: Expr[StringContext], args: Expr[Seq[String]])(using QuoteContext): Expr[String] = {
1010
self match {

tests/run-macros/quote-matcher-symantics-2/quoted_1.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import scala.quoted.unsafe._
44

55
object Macros {
66

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

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

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

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

tests/run-macros/quote-matcher-symantics-3/quoted_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import scala.quoted.unsafe._
55
object Macros {
66

77

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

1010

1111
private def impl[R[_]: Type](sym: Expr[Symantics { type Repr[X] = R[X] }], expr: Expr[Int])(using QuoteContext): Expr[R[Int]] = {

tests/run-macros/quoted-matching-docs-2/Macro_1.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import scala.quoted._
33

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

6-
inline def showOptimize(arg: Int): String = ${ showOptimizeExpr('arg) }
7-
inline def optimize(arg: Int): Int = ${ optimizeExpr('arg) }
6+
inline def showOptimize(inline arg: Int): String = ${ showOptimizeExpr('arg) }
7+
inline def optimize(inline arg: Int): Int = ${ optimizeExpr('arg) }
88

99
private def showOptimizeExpr(body: Expr[Int])(using QuoteContext): Expr[String] =
1010
Expr(optimizeExpr(body).show)

tests/run-macros/quoted-matching-docs/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ private def sumExprShow(argsExpr: Expr[Seq[Int]]) (using QuoteContext): Expr[Str
1010
Expr(sumExpr(argsExpr).show)
1111

1212
private def sumExpr(argsExpr: Expr[Seq[Int]])(using qctx: QuoteContext) : Expr[Int] = {
13-
import qctx.tasty.{given _, _}
13+
import qctx.tasty._
1414
UnsafeExpr.underlyingArgument(argsExpr) match {
1515
case Varargs(Consts(args)) => // args is of type Seq[Int]
1616
Expr(args.sum) // precompute result of sum

tests/run-macros/quoted-pattern-type/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import scala.quoted._
22

33
object Lib {
44

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

77
private def impl[T: Type](arg: Expr[T])(using QuoteContext): Expr[T] = {
88
arg match {

tests/run-macros/refined-selectable-macro/Macro_1.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ object Macro {
88

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

1414
private def toTupleImpl(s: Expr[Selectable])(using qctx:QuoteContext) : Expr[Tuple] = {
15-
import qctx.tasty.{given _, _}
15+
import qctx.tasty._
1616

1717
val repr = s.unseal.tpe.widenTermRefExpr.dealias
1818

@@ -46,7 +46,7 @@ object Macro {
4646
}
4747

4848
private def fromTupleImpl[T: Type](s: Expr[Tuple], newRecord: Expr[Array[(String, Any)] => T])(using qctx:QuoteContext) : Expr[Any] = {
49-
import qctx.tasty.{given _, _}
49+
import qctx.tasty._
5050

5151
val repr = s.unseal.tpe.widenTermRefExpr.dealias
5252

tests/run-macros/requiredSymbols/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import scala.quoted._
33
object Macro {
44
inline def foo: String = ${ fooImpl }
55
def fooImpl(using qctx: QuoteContext) : Expr[String] = {
6-
import qctx.tasty.{given _, _}
6+
import qctx.tasty._
77
val list = List(
88
rootContext.requiredPackage("java"),
99
rootContext.requiredPackage("java.lang"),

0 commit comments

Comments
 (0)