Skip to content

Commit c9e7d16

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 b017ba4 commit c9e7d16

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
@@ -190,7 +190,7 @@ object SymDenotations {
190190
* in `butNot` are set?
191191
*/
192192
final def is(fs: FlagSet, butNot: FlagSet)(implicit ctx: Context) =
193-
(if (isCurrent(fs) && isCurrent(butNot)) myFlags else flags) is (fs, butNot)
193+
(if (isCurrent(fs) && isCurrent(butNot)) myFlags else flags).is(fs, butNot)
194194

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

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

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

469469
/** Is this symbol the root class or its companion object? */
@@ -921,7 +921,7 @@ object SymDenotations {
921921
* A local dummy owner is mapped to the primary constructor of the class.
922922
*/
923923
final def enclosingMethod(implicit ctx: Context): Symbol =
924-
if (this is (Method, butNot = Label)) symbol
924+
if (this.is(Method, butNot = Label)) symbol
925925
else if (this.isClass) primaryConstructor
926926
else if (this.exists) owner.enclosingMethod
927927
else NoSymbol
@@ -1352,7 +1352,7 @@ object SymDenotations {
13521352

13531353
// ----- denotation fields and accessors ------------------------------
13541354

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

13581358
/** 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`.

compiler/src/dotty/tools/dotc/util/SimpleIdentityMap.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ abstract class SimpleIdentityMap[K <: AnyRef, +V >: Null <: AnyRef] extends (K =
2222
def toList: List[(K, V)] = map2((k, v) => (k, v))
2323
override def toString = {
2424
def assocToString(key: K, value: V) = s"$key -> $value"
25-
map2(assocToString) mkString ("(", ", ", ")")
25+
map2(assocToString).mkString("(", ", ", ")")
2626
}
2727
}
2828

compiler/src/dotty/tools/repl/terminal/filters/ReadlineFilters.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ object ReadlineFilters {
121121
}
122122
def cutCharLeft(b: Vector[Char], c: Int) = {
123123
/* Do not edit current cut. Zsh(zle) & Bash(readline) do not edit the yank ring for Ctrl-h */
124-
(b patch(from = c - 1, patch = Nil, replaced = 1), c - 1)
124+
(b .patch(from = c - 1, patch = Nil, replaced = 1), c - 1)
125125
}
126126

127127
def cutLineLeft(b: Vector[Char], c: Int) = {

tests/neg/i2033.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ object Test {
44
def check(obj: AnyRef): Unit = {
55
val bos = new ByteArrayOutputStream()
66
val out = new ObjectOutputStream(println) // error
7-
val arr = bos toByteArray ()
7+
val arr = bos.toByteArray ()
88
val in = (())
99
val deser = ()
10-
val lhs = mutable LinkedHashSet ()
10+
val lhs = mutable.LinkedHashSet ()
1111
check(lhs)
1212
}
1313
}

tests/run/collections.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ object Test extends dotty.runtime.LegacyApp {
1818
println("***** "+msg+":")
1919
var s = s0
2020
s = s + 2
21-
s = s + (3, 4000, 10000)
21+
s = s.+(3, 4000, 10000)
2222
println("test1: "+sum(s))
2323
time {
2424
s = s ++ (List.range(0, iters) map (2*))
@@ -36,7 +36,7 @@ object Test extends dotty.runtime.LegacyApp {
3636
println("***** "+msg+":")
3737
var s = s0
3838
s = s + 2
39-
s = s + (3, 4000, 10000)
39+
s = s.+(3, 4000, 10000)
4040
println("test1: "+sum(s))
4141
time {
4242
s = s ++ (List.range(0, iters) map (2*))
@@ -54,7 +54,7 @@ object Test extends dotty.runtime.LegacyApp {
5454
println("***** "+msg+":")
5555
var s = s0
5656
s = s + (2 -> 2)
57-
s = s + (3 -> 3, 4000 -> 4000, 10000 -> 10000)
57+
s = s.+(3 -> 3, 4000 -> 4000, 10000 -> 10000)
5858
println("test1: "+sum(s map (_._2)))
5959
time {
6060
s = s ++ (List.range(0, iters) map (x => x * 2 -> x * 2))
@@ -89,7 +89,7 @@ object Test extends dotty.runtime.LegacyApp {
8989
println("***** "+msg+":")
9090
var s = s0
9191
s = s + (2 -> 2)
92-
s = s + (3 -> 3, 4000 -> 4000, 10000 -> 10000)
92+
s = s.+(3 -> 3, 4000 -> 4000, 10000 -> 10000)
9393
println("test1: "+sum(s map (_._2)))
9494
time {
9595
s = s ++ (List.range(0, iters) map (x => x * 2 -> x * 2))

tests/run/colltest1.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ object Test extends dotty.runtime.LegacyApp {
4747
assert(vs1 == ten)
4848
assert((ten take 5) == firstFive)
4949
assert((ten drop 5) == secondFive)
50-
assert(ten slice (3, 3) isEmpty)
51-
assert((ten slice (3, 6)) == List(4, 5, 6), ten slice (3, 6))
50+
assert(ten.slice(3, 3) isEmpty)
51+
assert((ten.slice(3, 6)) == List(4, 5, 6), ten .slice (3, 6))
5252
assert((ten takeWhile (_ <= 5)) == firstFive)
5353
assert((ten dropWhile (_ <= 5)) == secondFive)
5454
assert((ten span (_ <= 5)) == (firstFive, secondFive))
@@ -139,7 +139,7 @@ object Test extends dotty.runtime.LegacyApp {
139139

140140
def setTest(empty: => Set[String]): Unit = {
141141
var s = empty + "A" + "B" + "C"
142-
s += ("D", "E", "F")
142+
s = s.+("D", "E", "F")
143143
s ++= List("G", "H", "I")
144144
s ++= ('J' to 'Z') map (_.toString)
145145
assert(s forall (s contains))
@@ -156,8 +156,8 @@ object Test extends dotty.runtime.LegacyApp {
156156
assert(!s.isEmpty)
157157
val s1 = s intersect empty
158158
assert(s1 == empty, s1)
159-
def abc = empty + ("a", "b", "c")
160-
def bc = empty + ("b", "c")
159+
def abc = empty.+("a", "b", "c")
160+
def bc = empty.+("b", "c")
161161
assert(bc subsetOf abc)
162162
}
163163

@@ -173,7 +173,7 @@ object Test extends dotty.runtime.LegacyApp {
173173

174174
def mapTest(empty: => Map[String, String]) = {
175175
var m = empty + ("A" -> "A") + ("B" -> "B") + ("C" -> "C")
176-
m += (("D" -> "D"), ("E" -> "E"), ("F" -> "F"))
176+
m = m.+(("D" -> "D"), ("E" -> "E"), ("F" -> "F"))
177177
m ++= List(("G" -> "G"), ("H" -> "H"), ("I" -> "I"))
178178
m ++= ('J' to 'Z') map (x => (x.toString -> x.toString))
179179
println(m.toList.sorted)

tests/run/runtime.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,15 @@ object Test1Test {
6565
// {System.out.print(12); java.lang}.System.out.println();
6666
// {System.out.print(13); java.lang.System}.out.println();
6767
{Console.print(14); Console}.println;
68-
{Console.print(15); (() => Console.println):(() => Unit)} apply ();
68+
{Console.print(15); (() => Console.println):(() => Unit)} .apply ();
6969
{Console.print(16); Console.println};
7070

7171
{Console.print(20)}; test1.bar.System.out.println();
7272
// {System.out.print(21); test1}.bar.System.out.println();
7373
// {System.out.print(22); test1.bar}.System.out.println();
7474
{Console.print(23); test1.bar.System}.out.println();
7575
{Console.print(24); test1.bar.System.out}.println();
76-
{Console.print(25); test1.bar.System.out.println:(() => Unit)} apply ();
76+
{Console.print(25); test1.bar.System.out.println:(() => Unit)} .apply ();
7777
{Console.print(26); test1.bar.System.out.println()};
7878
}
7979

tests/run/t2544.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ object Test {
1111
)
1212

1313
def main(args: Array[String]) = {
14-
println(Foo indexWhere(_ >= 2,1))
15-
println(Foo.toList indexWhere(_ >= 2,1))
16-
println(Foo segmentLength(_ <= 3,1))
17-
println(Foo.toList segmentLength(_ <= 3,1))
14+
println(Foo .indexWhere(_ >= 2,1))
15+
println(Foo.toList .indexWhere(_ >= 2,1))
16+
println(Foo .segmentLength(_ <= 3,1))
17+
println(Foo.toList .segmentLength(_ <= 3,1))
1818
lengthEquiv(Foo lengthCompare 7)
1919
lengthEquiv(Foo.toList lengthCompare 7)
2020
lengthEquiv(Foo lengthCompare 2)

tests/run/t4813.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ object Test extends dotty.runtime.LegacyApp {
3131
runTest(TreeSet(1,2,3))(_.clone) { buf => buf add 4 }
3232

3333
// Maps
34-
runTest(HashMap(1->1,2->2,3->3))(_.clone) { buf => buf put (4,4) }
35-
runTest(WeakHashMap(1->1,2->2,3->3))(_.clone) { buf => buf put (4,4) }
34+
runTest(HashMap(1->1,2->2,3->3))(_.clone) { buf => buf.put(4,4) }
35+
runTest(WeakHashMap(1->1,2->2,3->3))(_.clone) { buf => buf.put(4,4) }
3636
}
3737

tests/run/t5045.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ object Test extends dotty.runtime.LegacyApp {
66
import scala.util.matching.{ Regex, UnanchoredRegex }
77

88
val dateP1 = """(\d\d\d\d)-(\d\d)-(\d\d)""".r.unanchored
9-
val dateP2 = """(\d\d\d\d)-(\d\d)-(\d\d)""" r ("year", "month", "day") unanchored
9+
val dateP2 = """(\d\d\d\d)-(\d\d)-(\d\d)""" .r ("year", "month", "day") unanchored
1010
val dateP3 = new Regex("""(\d\d\d\d)-(\d\d)-(\d\d)""", "year", "month", "day") with UnanchoredRegex
1111

1212
val yearStr = "2011"

tests/run/t6271.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ object Test extends dotty.runtime.LegacyApp {
2121
}
2222
def slicedIssue = {
2323
val viewed : Iterable[Iterable[Int]] = List(List(0).view).view
24-
val filtered = viewed flatMap { x => List( x slice (2,3) ) }
24+
val filtered = viewed flatMap { x => List( x.slice(2,3) ) }
2525
filtered.iterator.toIterable.flatten
2626
}
2727
filterIssue

tests/run/t6827.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ object Test extends App {
1010
} catch {
1111
case e: Exception => e.toString
1212
}
13-
println("%s: %s" format (label, status))
13+
println("%s: %s".format(label, status))
1414
}
1515

1616
tryit("start at -5", -5, 10)

0 commit comments

Comments
 (0)