diff --git a/compiler/src/scala/quoted/runtime/impl/QuoteContextImpl.scala b/compiler/src/scala/quoted/runtime/impl/QuoteContextImpl.scala index 5c7732c49aca..300318ac7426 100644 --- a/compiler/src/scala/quoted/runtime/impl/QuoteContextImpl.scala +++ b/compiler/src/scala/quoted/runtime/impl/QuoteContextImpl.scala @@ -795,28 +795,28 @@ class QuoteContextImpl private (using val ctx: Context) extends QuoteContext, Qu end extension end MatchMethodsImpl - type GivenMatch = tpd.Match + type SummonFrom = tpd.Match - object GivenMatchTypeTest extends TypeTest[Tree, GivenMatch]: - def unapply(x: Tree): Option[GivenMatch & x.type] = x match + object SummonFromTypeTest extends TypeTest[Tree, SummonFrom]: + def unapply(x: Tree): Option[SummonFrom & x.type] = x match case x: (tpd.Match & x.type) if x.selector.isEmpty => Some(x) case _ => None - end GivenMatchTypeTest + end SummonFromTypeTest - object GivenMatch extends GivenMatchModule: - def apply(cases: List[CaseDef]): GivenMatch = + object SummonFrom extends SummonFromModule: + def apply(cases: List[CaseDef]): SummonFrom = withDefaultPos(tpd.Match(tpd.EmptyTree, cases)) - def copy(original: Tree)(cases: List[CaseDef]): GivenMatch = + def copy(original: Tree)(cases: List[CaseDef]): SummonFrom = tpd.cpy.Match(original)(tpd.EmptyTree, cases) - def unapply(x: GivenMatch): Option[List[CaseDef]] = + def unapply(x: SummonFrom): Option[List[CaseDef]] = Some(x.cases) - end GivenMatch + end SummonFrom - object GivenMatchMethodsImpl extends GivenMatchMethods: - extension (self: GivenMatch): + object SummonFromMethodsImpl extends SummonFromMethods: + extension (self: SummonFrom): def cases: List[CaseDef] = self.cases end extension - end GivenMatchMethodsImpl + end SummonFromMethodsImpl type Try = tpd.Try diff --git a/compiler/src/scala/quoted/runtime/impl/printers/Extractors.scala b/compiler/src/scala/quoted/runtime/impl/printers/Extractors.scala index aa215ea0188f..2de06f2c4e90 100644 --- a/compiler/src/scala/quoted/runtime/impl/printers/Extractors.scala +++ b/compiler/src/scala/quoted/runtime/impl/printers/Extractors.scala @@ -95,8 +95,8 @@ object Extractors { this += "Closure(" += meth += ", " += tpt += ")" case Match(selector, cases) => this += "Match(" += selector += ", " ++= cases += ")" - case GivenMatch(cases) => - this += "GivenMatch(" ++= cases += ")" + case SummonFrom(cases) => + this += "SummonFrom(" ++= cases += ")" case Return(expr, from) => this += "Return(" += expr += ", " += from += ")" case While(cond, body) => diff --git a/compiler/src/scala/quoted/runtime/impl/printers/SourceCode.scala b/compiler/src/scala/quoted/runtime/impl/printers/SourceCode.scala index 59689d6f4ba9..df422291b313 100644 --- a/compiler/src/scala/quoted/runtime/impl/printers/SourceCode.scala +++ b/compiler/src/scala/quoted/runtime/impl/printers/SourceCode.scala @@ -486,8 +486,8 @@ object SourceCode { this += highlightKeyword(" match") inBlock(printCases(cases, lineBreak())) - case GivenMatch(cases) => - this += highlightKeyword("given match") // TODO: drop + case SummonFrom(cases) => + this += highlightKeyword("summonFrom ") inBlock(printCases(cases, lineBreak())) case Try(body, cases, finallyOpt) => diff --git a/library/src/scala/quoted/QuoteContext.scala b/library/src/scala/quoted/QuoteContext.scala index e1ca3ada62e4..d39b8be7dc8d 100644 --- a/library/src/scala/quoted/QuoteContext.scala +++ b/library/src/scala/quoted/QuoteContext.scala @@ -95,7 +95,7 @@ trait QuoteContext { self: runtime.QuoteUnpickler & runtime.QuoteMatching => * | +- Closure * | +- If * | +- Match - * | +- GivenMatch + * | +- SummonFrom * | +- Try * | +- Return * | +- Repeated @@ -578,7 +578,6 @@ trait QuoteContext { self: runtime.QuoteUnpickler & runtime.QuoteMatching => */ def unique(qualifier: Term, name: String): Select - // TODO rename, this returns an Apply and not a Select /** Call an overloaded method with the given type and term parameters */ def overloaded(qualifier: Term, name: String, targs: List[TypeRepr], args: List[Term]): Apply @@ -1031,34 +1030,34 @@ trait QuoteContext { self: runtime.QuoteUnpickler & runtime.QuoteMatching => end extension end MatchMethods - /** Tree representing a pattern match `given match { ... }` in the source code */ // TODO: drop - type GivenMatch <: Term + /** Tree representing a summoning match `summonFrom { ... }` in the source code */ + type SummonFrom <: Term - given TypeTest[Tree, GivenMatch] = GivenMatchTypeTest - protected val GivenMatchTypeTest: TypeTest[Tree, GivenMatch] + given TypeTest[Tree, SummonFrom] = SummonFromTypeTest + protected val SummonFromTypeTest: TypeTest[Tree, SummonFrom] /** Scala implicit `match` term */ - val GivenMatch: GivenMatchModule + val SummonFrom: SummonFromModule - trait GivenMatchModule { this: GivenMatch.type => + trait SummonFromModule { this: SummonFrom.type => /** Creates a pattern match `given match { }` */ - def apply(cases: List[CaseDef]): GivenMatch + def apply(cases: List[CaseDef]): SummonFrom - def copy(original: Tree)(cases: List[CaseDef]): GivenMatch + def copy(original: Tree)(cases: List[CaseDef]): SummonFrom /** Matches a pattern match `given match { }` */ - def unapply(x: GivenMatch): Option[List[CaseDef]] + def unapply(x: SummonFrom): Option[List[CaseDef]] } - given GivenMatchMethods as GivenMatchMethods = GivenMatchMethodsImpl - protected val GivenMatchMethodsImpl: GivenMatchMethods + given SummonFromMethods as SummonFromMethods = SummonFromMethodsImpl + protected val SummonFromMethodsImpl: SummonFromMethods - trait GivenMatchMethods: - extension (self: GivenMatch): + trait SummonFromMethods: + extension (self: SummonFrom): def cases: List[CaseDef] end extension - end GivenMatchMethods + end SummonFromMethods /** Tree representing a try catch `try x catch { ... } finally { ... }` in the source code */ type Try <: Term