Skip to content

Commit b2c7905

Browse files
Merge pull request #10434 from dotty-staging/remove-given-match-from-reflection
Update GivenMatch to SummonFrom
2 parents 5af5be0 + 197cc82 commit b2c7905

File tree

4 files changed

+31
-32
lines changed

4 files changed

+31
-32
lines changed

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

+12-12
Original file line numberDiff line numberDiff line change
@@ -795,28 +795,28 @@ class QuoteContextImpl private (using val ctx: Context) extends QuoteContext, Qu
795795
end extension
796796
end MatchMethodsImpl
797797

798-
type GivenMatch = tpd.Match
798+
type SummonFrom = tpd.Match
799799

800-
object GivenMatchTypeTest extends TypeTest[Tree, GivenMatch]:
801-
def unapply(x: Tree): Option[GivenMatch & x.type] = x match
800+
object SummonFromTypeTest extends TypeTest[Tree, SummonFrom]:
801+
def unapply(x: Tree): Option[SummonFrom & x.type] = x match
802802
case x: (tpd.Match & x.type) if x.selector.isEmpty => Some(x)
803803
case _ => None
804-
end GivenMatchTypeTest
804+
end SummonFromTypeTest
805805

806-
object GivenMatch extends GivenMatchModule:
807-
def apply(cases: List[CaseDef]): GivenMatch =
806+
object SummonFrom extends SummonFromModule:
807+
def apply(cases: List[CaseDef]): SummonFrom =
808808
withDefaultPos(tpd.Match(tpd.EmptyTree, cases))
809-
def copy(original: Tree)(cases: List[CaseDef]): GivenMatch =
809+
def copy(original: Tree)(cases: List[CaseDef]): SummonFrom =
810810
tpd.cpy.Match(original)(tpd.EmptyTree, cases)
811-
def unapply(x: GivenMatch): Option[List[CaseDef]] =
811+
def unapply(x: SummonFrom): Option[List[CaseDef]] =
812812
Some(x.cases)
813-
end GivenMatch
813+
end SummonFrom
814814

815-
object GivenMatchMethodsImpl extends GivenMatchMethods:
816-
extension (self: GivenMatch):
815+
object SummonFromMethodsImpl extends SummonFromMethods:
816+
extension (self: SummonFrom):
817817
def cases: List[CaseDef] = self.cases
818818
end extension
819-
end GivenMatchMethodsImpl
819+
end SummonFromMethodsImpl
820820

821821
type Try = tpd.Try
822822

compiler/src/scala/quoted/runtime/impl/printers/Extractors.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ object Extractors {
9595
this += "Closure(" += meth += ", " += tpt += ")"
9696
case Match(selector, cases) =>
9797
this += "Match(" += selector += ", " ++= cases += ")"
98-
case GivenMatch(cases) =>
99-
this += "GivenMatch(" ++= cases += ")"
98+
case SummonFrom(cases) =>
99+
this += "SummonFrom(" ++= cases += ")"
100100
case Return(expr, from) =>
101101
this += "Return(" += expr += ", " += from += ")"
102102
case While(cond, body) =>

compiler/src/scala/quoted/runtime/impl/printers/SourceCode.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -486,8 +486,8 @@ object SourceCode {
486486
this += highlightKeyword(" match")
487487
inBlock(printCases(cases, lineBreak()))
488488

489-
case GivenMatch(cases) =>
490-
this += highlightKeyword("given match") // TODO: drop
489+
case SummonFrom(cases) =>
490+
this += highlightKeyword("summonFrom ")
491491
inBlock(printCases(cases, lineBreak()))
492492

493493
case Try(body, cases, finallyOpt) =>

library/src/scala/quoted/QuoteContext.scala

+15-16
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ trait QuoteContext { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
9595
* | +- Closure
9696
* | +- If
9797
* | +- Match
98-
* | +- GivenMatch
98+
* | +- SummonFrom
9999
* | +- Try
100100
* | +- Return
101101
* | +- Repeated
@@ -578,7 +578,6 @@ trait QuoteContext { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
578578
*/
579579
def unique(qualifier: Term, name: String): Select
580580

581-
// TODO rename, this returns an Apply and not a Select
582581
/** Call an overloaded method with the given type and term parameters */
583582
def overloaded(qualifier: Term, name: String, targs: List[TypeRepr], args: List[Term]): Apply
584583

@@ -1031,34 +1030,34 @@ trait QuoteContext { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
10311030
end extension
10321031
end MatchMethods
10331032

1034-
/** Tree representing a pattern match `given match { ... }` in the source code */ // TODO: drop
1035-
type GivenMatch <: Term
1033+
/** Tree representing a summoning match `summonFrom { ... }` in the source code */
1034+
type SummonFrom <: Term
10361035

1037-
given TypeTest[Tree, GivenMatch] = GivenMatchTypeTest
1038-
protected val GivenMatchTypeTest: TypeTest[Tree, GivenMatch]
1036+
given TypeTest[Tree, SummonFrom] = SummonFromTypeTest
1037+
protected val SummonFromTypeTest: TypeTest[Tree, SummonFrom]
10391038

10401039
/** Scala implicit `match` term */
1041-
val GivenMatch: GivenMatchModule
1040+
val SummonFrom: SummonFromModule
10421041

1043-
trait GivenMatchModule { this: GivenMatch.type =>
1042+
trait SummonFromModule { this: SummonFrom.type =>
10441043

10451044
/** Creates a pattern match `given match { <cases: List[CaseDef]> }` */
1046-
def apply(cases: List[CaseDef]): GivenMatch
1045+
def apply(cases: List[CaseDef]): SummonFrom
10471046

1048-
def copy(original: Tree)(cases: List[CaseDef]): GivenMatch
1047+
def copy(original: Tree)(cases: List[CaseDef]): SummonFrom
10491048

10501049
/** Matches a pattern match `given match { <cases: List[CaseDef]> }` */
1051-
def unapply(x: GivenMatch): Option[List[CaseDef]]
1050+
def unapply(x: SummonFrom): Option[List[CaseDef]]
10521051
}
10531052

1054-
given GivenMatchMethods as GivenMatchMethods = GivenMatchMethodsImpl
1055-
protected val GivenMatchMethodsImpl: GivenMatchMethods
1053+
given SummonFromMethods as SummonFromMethods = SummonFromMethodsImpl
1054+
protected val SummonFromMethodsImpl: SummonFromMethods
10561055

1057-
trait GivenMatchMethods:
1058-
extension (self: GivenMatch):
1056+
trait SummonFromMethods:
1057+
extension (self: SummonFrom):
10591058
def cases: List[CaseDef]
10601059
end extension
1061-
end GivenMatchMethods
1060+
end SummonFromMethods
10621061

10631062
/** Tree representing a try catch `try x catch { ... } finally { ... }` in the source code */
10641063
type Try <: Term

0 commit comments

Comments
 (0)