Skip to content

Commit 3da2ffc

Browse files
Merge pull request #7245 from dotty-staging/drop-old-given
Drop old syntax styles for givens
2 parents dbeba79 + 4d79c90 commit 3da2ffc

File tree

171 files changed

+1982
-2139
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

171 files changed

+1982
-2139
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,10 @@ class GenBCodePipeline(val int: DottyBackendInterface)(implicit val ctx: Context
161161
val same = classSymbol.effectiveName.toString == dupClassSym.effectiveName.toString
162162
ctx.atPhase(ctx.typerPhase) {
163163
if (same)
164-
the[Context].warning( // FIXME: This should really be an error, but then FromTasty tests fail
164+
summon[Context].warning( // FIXME: This should really be an error, but then FromTasty tests fail
165165
s"${cl1.show} and ${cl2.showLocated} produce classes that overwrite one another", cl1.sourcePos)
166166
else
167-
the[Context].warning(s"${cl1.show} differs only in case from ${cl2.showLocated}. " +
167+
summon[Context].warning(s"${cl1.show} differs only in case from ${cl2.showLocated}. " +
168168
"Such classes will overwrite one another on case-insensitive filesystems.", cl1.sourcePos)
169169
}
170170
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,7 @@ object desugar {
893893
* If the given member `mdef` is not of this form, flag it as an error.
894894
*/
895895

896-
def makeExtensionDef(mdef: Tree, tparams: List[TypeDef], leadingParams: List[ValDef]) given (ctx: Context): Tree = {
896+
def makeExtensionDef(mdef: Tree, tparams: List[TypeDef], leadingParams: List[ValDef])(given ctx: Context): Tree = {
897897
val allowed = "allowed here, since collective parameters are given"
898898
mdef match {
899899
case mdef: DefDef =>
@@ -933,7 +933,7 @@ object desugar {
933933

934934
/** Invent a name for an anonympus given of type or template `impl`. */
935935
def inventGivenName(impl: Tree)(implicit ctx: Context): SimpleName =
936-
avoidIllegalChars(s"${inventName(impl)}_given".toTermName.asSimpleName)
936+
avoidIllegalChars(s"given_${inventName(impl)}".toTermName.asSimpleName)
937937

938938
/** The normalized name of `mdef`. This means
939939
* 1. Check that the name does not redefine a Scala core class.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import ast.Trees._
2626
*/
2727
object MainProxies {
2828

29-
def mainProxies(stats: List[tpd.Tree]) given Context: List[untpd.Tree] = {
29+
def mainProxies(stats: List[tpd.Tree])(given Context): List[untpd.Tree] = {
3030
import tpd._
3131
def mainMethods(stats: List[Tree]): List[Symbol] = stats.flatMap {
3232
case stat: DefDef if stat.symbol.hasAnnotation(defn.MainAnnot) =>
@@ -40,7 +40,7 @@ object MainProxies {
4040
}
4141

4242
import untpd._
43-
def mainProxy(mainFun: Symbol) given (ctx: Context): List[TypeDef] = {
43+
def mainProxy(mainFun: Symbol)(given ctx: Context): List[TypeDef] = {
4444
val mainAnnotSpan = mainFun.getAnnotation(defn.MainAnnot).get.tree.span
4545
def pos = mainFun.sourcePos
4646
val argsRef = Ident(nme.args)

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import util.Spans.Span
1010

1111
object Annotations {
1212

13-
def annotClass(tree: Tree) given Context =
13+
def annotClass(tree: Tree)(given Context) =
1414
if (tree.symbol.isConstructor) tree.symbol.owner
1515
else tree.tpe.typeSymbol
1616

@@ -121,7 +121,7 @@ object Annotations {
121121
def deferred(sym: Symbol)(treeFn: ImplicitFunction1[Context, Tree])(implicit ctx: Context): Annotation =
122122
new LazyAnnotation {
123123
override def symbol(implicit ctx: Context): Symbol = sym
124-
def complete(implicit ctx: Context) = treeFn given ctx
124+
def complete(implicit ctx: Context) = treeFn(given ctx)
125125
}
126126

127127
/** Create an annotation where the symbol and the tree are computed lazily. */
@@ -131,12 +131,12 @@ object Annotations {
131131

132132
override def symbol(implicit ctx: Context): Symbol = {
133133
if (mySym == null || mySym.defRunId != ctx.runId) {
134-
mySym = symf given ctx
134+
mySym = symf(given ctx)
135135
assert(mySym != null)
136136
}
137137
mySym
138138
}
139-
def complete(implicit ctx: Context) = treeFn given ctx
139+
def complete(implicit ctx: Context) = treeFn(given ctx)
140140
}
141141

142142
def deferred(atp: Type, args: List[Tree])(implicit ctx: Context): Annotation =

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ object Decorators {
174174
def (x: T) reporting[T](
175175
op: ImplicitFunction1[WrappedResult[T], String],
176176
printer: config.Printers.Printer = config.Printers.default): T = {
177-
printer.println(op given WrappedResult(x))
177+
printer.println(op(given WrappedResult(x)))
178178
x
179179
}
180180
}

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

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,13 @@ class Definitions {
9898
* ErasedFunctionN traits follow this template:
9999
*
100100
* trait ErasedFunctionN[T0,...,T{N-1}, R] extends Object {
101-
* def apply erased ($x0: T0, ..., $x{N_1}: T{N-1}): R
101+
* def apply(erased $x0: T0, ..., $x{N_1}: T{N-1}): R
102102
* }
103103
*
104104
* ErasedImplicitFunctionN traits follow this template:
105105
*
106106
* trait ErasedImplicitFunctionN[T0,...,T{N-1}, R] extends Object {
107-
* def apply given erased ($x0: T0, ..., $x{N_1}: T{N-1}): R
107+
* def apply (given erased $x0: T0, ..., $x{N_1}: T{N-1}): R
108108
* }
109109
*
110110
* ErasedFunctionN and ErasedImplicitFunctionN erase to Function0.
@@ -403,7 +403,7 @@ class Definitions {
403403

404404
@tu lazy val CollectionSeqType: TypeRef = ctx.requiredClassRef("scala.collection.Seq")
405405
@tu lazy val SeqType: TypeRef = ctx.requiredClassRef("scala.collection.immutable.Seq")
406-
def SeqClass given Context: ClassSymbol = SeqType.symbol.asClass
406+
def SeqClass(given Context): ClassSymbol = SeqType.symbol.asClass
407407
@tu lazy val Seq_apply : Symbol = SeqClass.requiredMethod(nme.apply)
408408
@tu lazy val Seq_head : Symbol = SeqClass.requiredMethod(nme.head)
409409
@tu lazy val Seq_drop : Symbol = SeqClass.requiredMethod(nme.drop)
@@ -412,7 +412,7 @@ class Definitions {
412412
@tu lazy val Seq_toSeq : Symbol = SeqClass.requiredMethod(nme.toSeq)
413413

414414
@tu lazy val ArrayType: TypeRef = ctx.requiredClassRef("scala.Array")
415-
def ArrayClass given Context: ClassSymbol = ArrayType.symbol.asClass
415+
def ArrayClass(given Context): ClassSymbol = ArrayType.symbol.asClass
416416
@tu lazy val Array_apply : Symbol = ArrayClass.requiredMethod(nme.apply)
417417
@tu lazy val Array_update : Symbol = ArrayClass.requiredMethod(nme.update)
418418
@tu lazy val Array_length : Symbol = ArrayClass.requiredMethod(nme.length)
@@ -422,10 +422,10 @@ class Definitions {
422422
@tu lazy val ArrayModule: Symbol = ctx.requiredModule("scala.Array")
423423

424424
@tu lazy val UnitType: TypeRef = valueTypeRef("scala.Unit", java.lang.Void.TYPE, UnitEnc, nme.specializedTypeNames.Void)
425-
def UnitClass given Context: ClassSymbol = UnitType.symbol.asClass
426-
def UnitModuleClass given Context: Symbol = UnitType.symbol.asClass.linkedClass
425+
def UnitClass(given Context): ClassSymbol = UnitType.symbol.asClass
426+
def UnitModuleClass(given Context): Symbol = UnitType.symbol.asClass.linkedClass
427427
@tu lazy val BooleanType: TypeRef = valueTypeRef("scala.Boolean", java.lang.Boolean.TYPE, BooleanEnc, nme.specializedTypeNames.Boolean)
428-
def BooleanClass given Context: ClassSymbol = BooleanType.symbol.asClass
428+
def BooleanClass(given Context): ClassSymbol = BooleanType.symbol.asClass
429429
@tu lazy val Boolean_! : Symbol = BooleanClass.requiredMethod(nme.UNARY_!)
430430
@tu lazy val Boolean_&& : Symbol = BooleanClass.requiredMethod(nme.ZAND) // ### harmonize required... calls
431431
@tu lazy val Boolean_|| : Symbol = BooleanClass.requiredMethod(nme.ZOR)
@@ -441,13 +441,13 @@ class Definitions {
441441
}).symbol
442442

443443
@tu lazy val ByteType: TypeRef = valueTypeRef("scala.Byte", java.lang.Byte.TYPE, ByteEnc, nme.specializedTypeNames.Byte)
444-
def ByteClass given Context: ClassSymbol = ByteType.symbol.asClass
444+
def ByteClass(given Context): ClassSymbol = ByteType.symbol.asClass
445445
@tu lazy val ShortType: TypeRef = valueTypeRef("scala.Short", java.lang.Short.TYPE, ShortEnc, nme.specializedTypeNames.Short)
446-
def ShortClass given Context: ClassSymbol = ShortType.symbol.asClass
446+
def ShortClass(given Context): ClassSymbol = ShortType.symbol.asClass
447447
@tu lazy val CharType: TypeRef = valueTypeRef("scala.Char", java.lang.Character.TYPE, CharEnc, nme.specializedTypeNames.Char)
448-
def CharClass given Context: ClassSymbol = CharType.symbol.asClass
448+
def CharClass(given Context): ClassSymbol = CharType.symbol.asClass
449449
@tu lazy val IntType: TypeRef = valueTypeRef("scala.Int", java.lang.Integer.TYPE, IntEnc, nme.specializedTypeNames.Int)
450-
def IntClass given Context: ClassSymbol = IntType.symbol.asClass
450+
def IntClass(given Context): ClassSymbol = IntType.symbol.asClass
451451
@tu lazy val Int_- : Symbol = IntClass.requiredMethod(nme.MINUS, List(IntType))
452452
@tu lazy val Int_+ : Symbol = IntClass.requiredMethod(nme.PLUS, List(IntType))
453453
@tu lazy val Int_/ : Symbol = IntClass.requiredMethod(nme.DIV, List(IntType))
@@ -456,18 +456,18 @@ class Definitions {
456456
@tu lazy val Int_>= : Symbol = IntClass.requiredMethod(nme.GE, List(IntType))
457457
@tu lazy val Int_<= : Symbol = IntClass.requiredMethod(nme.LE, List(IntType))
458458
@tu lazy val LongType: TypeRef = valueTypeRef("scala.Long", java.lang.Long.TYPE, LongEnc, nme.specializedTypeNames.Long)
459-
def LongClass given Context: ClassSymbol = LongType.symbol.asClass
459+
def LongClass(given Context): ClassSymbol = LongType.symbol.asClass
460460
@tu lazy val Long_+ : Symbol = LongClass.requiredMethod(nme.PLUS, List(LongType))
461461
@tu lazy val Long_* : Symbol = LongClass.requiredMethod(nme.MUL, List(LongType))
462462
@tu lazy val Long_/ : Symbol = LongClass.requiredMethod(nme.DIV, List(LongType))
463463

464464
@tu lazy val FloatType: TypeRef = valueTypeRef("scala.Float", java.lang.Float.TYPE, FloatEnc, nme.specializedTypeNames.Float)
465-
def FloatClass given Context: ClassSymbol = FloatType.symbol.asClass
465+
def FloatClass(given Context): ClassSymbol = FloatType.symbol.asClass
466466
@tu lazy val DoubleType: TypeRef = valueTypeRef("scala.Double", java.lang.Double.TYPE, DoubleEnc, nme.specializedTypeNames.Double)
467-
def DoubleClass given Context: ClassSymbol = DoubleType.symbol.asClass
467+
def DoubleClass(given Context): ClassSymbol = DoubleType.symbol.asClass
468468

469469
@tu lazy val BoxedUnitClass: ClassSymbol = ctx.requiredClass("scala.runtime.BoxedUnit")
470-
def BoxedUnit_UNIT given Context: TermSymbol = BoxedUnitClass.linkedClass.requiredValue("UNIT")
470+
def BoxedUnit_UNIT(given Context): TermSymbol = BoxedUnitClass.linkedClass.requiredValue("UNIT")
471471

472472
@tu lazy val BoxedBooleanClass: ClassSymbol = ctx.requiredClass("java.lang.Boolean")
473473
@tu lazy val BoxedByteClass : ClassSymbol = ctx.requiredClass("java.lang.Byte")
@@ -533,9 +533,9 @@ class Definitions {
533533
// in scalac modified to have Any as parent
534534

535535
@tu lazy val ThrowableType: TypeRef = ctx.requiredClassRef("java.lang.Throwable")
536-
def ThrowableClass given Context: ClassSymbol = ThrowableType.symbol.asClass
536+
def ThrowableClass(given Context): ClassSymbol = ThrowableType.symbol.asClass
537537
@tu lazy val SerializableType: TypeRef = JavaSerializableClass.typeRef
538-
def SerializableClass given Context: ClassSymbol = SerializableType.symbol.asClass
538+
def SerializableClass(given Context): ClassSymbol = SerializableType.symbol.asClass
539539

540540
@tu lazy val JavaEnumClass: ClassSymbol = {
541541
val cls = ctx.requiredClass("java.lang.Enum")

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ abstract class Periods { self: Context =>
2222

2323
/** Execute `op` at given phase id */
2424
def atPhase[T](pid: PhaseId)(op: ImplicitFunction1[Context, T]): T =
25-
op given ctx.withPhase(pid)
25+
op(given ctx.withPhase(pid))
2626

2727
/** The period containing the current period where denotations do not change.
2828
* We compute this by taking as first phase the first phase less or equal to

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ trait Phases {
3737
def atNextPhase[T](op: ImplicitFunction1[Context, T]): T = atPhase(phase.next)(op)
3838

3939
def atPhaseNotLaterThan[T](limit: Phase)(op: ImplicitFunction1[Context, T]): T =
40-
if (!limit.exists || phase <= limit) op given this else atPhase(limit)(op)
40+
if (!limit.exists || phase <= limit) op(given this) else atPhase(limit)(op)
4141

4242
def isAfterTyper: Boolean = base.isAfterTyper(phase)
4343
}

0 commit comments

Comments
 (0)