Skip to content

Commit 2ce24c3

Browse files
committed
Update given syntax in the compiler and library
1 parent 11f53c7 commit 2ce24c3

File tree

30 files changed

+319
-319
lines changed

30 files changed

+319
-319
lines changed

compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ object DottyBackendInterface {
124124
requiredModule(className)
125125
}
126126

127-
given symExtensions as AnyRef:
127+
given symExtensions: AnyRef with
128128
extension (sym: Symbol):
129129

130130
def isInterface(using Context): Boolean = (sym.is(PureInterface)) || sym.is(Trait)

compiler/src/dotty/tools/dotc/Run.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
8585
private var myCtx = rootContext(using ictx)
8686

8787
/** The context created for this run */
88-
given runContext[Dummy_so_its_a_def] as Context = myCtx
88+
given runContext[Dummy_so_its_a_def]: Context = myCtx
8989
assert(runContext.runId <= Periods.MaxPossibleRunId)
9090

9191
private var myUnits: List[CompilationUnit] = _

compiler/src/dotty/tools/dotc/ast/Trees.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1553,7 +1553,7 @@ object Trees {
15531553
def applyOverloaded(
15541554
receiver: tpd.Tree, method: TermName, args: List[Tree], targs: List[Type],
15551555
expectedType: Type)(using parentCtx: Context): tpd.Tree = {
1556-
given ctx as Context = parentCtx.retractMode(Mode.ImplicitsEnabled)
1556+
given ctx: Context = parentCtx.retractMode(Mode.ImplicitsEnabled)
15571557
import dotty.tools.dotc.ast.tpd.TreeOps
15581558

15591559
val typer = ctx.typer

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ object Comments {
1515
val ContextDoc: Key[ContextDocstrings] = new Key[ContextDocstrings]
1616

1717
/** Decorator for getting docbase out of context */
18-
given CommentsContext as AnyRef:
18+
given CommentsContext: AnyRef with
1919
extension (c: Context) def docCtx: Option[ContextDocstrings] = c.property(ContextDoc)
2020

2121
/** Context for Docstrings, contains basic functionality for getting

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

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

652-
given ops as AnyRef:
652+
given ops: AnyRef with
653653
extension (c: Context):
654654
def addNotNullInfo(info: NotNullInfo) =
655655
c.withNotNullInfos(c.notNullInfos.extendWith(info))

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class Definitions {
3838
import Definitions._
3939

4040
private var initCtx: Context = _
41-
private given currentContext[Dummy_so_its_a_def] as Context = initCtx
41+
private given currentContext[Dummy_so_its_a_def]: Context = initCtx
4242

4343
private def newPermanentSymbol[N <: Name](owner: Symbol, name: N, flags: FlagSet, info: Type) =
4444
newSymbol(owner, name, flags | Permanent, info)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
3434
private var myContext: Context = initctx
3535
def comparerContext: Context = myContext
3636

37-
protected given [DummySoItsADef] as Context = myContext
37+
protected given [DummySoItsADef]: Context = myContext
3838

3939
protected var state: TyperState = null
4040
def constraint: Constraint = state.constraint

compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class PlainPrinter(_ctx: Context) extends Printer {
2121
* Overridden in RefinedPrinter.
2222
*/
2323
protected def curCtx: Context = _ctx.addMode(Mode.Printing)
24-
protected given [DummyToEnforceDef] as Context = curCtx
24+
protected given [DummyToEnforceDef]: Context = curCtx
2525

2626
protected def printDebug = ctx.settings.YprintDebug.value
2727

@@ -39,7 +39,7 @@ class PlainPrinter(_ctx: Context) extends Printer {
3939
limiter.register(str)
4040
Texts.Str(str, lineRange)
4141

42-
given stringToText as Conversion[String, Text] = Str(_)
42+
given stringToText: Conversion[String, Text] = Str(_)
4343

4444
/** If true, tweak output so it is the same before and after pickling */
4545
protected def homogenizedView: Boolean = ctx.settings.YtestPickler.value

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ object Scala3:
6868
end Symbols
6969

7070

71-
given NameOps as AnyRef:
71+
given NameOps: AnyRef with
7272
extension (name: Name):
7373
def isWildcard = name match
7474
case nme.WILDCARD | WILDCARDTypeName => true
@@ -89,7 +89,7 @@ object Scala3:
8989
}
9090
end NameOps
9191

92-
given SymbolOps as AnyRef:
92+
given SymbolOps: AnyRef with
9393
extension (sym: Symbol):
9494

9595
def ifExists(using Context): Option[Symbol] = if sym.exists then Some(sym) else None
@@ -145,7 +145,7 @@ object Scala3:
145145
case '/' | '.' | '#' | ']' | ')' => true
146146
case _ => false
147147

148-
given StringOps as AnyRef:
148+
given StringOps: AnyRef with
149149
extension (symbol: String):
150150
def isSymbol: Boolean = !symbol.isEmpty
151151
def isRootPackage: Boolean = RootPackage == symbol
@@ -169,7 +169,7 @@ object Scala3:
169169
isJavaIdentifierStart(symbol.head) && symbol.tail.forall(isJavaIdentifierPart)
170170
end StringOps
171171

172-
given InfoOps as AnyRef:
172+
given InfoOps: AnyRef with
173173
extension (info: SymbolInformation):
174174
def isAbstract: Boolean = (info.properties & SymbolInformation.Property.ABSTRACT.value) != 0
175175
def isFinal: Boolean = (info.properties & SymbolInformation.Property.FINAL.value) != 0
@@ -204,13 +204,13 @@ object Scala3:
204204
def isInterface: Boolean = info.kind.isInterface
205205
end InfoOps
206206

207-
given RangeOps as AnyRef:
207+
given RangeOps: AnyRef with
208208
extension (range: Range):
209209
def hasLength = range.endLine > range.startLine || range.endCharacter > range.startCharacter
210210
end RangeOps
211211

212212
/** Sort symbol occurrences by their start position. */
213-
given OccurrenceOrdering as Ordering[SymbolOccurrence] = (x, y) =>
213+
given OccurrenceOrdering: Ordering[SymbolOccurrence] = (x, y) =>
214214
x.range -> y.range match
215215
case None -> _ | _ -> None => 0
216216
case Some(a) -> Some(b) =>

compiler/src/dotty/tools/dotc/transform/ExplicitOuter.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ object ExplicitOuter {
353353
*/
354354
class OuterOps(val ictx: Context) extends AnyVal {
355355
/** The context of all operations of this class */
356-
given [Dummy] as Context = ictx
356+
given [Dummy]: Context = ictx
357357

358358
/** If `cls` has an outer parameter add one to the method type `tp`. */
359359
def addParam(cls: ClassSymbol, tp: Type): Type =

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,11 @@ trait Deriving {
125125
//
126126
// ADT: C[A, B] (A, B have same kinds at T, U)
127127
//
128-
// given derived$TC as TC[ C ] // a "natural" instance
128+
// given derived$TC : TC[ C ] // a "natural" instance
129129
//
130130
// ADT: C[A] (A has same kind as U)
131131
//
132-
// given derived$TC as TC[[t, u] =>> C[ u]]
132+
// given derived$TC : TC[[t, u] =>> C[ u]]
133133
//
134134
// (b) The type class and all ADT type parameters are of kind *
135135
//

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ class Namer { typer: Typer =>
669669
protected def localContext(owner: Symbol): FreshContext = ctx.fresh.setOwner(owner).setTree(original)
670670

671671
/** The context with which this completer was created */
672-
given creationContext as Context = ictx
672+
given creationContext: Context = ictx
673673

674674
// make sure testing contexts are not captured by completers
675675
assert(!ictx.reporter.isInstanceOf[ExploringReporter])
@@ -835,7 +835,7 @@ class Namer { typer: Typer =>
835835

836836
override final def typeSig(sym: Symbol): Type =
837837
val tparamSyms = completerTypeParams(sym)(using ictx)
838-
given ctx as Context = nestedCtx
838+
given ctx: Context = nestedCtx
839839

840840
def abstracted(tp: TypeBounds): TypeBounds =
841841
HKTypeLambda.boundsFromParams(tparamSyms, tp)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ object PrepareInlineable {
236236
if (!ctx.isAfterTyper) {
237237
val inlineCtx = ctx
238238
inlined.updateAnnotation(LazyBodyAnnotation {
239-
given ctx as Context = inlineCtx
239+
given ctx: Context = inlineCtx
240240
var inlinedBody = dropInlineIfError(inlined, treeExpr)
241241
if inlined.isInlineMethod then
242242
inlinedBody = dropInlineIfError(inlined,

compiler/test/dotty/tools/repl/ReplCompilerTests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ class ReplCompilerTests extends ReplTest {
174174
| extension (x: T) def > (y: T) = compare(x, y) > 0
175175
|}
176176
|
177-
|given IntOrd as Ord[Int] {
177+
|given IntOrd: Ord[Int] with {
178178
| def compare(x: Int, y: Int) =
179179
| if (x < y) -1 else if (x > y) +1 else 0
180180
|}

docs/docs/reference/metaprogramming/erased-terms-spec.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ title: "Erased Terms Spec"
3232

3333
3. Functions
3434
* `(erased x1: T1, x2: T2, ..., xN: TN) => y : (erased T1, T2, ..., TN) => R`
35-
* `(given erased x1: T1, x2: T2, ..., xN: TN) => y as (given erased T1, T2, ..., TN) => R`
35+
* `(given erased x1: T1, x2: T2, ..., xN: TN) => y: (given erased T1, T2, ..., TN) => R`
3636
* `(given erased T1) => R <:< erased T1 => R`
3737
* `(given erased T1, T2) => R <:< (erased T1, T2) => R`
3838
* ...

0 commit comments

Comments
 (0)