@@ -266,8 +266,8 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
266
266
267
267
object DefDef extends DefDefModule :
268
268
def apply (symbol : Symbol , rhsFn : List [List [Tree ]] => Option [Term ]): DefDef =
269
- assert( ! xCheckMacro || symbol.isTerm, s " expected a term symbol but received $symbol" )
270
- assert( ! xCheckMacro || symbol.flags.is(Flags .Method ), " expected a symbol with `Method` flag set" )
269
+ xCheckMacroAssert( symbol.isTerm, s " expected a term symbol but received $symbol" )
270
+ xCheckMacroAssert( symbol.flags.is(Flags .Method ), " expected a symbol with `Method` flag set" )
271
271
withDefaultPos(tpd.DefDef (symbol.asTerm, prefss =>
272
272
xCheckedMacroOwners(xCheckMacroValidExpr(rhsFn(prefss)), symbol).getOrElse(tpd.EmptyTree )
273
273
))
@@ -298,7 +298,7 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
298
298
299
299
object ValDef extends ValDefModule :
300
300
def apply (symbol : Symbol , rhs : Option [Term ]): ValDef =
301
- assert( ! xCheckMacro || ! symbol.flags.is(Flags .Method ), " expected a symbol without `Method` flag set" )
301
+ xCheckMacroAssert( ! symbol.flags.is(Flags .Method ), " expected a symbol without `Method` flag set" )
302
302
tpd.ValDef (symbol.asTerm, xCheckedMacroOwners(xCheckMacroValidExpr(rhs), symbol).getOrElse(tpd.EmptyTree ))
303
303
def copy (original : Tree )(name : String , tpt : TypeTree , rhs : Option [Term ]): ValDef =
304
304
tpd.cpy.ValDef (original)(name.toTermName, tpt, xCheckedMacroOwners(xCheckMacroValidExpr(rhs), original.symbol).getOrElse(tpd.EmptyTree ))
@@ -1475,7 +1475,7 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
1475
1475
1476
1476
object Bind extends BindModule :
1477
1477
def apply (sym : Symbol , pattern : Tree ): Bind =
1478
- assert( ! xCheckMacro || sym.flags.is(Flags .Case ), " expected a symbol with `Case` flag set" )
1478
+ xCheckMacroAssert( sym.flags.is(Flags .Case ), " expected a symbol with `Case` flag set" )
1479
1479
tpd.Bind (sym, pattern)
1480
1480
def copy (original : Tree )(name : String , pattern : Tree ): Bind =
1481
1481
withDefaultPos(tpd.cpy.Bind (original)(name.toTermName, pattern))
@@ -2499,12 +2499,9 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
2499
2499
dotc.core.Symbols .newSymbol(owner, name.toTermName, flags | dotc.core.Flags .Case , tpe)
2500
2500
def noSymbol : Symbol = dotc.core.Symbols .NoSymbol
2501
2501
2502
- private def checkValidFlags (flags : Flags , valid : Flags ): Unit =
2503
- // TODO remove xCheckMacro.
2504
- // We introduce this check under this flag to not break published macros that may have accidentally used a wrong flag but happen to work.
2505
- // Once macro implementation had a compiler version or two too find their bugs and patch them we can enforce it on every use site.
2506
- assert(
2507
- ! xCheckMacro || flags <= valid,
2502
+ private inline def checkValidFlags (inline flags : Flags , inline valid : Flags ): Unit =
2503
+ xCheckMacroAssert(
2504
+ flags <= valid,
2508
2505
s " Received invalid flags. Expected flags ${flags.show} to only contain a subset of ${valid.show}. "
2509
2506
)
2510
2507
@@ -3019,6 +3016,9 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
3019
3016
" Reference to a method must be eta-expanded before it is used as an expression: " + term.show)
3020
3017
term
3021
3018
3019
+ private inline def xCheckMacroAssert (inline cond : Boolean , inline msg : String ): Unit =
3020
+ assert(! xCheckMacro || cond, msg)
3021
+
3022
3022
object Printer extends PrinterModule :
3023
3023
3024
3024
lazy val TreeCode : Printer [Tree ] = new Printer [Tree ]:
0 commit comments