diff --git a/compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala b/compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala index fd5b635e11e2..c35d259ffea8 100644 --- a/compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala +++ b/compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala @@ -1694,6 +1694,8 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler end SimpleSelectorTypeTest object SimpleSelector extends SimpleSelectorModule: + def apply(name: String): SimpleSelector = + withDefaultPos(untpd.ImportSelector(untpd.Ident(name.toTermName))) def unapply(x: SimpleSelector): Some[String] = Some(x.name.toString) end SimpleSelector @@ -1713,6 +1715,8 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler end RenameSelectorTypeTest object RenameSelector extends RenameSelectorModule: + def apply(fromName: String, toName: String): RenameSelector = + withDefaultPos(untpd.ImportSelector(untpd.Ident(fromName.toTermName), untpd.Ident(toName.toTermName))) def unapply(x: RenameSelector): (String, String) = (x.fromName, x.toName) end RenameSelector @@ -1738,6 +1742,8 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler end OmitSelectorTypeTest object OmitSelector extends OmitSelectorModule: + def apply(name: String): OmitSelector = + withDefaultPos(untpd.ImportSelector(untpd.Ident(name.toTermName), untpd.Ident(nme.WILDCARD))) def unapply(x: OmitSelector): Some[String] = Some(x.imported.name.toString) end OmitSelector @@ -1758,6 +1764,11 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler end GivenSelectorTypeTest object GivenSelector extends GivenSelectorModule: + def apply(bound: Option[TypeTree]): GivenSelector = + withDefaultPos(untpd.ImportSelector( + untpd.Ident(nme.EMPTY), + bound = bound.map(tpt => untpd.TypedSplice(tpt)).getOrElse(EmptyTree) + )) def unapply(x: GivenSelector): Some[Option[TypeTree]] = Some(GivenSelectorMethods.bound(x)) end GivenSelector diff --git a/library/src/scala/quoted/Quotes.scala b/library/src/scala/quoted/Quotes.scala index 7a98d6f6f761..70505eb2e98b 100644 --- a/library/src/scala/quoted/Quotes.scala +++ b/library/src/scala/quoted/Quotes.scala @@ -2545,6 +2545,7 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching => /** Methods of the module object `val SimpleSelector` */ trait SimpleSelectorModule { this: SimpleSelector.type => + @experimental def apply(name: String): SimpleSelector def unapply(x: SimpleSelector): Some[String] } @@ -2570,6 +2571,7 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching => /** Methods of the module object `val RenameSelector` */ trait RenameSelectorModule { this: RenameSelector.type => + @experimental def apply(fromName: String, toName: String): RenameSelector def unapply(x: RenameSelector): (String, String) } @@ -2597,6 +2599,7 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching => /** Methods of the module object `val OmitSelector` */ trait OmitSelectorModule { this: OmitSelector.type => + @experimental def apply(name: String): OmitSelector def unapply(x: OmitSelector): Some[String] } @@ -2621,6 +2624,7 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching => /** Methods of the module object `val GivenSelector` */ trait GivenSelectorModule { this: GivenSelector.type => + @experimental def apply(bound: Option[TypeTree]): GivenSelector def unapply(x: GivenSelector): Some[Option[TypeTree]] }