Skip to content

Commit 9c218d0

Browse files
committed
Realign stars munged by cut-paste
1 parent 12d87df commit 9c218d0

File tree

1 file changed

+36
-37
lines changed

1 file changed

+36
-37
lines changed

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

Lines changed: 36 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,13 @@ class QuoteMatcher(debug: Boolean) {
116116
private type MatchingExprs = Seq[MatchResult]
117117

118118
/** TODO-18271: update
119-
* A map relating equivalent symbols from the scrutinee and the pattern
120-
* For example in
121-
* ```
122-
* '{val a = 4; a * a} match case '{ val x = 4; x * x }
123-
* ```
124-
* when matching `a * a` with `x * x` the environment will contain `Map(a -> x)`.
125-
*/
119+
* A map relating equivalent symbols from the scrutinee and the pattern
120+
* For example in
121+
* ```
122+
* '{val a = 4; a * a} match case '{ val x = 4; x * x }
123+
* ```
124+
* when matching `a * a` with `x * x` the environment will contain `Map(a -> x)`.
125+
*/
126126
private case class Env(val termEnv: Map[Symbol, Symbol], val typeEnv: Map[Symbol, Symbol])
127127

128128
private def withEnv[T](env: Env)(body: Env ?=> T): T = body(using env)
@@ -198,14 +198,14 @@ class QuoteMatcher(debug: Boolean) {
198198
extension (scrutinee0: Tree)
199199

200200
/** Check that the trees match and return the contents from the pattern holes.
201-
* Return a sequence containing all the contents in the holes.
202-
* If it does not match, continues to the `optional` with `None`.
203-
*
204-
* @param scrutinee The tree being matched
205-
* @param pattern The pattern tree that the scrutinee should match. Contains `patternHole` holes.
206-
* @param `summon[Env]` Set of tuples containing pairs of symbols (s, p) where s defines a symbol in `scrutinee` which corresponds to symbol p in `pattern`.
207-
* @return The sequence with the contents of the holes of the matched expression.
208-
*/
201+
* Return a sequence containing all the contents in the holes.
202+
* If it does not match, continues to the `optional` with `None`.
203+
*
204+
* @param scrutinee The tree being matched
205+
* @param pattern The pattern tree that the scrutinee should match. Contains `patternHole` holes.
206+
* @param `summon[Env]` Set of tuples containing pairs of symbols (s, p) where s defines a symbol in `scrutinee` which corresponds to symbol p in `pattern`.
207+
* @return The sequence with the contents of the holes of the matched expression.
208+
*/
209209
private def =?= (pattern0: Tree)(using Env, Context): optional[MatchingExprs] =
210210

211211
/* Match block flattening */ // TODO move to cases
@@ -238,19 +238,19 @@ class QuoteMatcher(debug: Boolean) {
238238
case _ => None
239239
end TypeTreeTypeTest
240240

241-
/* Some of method symbols in arguments of higher-order term hole are eta-expanded.
242-
* e.g.
243-
* g: (Int) => Int
244-
* => {
245-
* def $anonfun(y: Int): Int = g(y)
246-
* closure($anonfun)
247-
* }
248-
*
249-
* f: (using Int) => Int
250-
* => f(using x)
251-
* This function restores the symbol of the original method from
252-
* the eta-expanded function.
253-
*/
241+
/** Some of method symbols in arguments of higher-order term hole are eta-expanded.
242+
* e.g.
243+
* g: (Int) => Int
244+
* => {
245+
* def $anonfun(y: Int): Int = g(y)
246+
* closure($anonfun)
247+
* }
248+
*
249+
* f: (using Int) => Int
250+
* => f(using x)
251+
* This function restores the symbol of the original method from
252+
* the eta-expanded function.
253+
*/
254254
def getCapturedIdent(arg: Tree)(using Context): Ident =
255255
arg match
256256
case id: Ident => id
@@ -552,10 +552,10 @@ class QuoteMatcher(debug: Boolean) {
552552
end extension
553553

554554
/** Does the scrutinee symbol match the pattern symbol? It matches if:
555-
* - They are the same symbol
556-
* - The scrutinee has is in the environment and they are equivalent
557-
* - The scrutinee overrides the symbol of the pattern
558-
*/
555+
* - They are the same symbol
556+
* - The scrutinee is in the environment and they are equivalent
557+
* - The scrutinee overrides the symbol of the pattern
558+
*/
559559
private def symbolMatch(scrutineeTree: Tree, patternTree: Tree)(using Env, Context): Boolean =
560560
val scrutinee = scrutineeTree.symbol
561561

@@ -675,11 +675,10 @@ class QuoteMatcher(debug: Boolean) {
675675
treeMap = new TreeMap {
676676
override def transform(tree: Tree)(using Context): Tree =
677677
tree match
678-
/*
679-
* When matching a method call `f(0)` against a HOAS pattern `p(g)` where
680-
* f has a method type `(x: Int): Int` and `f` maps to `g`, `p` should hold
681-
* `g.apply(0)` because the type of `g` is `Int => Int` due to eta expansion.
682-
*/
678+
/* When matching a method call `f(0)` against a HOAS pattern `p(g)` where
679+
* f has a method type `(x: Int): Int` and `f` maps to `g`, `p` should hold
680+
* `g.apply(0)` because the type of `g` is `Int => Int` due to eta expansion.
681+
*/
683682
case Apply(fun, args) if termEnv.contains(tree.symbol) => transform(fun).select(nme.apply).appliedToArgs(args.map(transform))
684683
case tree: Ident => termEnv.get(tree.symbol).flatMap(argsMap.get).getOrElse(tree)
685684
case tree => super.transform(tree)

0 commit comments

Comments
 (0)