Skip to content

Commit 1830567

Browse files
authored
Merge pull request #8240 from dotty-staging/update-to-new-extension-syntax
Update to new extension syntax
2 parents 6afa1bd + d8728be commit 1830567

File tree

5 files changed

+19
-19
lines changed

5 files changed

+19
-19
lines changed

compiler/src/dotty/tools/dotc/core/Contexts.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ object Contexts {
599599
def setDebug: this.type = setSetting(base.settings.Ydebug, true)
600600
}
601601

602-
given ops: extension (c: Context) with
602+
extension ops on (c: Context) with
603603
def addNotNullInfo(info: NotNullInfo) =
604604
c.withNotNullInfos(c.notNullInfos.extendWith(info))
605605

compiler/src/dotty/tools/dotc/semanticdb/Scala3.scala

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ object Scala3 with
6767

6868
end Symbols
6969

70-
given NameOps: extension (name: Name) with
70+
extension NameOps on (name: Name) with
7171

7272
def isWildcard = name match
7373
case nme.WILDCARD | WILDCARDTypeName => true
@@ -87,9 +87,9 @@ object Scala3 with
8787
case _ => false
8888
}
8989

90-
end NameOps
90+
// end NameOps
9191

92-
given SymbolOps: extension (sym: Symbol) with
92+
extension SymbolOps on (sym: Symbol) with
9393

9494
def ifExists(given Context): Option[Symbol] = if sym.exists then Some(sym) else None
9595

@@ -126,7 +126,7 @@ object Scala3 with
126126
def isAnnotation(given Context): Boolean =
127127
sym.derivesFrom(defn.AnnotationClass)
128128

129-
end SymbolOps
129+
// end SymbolOps
130130

131131
object LocalSymbol with
132132

@@ -146,7 +146,7 @@ object Scala3 with
146146
case '/' | '.' | '#' | ']' | ')' => true
147147
case _ => false
148148

149-
given StringOps: extension (symbol: String) with
149+
extension StringOps on (symbol: String) with
150150

151151
def isSymbol: Boolean = !symbol.isEmpty
152152
def isRootPackage: Boolean = RootPackage == symbol
@@ -169,9 +169,9 @@ object Scala3 with
169169
def isJavaIdent =
170170
isJavaIdentifierStart(symbol.head) && symbol.tail.forall(isJavaIdentifierPart)
171171

172-
end StringOps
172+
// end StringOps
173173

174-
given InfoOps: extension (info: SymbolInformation) with
174+
extension InfoOps on (info: SymbolInformation) with
175175

176176
def isAbstract: Boolean = (info.properties & SymbolInformation.Property.ABSTRACT.value) != 0
177177
def isFinal: Boolean = (info.properties & SymbolInformation.Property.FINAL.value) != 0
@@ -205,11 +205,11 @@ object Scala3 with
205205
def isTrait: Boolean = info.kind.isTrait
206206
def isInterface: Boolean = info.kind.isInterface
207207

208-
end InfoOps
208+
// end InfoOps
209209

210-
given RangeOps: extension (range: Range) with
210+
extension RangeOps on (range: Range) with
211211
def hasLength = range.endLine > range.startLine || range.endCharacter > range.startCharacter
212-
end RangeOps
212+
// end RangeOps
213213

214214
/** Sort symbol occurrences by their start position. */
215215
given OccurrenceOrdering: Ordering[SymbolOccurrence] = (x, y) =>

compiler/src/dotty/tools/dotc/typer/Nullables.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ object Nullables with
160160
// TODO: Add constant pattern if the constant type is not nullable
161161
case _ => false
162162

163-
given notNullInfoOps: extension (infos: List[NotNullInfo]) with
163+
extension notNullInfoOps on (infos: List[NotNullInfo]) with
164164

165165
/** Do the current not-null infos imply that `ref` is not null?
166166
* Not-null infos are as a history where earlier assertions and retractions replace
@@ -189,9 +189,9 @@ object Nullables with
189189
val mutables = infos.foldLeft(Set[TermRef]())((ms, info) =>
190190
ms.union(info.asserted.filter(_.symbol.is(Mutable))))
191191
infos.extendWith(NotNullInfo(Set(), mutables))
192-
end notNullInfoOps
192+
// end notNullInfoOps
193193

194-
given refOps: extension (ref: TermRef) with
194+
extension refOps on (ref: TermRef) with
195195

196196
/** Is the use of a mutable variable out of order
197197
*
@@ -245,7 +245,7 @@ object Nullables with
245245
&& refOwner.isTerm
246246
&& recur(curCtx.owner)
247247

248-
given treeOps: extension (tree: Tree) with
248+
extension treeOps on (tree: Tree) with
249249

250250
/* The `tree` with added nullability attachment */
251251
def withNotNullInfo(info: NotNullInfo): tree.type =
@@ -335,7 +335,7 @@ object Nullables with
335335
tree.computeNullable()
336336
}.traverse(tree)
337337

338-
given assignOps: extension (tree: Assign) with
338+
extension assignOps on (tree: Assign) with
339339
def computeAssignNullable()(given Context): tree.type = tree.lhs match
340340
case TrackedRef(ref) =>
341341
val rhstp = tree.rhs.typeOpt

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,13 @@ private[quoted] object Matcher {
9696
case _ => notMatched
9797
}
9898

99-
private given treeListOps: extension (scrutinees: List[Tree]) {
99+
private extension treeListOps on (scrutinees: List[Tree]) {
100100
/** Check that all trees match with =?= and concatenate the results with && */
101101
def =?= (patterns: List[Tree])(using Context, Env): Matching =
102102
matchLists(scrutinees, patterns)(_ =?= _)
103103
}
104104

105-
private given treeOps: extension (scrutinee0: Tree) {
105+
private extension treeOps on (scrutinee0: Tree) {
106106

107107
/** Check that the trees match and return the contents from the pattern holes.
108108
* Return None if the trees do not match otherwise return Some of a tuple containing all the contents in the holes.

library/src/scala/tasty/Reflection.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self =>
419419
// QUOTES //
420420
////////////////
421421

422-
given QuotedExprOps: extension (expr: scala.quoted.Expr[?]) {
422+
extension QuotedExprOps on (expr: scala.quoted.Expr[?]) {
423423
/** View this expression `quoted.Expr[T]` as a `Term` */
424424
def unseal(using ctx: Context): Term =
425425
internal.QuotedExpr_unseal(expr)

0 commit comments

Comments
 (0)