Skip to content

Commit b8055a2

Browse files
committed
Fix quoted match inline bindings leak
1 parent 3941b59 commit b8055a2

File tree

13 files changed

+14
-14
lines changed

13 files changed

+14
-14
lines changed

library/src-non-bootstrapped/dotty/internal/StringContextMacro.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import scala.quoted._
77
object StringContextMacro {
88

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

1313
}

library/src/scala/internal/quoted/Matcher.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ private[quoted] object Matcher {
3333
if (hasTypeSplices) {
3434
val ctx: Context = internal.Context_GADT_setFreshGADTBounds(rootContext)
3535
given Context = ctx
36-
val matchings = scrutineeTerm.underlyingArgument =?= patternTerm.underlyingArgument
36+
val matchings = scrutineeTerm =?= patternTerm
3737
// After matching and doing all subtype checks, we have to approximate all the type bindings
3838
// that we have found and seal them in a quoted.Type
3939
matchings.asOptionOfTuple.map { tup =>
@@ -44,7 +44,7 @@ private[quoted] object Matcher {
4444
}
4545
}
4646
else {
47-
scrutineeTerm.underlyingArgument =?= patternTerm.underlyingArgument
47+
scrutineeTerm =?= patternTerm
4848
}
4949
}
5050

tests/neg-macros/i6432/Macro_1.scala

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

55

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

99
def impl(sc: Expr[StringContext])(using qctx: QuoteContext) : Expr[Unit] = {
1010
import qctx.tasty._

tests/neg-macros/i6432b/Macro_1.scala

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

55

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

99
def impl(sc: Expr[StringContext])(using qctx: QuoteContext) : Expr[Unit] = {
1010
import qctx.tasty._

tests/neg/i7698.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ def showInterpolatorImpl(sc: Expr[StringContext], argsExpr: Expr[Seq[Any]])(usin
1111
case '[ Int ] => // error
1212
???
1313

14-
inline def (sc: => StringContext) show (args: Any*): String = ${ showInterpolatorImpl('sc, 'args) }
14+
inline def (inline sc: StringContext) show (args: Any*): String = ${ showInterpolatorImpl('sc, 'args) }

tests/run-macros/i5119/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ object Macro {
55
class StringContextOps(sc: => StringContext) {
66
inline def ff(args: => Any*): String = ${ Macro.impl('sc, 'args) }
77
}
8-
implicit inline def XmlQuote(sc: => StringContext): StringContextOps = new StringContextOps(sc)
8+
implicit inline def XmlQuote(inline sc: StringContext): StringContextOps = new StringContextOps(sc)
99
def impl(sc: Expr[StringContext], args: Expr[Seq[Any]])(using qctx: QuoteContext) : Expr[String] = {
1010
import qctx.tasty._
1111
(sc.unseal.underlyingArgument.showExtractors + "\n" + args.unseal.underlyingArgument.showExtractors)

tests/run-macros/quote-elide-prefix/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
object Macro {
44

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

88
def impl(sc: Expr[StringContext], args: Expr[Seq[Any]])(using QuoteContext): Expr[String] = '{ $args.mkString }
99
}

tests/run-macros/quote-matcher-runtime/quoted_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ object Macros {
55
inline def matches[A, B](inline a: A, inline b: B): Unit = ${impl('a, 'b)}
66

77
private def impl[A, B](a: Expr[A], b: Expr[B])(using qctx: QuoteContext) : Expr[Unit] = {
8-
import qctx.tasty.{Bind => _, given _, _}
8+
import qctx.tasty._
99

1010
val res = scala.internal.quoted.Expr.unapply[Tuple, Tuple](a)(using b, true, qctx).map { tup =>
1111
tup.toArray.toList.map {

tests/run-macros/quote-matcher-string-interpolator-2/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(inline args: String*): String = ${impl('self, 'args)}
7+
inline def (inline self: StringContext) xyz(inline args: String*): String = ${impl('self, 'args)}
88

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

tests/run-macros/quote-matcher-string-interpolator-3/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) S(args: => String*): String = ${impl('self, 'args)}
7+
inline def (inline self: StringContext) S(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-1/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 lift[T](sym: Symantics[T])(a: => DSL): T = ${impl[T]('sym, 'a)}
7+
inline def lift[T](sym: Symantics[T])(inline a: DSL): T = ${impl[T]('sym, 'a)}
88

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

tests/run-macros/quote-matching-open/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
import scala.quoted.unsafe._
33
object Macro {
44

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

77
def impl(x: Expr[Any])(using QuoteContext): Expr[Any] = {
88
x match {

tests/run-macros/quoted-pattern-open-expr/Macro_1.scala

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

3-
inline def test(e: Int): String = ${testExpr('e)}
3+
inline def test(inline e: Int): String = ${testExpr('e)}
44

55
private def testExpr(e: Expr[Int])(using QuoteContext): Expr[String] = {
66
e match {

0 commit comments

Comments
 (0)