Skip to content

Commit c15978c

Browse files
committed
Use extension method syntax in Matcher and IArray
1 parent ea27220 commit c15978c

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

library/src-bootstrapped/scala/IArray.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import reflect.ClassTag
44
/** An immutable array. An `IArray[T]` has the same representation as an `Array[T]`,
55
* but it cannot be updated. Unlike regular arrays, immutable arrays are covariant.
66
*/
7-
object opaques {
7+
object opaques
88
opaque type IArray[+T] = Array[_ <: T]
99

1010
/** Defines extension methods for immutable arrays */
11-
given arrayOps: AnyRef {
11+
given arrayOps: Object with
1212

1313
/** The selection operation on an immutable array.
1414
*
@@ -38,8 +38,8 @@ object opaques {
3838
def (arr: IArray[Double]) length: Int = arr.asInstanceOf[Array[Double]].length
3939
def (arr: IArray[Object]) length: Int = arr.asInstanceOf[Array[Object]].length
4040
def [T](arr: IArray[T]) length: Int = arr.asInstanceOf[Array[T]].length
41-
}
42-
}
41+
end opaques
42+
4343
type IArray[+T] = opaques.IArray[T]
4444

4545
object IArray {

library/src/scala/internal/quoted/Matcher.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,15 @@ private[quoted] object Matcher {
8686
case _ => notMatched
8787
}
8888

89-
private given treeListOps: {
89+
private given treeListOps: extension (scrutinees: List[Tree]) with
9090

9191
/** Check that all trees match with =?= and concatenate the results with && */
92-
def (scrutinees: List[Tree]) =?= (patterns: List[Tree])(given Context, Env): Matching =
92+
def =?= (patterns: List[Tree])(given Context, Env): Matching =
9393
matchLists(scrutinees, patterns)(_ =?= _)
9494

95-
}
95+
end treeListOps
9696

97-
private given treeOps: {
97+
private given treeOps: extension (scrutinee0: Tree) with
9898

9999
/** Check that the trees match and return the contents from the pattern holes.
100100
* Return None if the trees do not match otherwise return Some of a tuple containing all the contents in the holes.
@@ -104,7 +104,7 @@ private[quoted] object Matcher {
104104
* @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`.
105105
* @return `None` if it did not match or `Some(tup: Tuple)` if it matched where `tup` contains the contents of the holes.
106106
*/
107-
def (scrutinee0: Tree) =?= (pattern0: Tree)(given Context, Env): Matching = {
107+
def =?= (pattern0: Tree)(given Context, Env): Matching = {
108108

109109
/** Normalize the tree */
110110
def normalize(tree: Tree): Tree = tree match {
@@ -275,7 +275,7 @@ private[quoted] object Matcher {
275275
notMatched
276276
}
277277
}
278-
}
278+
end treeOps
279279

280280
private def treeOptMatches(scrutinee: Option[Tree], pattern: Option[Tree])(given Context, Env): Matching = {
281281
(scrutinee, pattern) match {

0 commit comments

Comments
 (0)