Skip to content

Commit 87fd49a

Browse files
committed
Avoid infix operations with more than one argument on the right. The
idiom x op (y, z) will in the future be interpreted as taking a tuple `(y, z)`. So all infix operations with more than one parameter have to be rewritten to method calls. This was for the most part done using an automatic rewrite (introduced in one of the next commits). Most of the tests were not re-formatted afterwards so one sees the traces of the rewrite. E.g. the reqrite would yield x .op (y, z) instead of the more idiomatic x.op(y. z)
1 parent f8d371c commit 87fd49a

21 files changed

+47
-47
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ object Denotations {
553553
val r = mergeDenot(this, that)
554554
if (r.exists) r else MultiDenotation(this, that)
555555
case that @ MultiDenotation(denot1, denot2) =>
556-
this & (denot1, pre) & (denot2, pre)
556+
this .& (denot1, pre) .& (denot2, pre)
557557
}
558558
}
559559

@@ -634,11 +634,11 @@ object Denotations {
634634
else if (!that.exists) that
635635
else this match {
636636
case denot1 @ MultiDenotation(denot11, denot12) =>
637-
denot1.derivedUnionDenotation(denot11 | (that, pre), denot12 | (that, pre))
637+
denot1.derivedUnionDenotation(denot11 .| (that, pre), denot12 .| (that, pre))
638638
case denot1: SingleDenotation =>
639639
that match {
640640
case denot2 @ MultiDenotation(denot21, denot22) =>
641-
denot2.derivedUnionDenotation(this | (denot21, pre), this | (denot22, pre))
641+
denot2.derivedUnionDenotation(this .| (denot21, pre), this .| (denot22, pre))
642642
case denot2: SingleDenotation =>
643643
unionDenot(denot1, denot2)
644644
}
@@ -1180,7 +1180,7 @@ object Denotations {
11801180
final case class DenotUnion(denot1: PreDenotation, denot2: PreDenotation) extends MultiPreDenotation {
11811181
def exists = true
11821182
def toDenot(pre: Type)(implicit ctx: Context) =
1183-
(denot1 toDenot pre) & (denot2 toDenot pre, pre)
1183+
(denot1 toDenot pre) .& (denot2 toDenot pre, pre)
11841184
def containsSym(sym: Symbol) =
11851185
(denot1 containsSym sym) || (denot2 containsSym sym)
11861186
type AsSeenFromResult = PreDenotation
@@ -1218,8 +1218,8 @@ object Denotations {
12181218
def hasAltWith(p: SingleDenotation => Boolean): Boolean =
12191219
denot1.hasAltWith(p) || denot2.hasAltWith(p)
12201220
def accessibleFrom(pre: Type, superAccess: Boolean)(implicit ctx: Context): Denotation = {
1221-
val d1 = denot1 accessibleFrom (pre, superAccess)
1222-
val d2 = denot2 accessibleFrom (pre, superAccess)
1221+
val d1 = denot1.accessibleFrom(pre, superAccess)
1222+
val d2 = denot2.accessibleFrom(pre, superAccess)
12231223
if (!d1.exists) d2
12241224
else if (!d2.exists) d1
12251225
else derivedUnionDenotation(d1, d2)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ object NameOps {
121121

122122
/** If flags is a ModuleClass but not a Package, add module class suffix */
123123
def adjustIfModuleClass(flags: Flags.FlagSet): N = likeSpaced {
124-
if (flags is (ModuleClass, butNot = Package)) name.asTypeName.moduleClassName
124+
if (flags.is(ModuleClass, butNot = Package)) name.asTypeName.moduleClassName
125125
else name.toTermName.exclude(AvoidClashName)
126126
}
127127

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ object SymDenotations {
189189
* in `butNot` are set?
190190
*/
191191
final def is(fs: FlagSet, butNot: FlagSet)(implicit ctx: Context) =
192-
(if (isCurrent(fs) && isCurrent(butNot)) myFlags else flags) is (fs, butNot)
192+
(if (isCurrent(fs) && isCurrent(butNot)) myFlags else flags).is(fs, butNot)
193193

194194
/** Has this denotation all of the flags in `fs` set? */
195195
final def is(fs: FlagConjunction)(implicit ctx: Context) =
@@ -199,7 +199,7 @@ object SymDenotations {
199199
* in `butNot` are set?
200200
*/
201201
final def is(fs: FlagConjunction, butNot: FlagSet)(implicit ctx: Context) =
202-
(if (isCurrent(fs) && isCurrent(butNot)) myFlags else flags) is (fs, butNot)
202+
(if (isCurrent(fs) && isCurrent(butNot)) myFlags else flags).is(fs, butNot)
203203

204204
/** The type info.
205205
* The info is an instance of TypeType iff this is a type denotation
@@ -456,13 +456,13 @@ object SymDenotations {
456456
/** Is symbol known to not exist, or potentially not completed yet? */
457457
final def unforcedIsAbsent(implicit ctx: Context): Boolean =
458458
myInfo == NoType ||
459-
(this is (ModuleVal, butNot = Package)) && moduleClass.unforcedIsAbsent
459+
(this.is(ModuleVal, butNot = Package)) && moduleClass.unforcedIsAbsent
460460

461461
/** Is symbol known to not exist? */
462462
final def isAbsent(implicit ctx: Context): Boolean = {
463463
ensureCompleted()
464464
(myInfo `eq` NoType) ||
465-
(this is (ModuleVal, butNot = Package)) && moduleClass.isAbsent
465+
(this.is(ModuleVal, butNot = Package)) && moduleClass.isAbsent
466466
}
467467

468468
/** Is this symbol the root class or its companion object? */
@@ -920,7 +920,7 @@ object SymDenotations {
920920
* A local dummy owner is mapped to the primary constructor of the class.
921921
*/
922922
final def enclosingMethod(implicit ctx: Context): Symbol =
923-
if (this is (Method, butNot = Label)) symbol
923+
if (this.is(Method, butNot = Label)) symbol
924924
else if (this.isClass) primaryConstructor
925925
else if (this.exists) owner.enclosingMethod
926926
else NoSymbol
@@ -1350,7 +1350,7 @@ object SymDenotations {
13501350

13511351
// ----- denotation fields and accessors ------------------------------
13521352

1353-
if (initFlags is (Module, butNot = Package))
1353+
if (initFlags.is(Module, butNot = Package))
13541354
assert(name.is(ModuleClassName), s"module naming inconsistency: ${name.debugString}")
13551355

13561356
/** The symbol asserted to have type ClassSymbol */

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ object Types {
601601
else pdenot.info recoverable_& rinfo
602602
pdenot.asSingleDenotation.derivedSingleDenotation(pdenot.symbol, jointInfo)
603603
} else {
604-
pdenot & (
604+
pdenot .& (
605605
new JointRefDenotation(NoSymbol, rinfo, Period.allInRun(ctx.runId)),
606606
pre,
607607
safeIntersection = ctx.pendingMemberSearches.contains(name))
@@ -646,7 +646,7 @@ object Types {
646646
}
647647

648648
def goAnd(l: Type, r: Type) = {
649-
go(l) & (go(r), pre, safeIntersection = ctx.pendingMemberSearches.contains(name))
649+
go(l) .& (go(r), pre, safeIntersection = ctx.pendingMemberSearches.contains(name))
650650
}
651651

652652
val recCount = ctx.findMemberCount
@@ -983,7 +983,7 @@ object Types {
983983
case res => res
984984
}
985985
case tp @ AndType(tp1, tp2) =>
986-
tp derived_& (tp1.widenUnion, tp2.widenUnion)
986+
tp.derived_&(tp1.widenUnion, tp2.widenUnion)
987987
case tp: RefinedType =>
988988
tp.derivedRefinedType(tp.parent.widenUnion, tp.refinedName, tp.refinedInfo)
989989
case tp: RecType =>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ class Constructors extends MiniPhase with IdentityDenotTransformer { thisPhase =
152152
override def transform(tree: Tree)(implicit ctx: Context): Tree = tree match {
153153
case Ident(_) | Select(This(_), _) =>
154154
var sym = tree.symbol
155-
if (sym is (ParamAccessor, butNot = Mutable)) sym = sym.subst(accessors, paramSyms)
155+
if (sym.is(ParamAccessor, butNot = Mutable)) sym = sym.subst(accessors, paramSyms)
156156
if (sym.owner.isConstructor) ref(sym).withPos(tree.pos) else tree
157157
case Apply(fn, Nil) =>
158158
val fn1 = transform(fn)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class ParamForwarding(thisPhase: DenotTransformer) {
4848
* }
4949
*/
5050
val candidate = sym.owner.asClass.superClass
51-
.info.decl(sym.name).suchThat(_ is (ParamAccessor, butNot = Mutable)).symbol
51+
.info.decl(sym.name).suchThat(_.is(ParamAccessor, butNot = Mutable)).symbol
5252
if (candidate.isAccessibleFrom(currentClass.thisType, superAccess = true)) candidate
5353
else if (candidate.exists) inheritedAccessor(candidate)
5454
else NoSymbol

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ class SuperAccessors(thisPhase: DenotTransformer) {
123123
// SI-4989 Check if an intermediate class between `clazz` and `sym.owner` redeclares the method as abstract.
124124
for (intermediateClass <- clazz.info.baseClasses.tail.takeWhile(_ != sym.owner)) {
125125
val overriding = sym.overridingSymbol(intermediateClass)
126-
if ((overriding is (Deferred, butNot = AbsOverride)) && !(overriding.owner is Trait))
126+
if (overriding.is(Deferred, butNot = AbsOverride) && !overriding.owner.is(Trait))
127127
ctx.error(
128128
s"${sym.showLocated} cannot be directly accessed from ${clazz} because ${overriding.owner} redeclares it as abstract",
129129
sel.pos)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ abstract class TransformByNameApply extends MiniPhase { thisPhase: DenotTransfor
2626

2727
/** If denotation had an ExprType before, it now gets a function type */
2828
protected def exprBecomesFunction(symd: SymDenotation)(implicit ctx: Context) =
29-
(symd is Param) || (symd is (ParamAccessor, butNot = Method))
29+
symd.is(Param) || symd.is(ParamAccessor, butNot = Method)
3030

3131
protected def isByNameRef(tree: Tree)(implicit ctx: Context) = {
3232
val origDenot = originalDenotation(tree)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1029,7 +1029,7 @@ class Namer { typer: Typer =>
10291029
def moduleValSig(sym: Symbol)(implicit ctx: Context): Type = {
10301030
val clsName = sym.name.moduleClassName
10311031
val cls = ctx.denotNamed(clsName) suchThat (_ is ModuleClass)
1032-
ctx.owner.thisType select (clsName, cls)
1032+
ctx.owner.thisType.select(clsName, cls)
10331033
}
10341034

10351035
/** The type signature of a ValDef or DefDef

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ class Typer extends Namer
151151
def qualifies(denot: Denotation): Boolean =
152152
reallyExists(denot) &&
153153
!(pt.isInstanceOf[UnapplySelectionProto] &&
154-
(denot.symbol is (Method, butNot = Accessor))) &&
154+
(denot.symbol.is(Method, butNot = Accessor))) &&
155155
!(denot.symbol is PackageClass)
156156

157157
/** Find the denotation of enclosing `name` in given context `ctx`.

0 commit comments

Comments
 (0)