From 9db0a00023dac264edf3f17fc9bef6aa048f06c2 Mon Sep 17 00:00:00 2001 From: Jan Chyb Date: Thu, 3 Oct 2024 13:20:22 +0200 Subject: [PATCH] Address review comments --- .../src/scala/quoted/runtime/impl/QuotesImpl.scala | 14 +++++++++----- library/src/scala/quoted/Quotes.scala | 10 +++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala b/compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala index ba6a6bb56253..901e0038efd5 100644 --- a/compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala +++ b/compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala @@ -2651,12 +2651,13 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler dotc.core.Symbols.newSymbol(owner, name.toTermName, flags | dotc.core.Flags.Case, tpe) def newTypeAlias(owner: Symbol, name: String, flags: Flags, tpe: TypeRepr, privateWithin: Symbol): Symbol = - checkValidFlags(flags.toTypeFlags, Flags.validTypeFlags) + checkValidFlags(flags.toTypeFlags, Flags.validTypeAliasFlags) + assert(!tpe.isInstanceOf[Types.TypeBounds], "Passed `tpe` into newTypeAlias should not represent TypeBounds") dotc.core.Symbols.newSymbol(owner, name.toTypeName, flags | dotc.core.Flags.Deferred, dotc.core.Types.TypeAlias(tpe), privateWithin) def newBoundedType(owner: Symbol, name: String, flags: Flags, tpe: TypeBounds, privateWithin: Symbol): Symbol = - checkValidFlags(flags.toTypeFlags, Flags.validTypeFlags) - dotc.core.Symbols.newSymbol(owner, name.toTypeName, flags | dotc.core.Flags.Deferred, tpe, privateWithin) + checkValidFlags(flags.toTypeFlags, Flags.validBoundedTypeFlags) + dotc.core.Symbols.newSymbol(owner, name.toTypeName, flags, tpe, privateWithin) def noSymbol: Symbol = dotc.core.Symbols.NoSymbol @@ -2999,8 +3000,11 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler // Keep: aligned with Quotes's `newBind` doc private[QuotesImpl] def validBindFlags: Flags = Case // Flags that could be allowed: Implicit | Given | Erased - // Keep: aligned with Quotes's 'newType' doc - private[QuotesImpl] def validTypeFlags: Flags = Private | Protected | Override | Deferred | Final | Infix | Local + // Keep: aligned with Quotes's 'newBoundedType' doc + private[QuotesImpl] def validBoundedTypeFlags: Flags = Private | Protected | Override | Deferred | Final | Infix | Local + + // Keep: aligned with Quotes's `newTypeAlias` doc + private[QuotesImpl] def validTypeAliasFlags: Flags = Private | Protected | Override | Final | Infix | Local end Flags diff --git a/library/src/scala/quoted/Quotes.scala b/library/src/scala/quoted/Quotes.scala index 99cf04ec423c..7a98d6f6f761 100644 --- a/library/src/scala/quoted/Quotes.scala +++ b/library/src/scala/quoted/Quotes.scala @@ -3971,14 +3971,14 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching => * * @param parent The owner of the type * @param name The name of the type - * @param flags extra flags to with which symbol can be constructed. `Deferred` flag will be added. Can be `Private` | `Protected` | `Override` | `Deferred` | `Final` | `Infix` | `Local` + * @param flags extra flags to with which symbol can be constructed. Can be `Private` | `Protected` | `Override` | `Final` | `Infix` | `Local` * @param tpe The rhs the type alias - * @param privateWithin the symbol within which this new method symbol should be private. May be noSymbol. + * @param privateWithin the symbol within which this new type symbol should be private. May be noSymbol. * @note As a macro can only splice code into the point at which it is expanded, all generated symbols must be * direct or indirect children of the reflection context's owner. */ @experimental - // Keep: `flags` doc aligned with QuotesImpl's `validTypeFlags` + // Keep: `flags` doc aligned with QuotesImpl's `validTypeAliasFlags` def newTypeAlias(parent: Symbol, name: String, flags: Flags, tpe: TypeRepr, privateWithin: Symbol): Symbol /** Generate a new type symbol for a type bounds with the given parent, name and type @@ -3991,12 +3991,12 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching => * @param name The name of the type * @param flags extra flags to with which symbol can be constructed. `Deferred` flag will be added. Can be `Private` | `Protected` | `Override` | `Deferred` | `Final` | `Infix` | `Local` * @param tpe The bounds of the type - * @param privateWithin the symbol within which this new method symbol should be private. May be noSymbol. + * @param privateWithin the symbol within which this new type symbol should be private. May be noSymbol. * @note As a macro can only splice code into the point at which it is expanded, all generated symbols must be * direct or indirect children of the reflection context's owner. */ @experimental - // Keep: `flags` doc aligned with QuotesImpl's `validTypeFlags` + // Keep: `flags` doc aligned with QuotesImpl's `validBoundedTypeFlags` def newBoundedType(parent: Symbol, name: String, flags: Flags, tpe: TypeBounds, privateWithin: Symbol): Symbol /** Definition not available */