Skip to content

Update to new extension syntax #8240

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/Contexts.scala
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ object Contexts {
def setDebug: this.type = setSetting(base.settings.Ydebug, true)
}

given ops: extension (c: Context) with
extension ops on (c: Context) with
def addNotNullInfo(info: NotNullInfo) =
c.withNotNullInfos(c.notNullInfos.extendWith(info))

Expand Down
20 changes: 10 additions & 10 deletions compiler/src/dotty/tools/dotc/semanticdb/Scala3.scala
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ object Scala3 with

end Symbols

given NameOps: extension (name: Name) with
extension NameOps on (name: Name) with

def isWildcard = name match
case nme.WILDCARD | WILDCARDTypeName => true
Expand All @@ -87,9 +87,9 @@ object Scala3 with
case _ => false
}

end NameOps
// end NameOps

given SymbolOps: extension (sym: Symbol) with
extension SymbolOps on (sym: Symbol) with

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

Expand Down Expand Up @@ -126,7 +126,7 @@ object Scala3 with
def isAnnotation(given Context): Boolean =
sym.derivesFrom(defn.AnnotationClass)

end SymbolOps
// end SymbolOps

object LocalSymbol with

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

given StringOps: extension (symbol: String) with
extension StringOps on (symbol: String) with

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

end StringOps
// end StringOps

given InfoOps: extension (info: SymbolInformation) with
extension InfoOps on (info: SymbolInformation) with

def isAbstract: Boolean = (info.properties & SymbolInformation.Property.ABSTRACT.value) != 0
def isFinal: Boolean = (info.properties & SymbolInformation.Property.FINAL.value) != 0
Expand Down Expand Up @@ -205,11 +205,11 @@ object Scala3 with
def isTrait: Boolean = info.kind.isTrait
def isInterface: Boolean = info.kind.isInterface

end InfoOps
// end InfoOps

given RangeOps: extension (range: Range) with
extension RangeOps on (range: Range) with
def hasLength = range.endLine > range.startLine || range.endCharacter > range.startCharacter
end RangeOps
// end RangeOps

/** Sort symbol occurrences by their start position. */
given OccurrenceOrdering: Ordering[SymbolOccurrence] = (x, y) =>
Expand Down
10 changes: 5 additions & 5 deletions compiler/src/dotty/tools/dotc/typer/Nullables.scala
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ object Nullables with
// TODO: Add constant pattern if the constant type is not nullable
case _ => false

given notNullInfoOps: extension (infos: List[NotNullInfo]) with
extension notNullInfoOps on (infos: List[NotNullInfo]) with

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

given refOps: extension (ref: TermRef) with
extension refOps on (ref: TermRef) with

/** Is the use of a mutable variable out of order
*
Expand Down Expand Up @@ -245,7 +245,7 @@ object Nullables with
&& refOwner.isTerm
&& recur(curCtx.owner)

given treeOps: extension (tree: Tree) with
extension treeOps on (tree: Tree) with

/* The `tree` with added nullability attachment */
def withNotNullInfo(info: NotNullInfo): tree.type =
Expand Down Expand Up @@ -335,7 +335,7 @@ object Nullables with
tree.computeNullable()
}.traverse(tree)

given assignOps: extension (tree: Assign) with
extension assignOps on (tree: Assign) with
def computeAssignNullable()(given Context): tree.type = tree.lhs match
case TrackedRef(ref) =>
val rhstp = tree.rhs.typeOpt
Expand Down
4 changes: 2 additions & 2 deletions library/src/scala/internal/quoted/Matcher.scala
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,13 @@ private[quoted] object Matcher {
case _ => notMatched
}

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

private given treeOps: extension (scrutinee0: Tree) {
private extension treeOps on (scrutinee0: Tree) {

/** Check that the trees match and return the contents from the pattern holes.
* Return None if the trees do not match otherwise return Some of a tuple containing all the contents in the holes.
Expand Down
2 changes: 1 addition & 1 deletion library/src/scala/tasty/Reflection.scala
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self =>
// QUOTES //
////////////////

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