Skip to content

Commit b90e9c6

Browse files
Make check flags for newMethod, newVal and newBind in Quotes API less restrictive (#18217)
Fixes #17764 Allows `Flags.Artifact` and `Flags.Synthetic` and the other ["flags that could be allowed"](https://github.com/lampepfl/dotty/blob/3.3.1-RC1/compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala#L2880-L2885) as they are valid flags and there is no reason to forbid them.
2 parents 36a9940 + 510c6ba commit b90e9c6

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -2915,9 +2915,10 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
29152915
def Transparent: Flags = dotc.core.Flags.Transparent
29162916

29172917
// Keep: aligned with Quotes's `newMethod` doc
2918-
private[QuotesImpl] def validMethodFlags: Flags = Private | Protected | Override | Deferred | Final | Method | Implicit | Given | Local | AbsOverride | JavaStatic // Flags that could be allowed: Synthetic | ExtensionMethod | Exported | Erased | Infix | Invisible
2918+
private[QuotesImpl] def validMethodFlags: Flags = Private | Protected | Override | Deferred | Final | Method | Implicit | Given | Local | AbsOverride | JavaStatic | Synthetic | Artifact // Flags that could be allowed: Synthetic | ExtensionMethod | Exported | Erased | Infix | Invisible
29192919
// Keep: aligned with Quotes's `newVal` doc
2920-
private[QuotesImpl] def validValFlags: Flags = Private | Protected | Override | Deferred | Final | Param | Implicit | Lazy | Mutable | Local | ParamAccessor | Module | Package | Case | CaseAccessor | Given | Enum | AbsOverride | JavaStatic // Flags that could be added: Synthetic | Erased | Invisible
2920+
private[QuotesImpl] def validValFlags: Flags = Private | Protected | Override | Deferred | Final | Param | Implicit | Lazy | Mutable | Local | ParamAccessor | Module | Package | Case | CaseAccessor | Given | Enum | AbsOverride | JavaStatic | Synthetic | Artifact // Flags that could be added: Synthetic | Erased | Invisible
2921+
29212922
// Keep: aligned with Quotes's `newBind` doc
29222923
private[QuotesImpl] def validBindFlags: Flags = Case // Flags that could be allowed: Implicit | Given | Erased
29232924
end Flags

library/src/scala/quoted/Quotes.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -3816,7 +3816,7 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
38163816
* @param parent The owner of the method
38173817
* @param name The name of the method
38183818
* @param tpe The type of the method (MethodType, PolyType, ByNameType)
3819-
* @param flags extra flags to with which the symbol should be constructed. `Method` flag will be added. Can be `Private | Protected | Override | Deferred | Final | Method | Implicit | Given | Local | JavaStatic`
3819+
* @param flags extra flags to with which the symbol should be constructed. `Method` flag will be added. Can be `Private | Protected | Override | Deferred | Final | Method | Implicit | Given | Local | JavaStatic | Synthetic | Artifact`
38203820
* @param privateWithin the symbol within which this new method symbol should be private. May be noSymbol.
38213821
*/
38223822
// Keep: `flags` doc aligned with QuotesImpl's `validMethodFlags`
@@ -3833,7 +3833,7 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
38333833
* @param parent The owner of the val/var/lazy val
38343834
* @param name The name of the val/var/lazy val
38353835
* @param tpe The type of the val/var/lazy val
3836-
* @param flags extra flags to with which the symbol should be constructed. Can be `Private | Protected | Override | Deferred | Final | Param | Implicit | Lazy | Mutable | Local | ParamAccessor | Module | Package | Case | CaseAccessor | Given | Enum | JavaStatic`
3836+
* @param flags extra flags to with which the symbol should be constructed. Can be `Private | Protected | Override | Deferred | Final | Param | Implicit | Lazy | Mutable | Local | ParamAccessor | Module | Package | Case | CaseAccessor | Given | Enum | JavaStatic | Synthetic | Artifact`
38373837
* @param privateWithin the symbol within which this new method symbol should be private. May be noSymbol.
38383838
* @note As a macro can only splice code into the point at which it is expanded, all generated symbols must be
38393839
* direct or indirect children of the reflection context's owner.

0 commit comments

Comments
 (0)