Skip to content

Commit 8360a31

Browse files
Only check newVal/newMethod privateWithin on -Xcheck-macros (#17437)
Closes #17432
2 parents af86500 + c909024 commit 8360a31

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2540,13 +2540,15 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
25402540
def newMethod(owner: Symbol, name: String, tpe: TypeRepr): Symbol =
25412541
newMethod(owner, name, tpe, Flags.EmptyFlags, noSymbol)
25422542
def newMethod(owner: Symbol, name: String, tpe: TypeRepr, flags: Flags, privateWithin: Symbol): Symbol =
2543-
assert(!privateWithin.exists || privateWithin.isType, "privateWithin must be a type symbol or `Symbol.noSymbol`")
2543+
xCheckMacroAssert(!privateWithin.exists || privateWithin.isType, "privateWithin must be a type symbol or `Symbol.noSymbol`")
2544+
val privateWithin1 = if privateWithin.isTerm then Symbol.noSymbol else privateWithin
25442545
checkValidFlags(flags.toTermFlags, Flags.validMethodFlags)
2545-
dotc.core.Symbols.newSymbol(owner, name.toTermName, flags | dotc.core.Flags.Method, tpe, privateWithin)
2546+
dotc.core.Symbols.newSymbol(owner, name.toTermName, flags | dotc.core.Flags.Method, tpe, privateWithin1)
25462547
def newVal(owner: Symbol, name: String, tpe: TypeRepr, flags: Flags, privateWithin: Symbol): Symbol =
2547-
assert(!privateWithin.exists || privateWithin.isType, "privateWithin must be a type symbol or `Symbol.noSymbol`")
2548+
xCheckMacroAssert(!privateWithin.exists || privateWithin.isType, "privateWithin must be a type symbol or `Symbol.noSymbol`")
2549+
val privateWithin1 = if privateWithin.isTerm then Symbol.noSymbol else privateWithin
25482550
checkValidFlags(flags.toTermFlags, Flags.validValFlags)
2549-
dotc.core.Symbols.newSymbol(owner, name.toTermName, flags, tpe, privateWithin)
2551+
dotc.core.Symbols.newSymbol(owner, name.toTermName, flags, tpe, privateWithin1)
25502552
def newBind(owner: Symbol, name: String, flags: Flags, tpe: TypeRepr): Symbol =
25512553
checkValidFlags(flags.toTermFlags, Flags.validBindFlags)
25522554
dotc.core.Symbols.newSymbol(owner, name.toTermName, flags | dotc.core.Flags.Case, tpe)
File renamed without changes.

0 commit comments

Comments
 (0)