Skip to content

Commit 0c3d86e

Browse files
committed
Rename mut to update
Rename the `mut` soft modifier to `update`. Reasons: - `update` is more descriptive than `mut` - `update` corresponds to the terminology "update method" - 3 letter modifiers are problematic for visual layout
1 parent 6513b52 commit 0c3d86e

24 files changed

+44
-45
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
206206

207207
case class Var()(implicit @constructorOnly src: SourceFile) extends Mod(Flags.Mutable)
208208

209-
case class Mut()(implicit @constructorOnly src: SourceFile) extends Mod(Flags.Mutable)
209+
case class Update()(implicit @constructorOnly src: SourceFile) extends Mod(Flags.Mutable)
210210

211211
case class Implicit()(implicit @constructorOnly src: SourceFile) extends Mod(Flags.Implicit)
212212

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,6 @@ object StdNames {
553553
val maybeCapability: N = "maybeCapability"
554554
val mirror : N = "mirror"
555555
val moduleClass : N = "moduleClass"
556-
val mut: N = "mut"
557556
val name: N = "name"
558557
val nameDollar: N = "$name"
559558
val ne: N = "ne"

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3291,7 +3291,7 @@ object Parsers {
32913291
case nme.infix => Mod.Infix()
32923292
case nme.tracked => Mod.Tracked()
32933293
case nme.erased if in.erasedEnabled => Mod.Erased()
3294-
case nme.mut if Feature.ccEnabled => Mod.Mut()
3294+
case nme.update if Feature.ccEnabled => Mod.Update()
32953295
}
32963296
}
32973297

@@ -4708,7 +4708,7 @@ object Parsers {
47084708
Nil
47094709
tree match
47104710
case tree: MemberDef
4711-
if !(tree.mods.flags & ModifierFlags).isEmpty && !tree.mods.isMutableVar => // vars are OK, mut defs are not
4711+
if !(tree.mods.flags & ModifierFlags).isEmpty && !tree.mods.isMutableVar => // vars are OK, update defs are not
47124712
fail(em"refinement cannot be ${(tree.mods.flags & ModifierFlags).flagStrings().mkString("`", "`, `", "`")}")
47134713
case tree: DefDef if tree.termParamss.nestedExists(!_.rhs.isEmpty) =>
47144714
fail(em"refinement cannot have default arguments")

compiler/src/dotty/tools/dotc/parsing/Scanners.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1228,7 +1228,7 @@ object Scanners {
12281228
&& (softModifierNames.contains(name)
12291229
|| name == nme.erased && erasedEnabled
12301230
|| name == nme.tracked && trackedEnabled
1231-
|| name == nme.mut && Feature.ccEnabled)
1231+
|| name == nme.update && Feature.ccEnabled)
12321232

12331233
def isSoftModifierInModifierPosition: Boolean =
12341234
isSoftModifier && inModifierPosition()

compiler/src/dotty/tools/dotc/parsing/Tokens.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ object Tokens extends TokensCommon {
299299

300300
final val closingParens = BitSet(RPAREN, RBRACKET, RBRACE)
301301

302-
final val softModifierNames = Set(nme.inline, nme.into, nme.opaque, nme.open, nme.transparent, nme.infix)
302+
final val softModifierNames = Set(nme.inline, nme.into, nme.opaque, nme.open, nme.transparent, nme.infix, nme.update)
303303

304304
def showTokenDetailed(token: Int): String = debugString(token)
305305

tests/neg-custom-args/captures/contracap.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import caps.*
44
class Ref[T](init: T) extends Mutable:
55
private var value: T = init
66
def get: T = value
7-
mut def set(newValue: T): Unit = value = newValue
7+
update def set(newValue: T): Unit = value = newValue
88

99
// a library function that assumes that a and b MUST BE separate
1010
def swap[T](a: Ref[Int]^, b: Ref[Int]^): Unit = ???

tests/neg-custom-args/captures/linear-buffer-2.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import caps.{cap, consume, Mutable}
22
import language.experimental.captureChecking
33

44
class Buffer[T] extends Mutable:
5-
@consume mut def append(x: T): Buffer[T]^ = this // ok
5+
@consume update def append(x: T): Buffer[T]^ = this // ok
66

77
def app[T](@consume buf: Buffer[T]^, elem: T): Buffer[T]^ =
88
buf.append(elem)

tests/neg-custom-args/captures/linear-buffer.check

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
-- Error: tests/neg-custom-args/captures/linear-buffer.scala:5:24 ------------------------------------------------------
2-
5 | mut def append(x: T): BadBuffer[T]^ = this // error
3-
| ^^^^^^^^^^^^^
1+
-- Error: tests/neg-custom-args/captures/linear-buffer.scala:5:27 ------------------------------------------------------
2+
5 | update def append(x: T): BadBuffer[T]^ = this // error
3+
| ^^^^^^^^^^^^^
44
| Separation failure: method append's result type BadBuffer[T]^ hides non-local this of class class BadBuffer.
55
| The access must be in a @consume method to allow this.
66
-- Error: tests/neg-custom-args/captures/linear-buffer.scala:7:13 ------------------------------------------------------

tests/neg-custom-args/captures/linear-buffer.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import caps.{cap, consume, Mutable}
22
import language.experimental.captureChecking
33

44
class BadBuffer[T] extends Mutable:
5-
mut def append(x: T): BadBuffer[T]^ = this // error
5+
update def append(x: T): BadBuffer[T]^ = this // error
66
def foo =
77
def bar: BadBuffer[T]^ = this // error
88
bar
99

1010
class Buffer[T] extends Mutable:
11-
@consume mut def append(x: T): Buffer[T]^ = this // ok
11+
@consume update def append(x: T): Buffer[T]^ = this // ok
1212

1313
def app[T](@consume buf: Buffer[T]^, elem: T): Buffer[T]^ =
1414
buf.append(elem)
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
-- Error: tests/neg-custom-args/captures/mut-outside-mutable.scala:5:10 ------------------------------------------------
2-
5 | mut def foreach(op: T => Unit): Unit // error
3-
| ^
4-
| Update methods can only be used as members of classes extending the `Mutable` trait
5-
-- Error: tests/neg-custom-args/captures/mut-outside-mutable.scala:9:12 ------------------------------------------------
6-
9 | mut def baz() = 1 // error
7-
| ^
8-
| Update methods can only be used as members of classes extending the `Mutable` trait
1+
-- Error: tests/neg-custom-args/captures/mut-outside-mutable.scala:5:13 ------------------------------------------------
2+
5 | update def foreach(op: T => Unit): Unit // error
3+
| ^
4+
| Update methods can only be used as members of classes extending the `Mutable` trait
5+
-- Error: tests/neg-custom-args/captures/mut-outside-mutable.scala:9:15 ------------------------------------------------
6+
9 | update def baz() = 1 // error
7+
| ^
8+
| Update methods can only be used as members of classes extending the `Mutable` trait

tests/neg-custom-args/captures/mut-outside-mutable.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import caps.Mutable
22

33
trait IterableOnce[T]:
44
def iterator: Iterator[T]^{this}
5-
mut def foreach(op: T => Unit): Unit // error
5+
update def foreach(op: T => Unit): Unit // error
66

77
trait Foo extends Mutable:
88
def bar =
9-
mut def baz() = 1 // error
9+
update def baz() = 1 // error
1010
baz()

tests/neg-custom-args/captures/mut-override.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@ import caps.Mutable
22

33
trait IterableOnce[T] extends Mutable:
44
def iterator: Iterator[T]^{this}
5-
mut def foreach(op: T => Unit): Unit
5+
update def foreach(op: T => Unit): Unit
66

77
trait Iterator[T] extends IterableOnce[T]:
88
def iterator = this
99
def hasNext: Boolean
10-
mut def next(): T
11-
mut def foreach(op: T => Unit): Unit = ???
12-
override mut def toString = ??? // error
10+
update def next(): T
11+
update def foreach(op: T => Unit): Unit = ???
12+
override update def toString = ??? // error
1313

1414
trait Iterable[T] extends IterableOnce[T]:
1515
def iterator: Iterator[T] = ???
1616
def foreach(op: T => Unit) = iterator.foreach(op)
1717

1818
trait BadIterator[T] extends Iterator[T]:
19-
override mut def hasNext: Boolean // error
19+
override update def hasNext: Boolean // error

tests/neg-custom-args/captures/readOnly.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import caps.cap
44
class Ref(init: Int) extends Mutable:
55
private var current = init
66
def get: Int = current
7-
mut def put(x: Int): Unit = current = x
7+
update def put(x: Int): Unit = current = x
88

99
def Test(c: Object^) =
1010
val a: Ref^ = Ref(1)

tests/neg-custom-args/captures/sep-box.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ object NIL extends LIST[Nothing]:
2121
class Ref extends Mutable:
2222
var x = 0
2323
def get: Int = x
24-
mut def put(y: Int): Unit = x = y
24+
update def put(y: Int): Unit = x = y
2525

2626
class Box[+X](val value: X)
2727

tests/neg-custom-args/captures/sep-consume.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import caps.*
44
class Ref extends Mutable:
55
private var _data = 0
66
def get: Int = _data
7-
mut def put(x: Int): Unit = _data = x
7+
update def put(x: Int): Unit = _data = x
88

99
case class Pair[+A, +B](fst: A, snd: B)
1010

tests/neg-custom-args/captures/sep-counter.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import caps.cap
44
class Ref extends Mutable:
55
var x = 0
66
def get: Int = x
7-
mut def put(y: Int): Unit = x = y
7+
update def put(y: Int): Unit = x = y
88

99
class Pair[+X, +Y](val fst: X, val snd: Y)
1010

tests/neg-custom-args/captures/sep-curried.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import caps.*
44
class Ref[T](init: T) extends Mutable:
55
private var value: T = init
66
def get: T = value
7-
mut def set(newValue: T): Unit = value = newValue
7+
update def set(newValue: T): Unit = value = newValue
88

99
// a library function that assumes that a and b MUST BE separate
1010
def swap[T](a: Ref[Int]^, b: Ref[Int]^): Unit = ???

tests/neg-custom-args/captures/sep-list.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ object NIL extends LIST[Nothing]:
2121
class Ref extends Mutable:
2222
var x = 0
2323
def get: Int = x
24-
mut def put(y: Int): Unit = x = y
24+
update def put(y: Int): Unit = x = y
2525

2626
def listFresh(n: Int): LIST[Ref^] =
2727
if n == 0 then NIL

tests/neg-custom-args/captures/sep-pairs-2.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import caps.cap
44
class Ref extends Mutable:
55
var x = 0
66
def get: Int = x
7-
mut def put(y: Int): Unit = x = y
7+
update def put(y: Int): Unit = x = y
88

99
class Pair[+X, +Y](val fst: X, val snd: Y)
1010

tests/neg-custom-args/captures/sep-pairs.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import caps.cap
44
class Ref extends Mutable:
55
var x = 0
66
def get: Int = x
7-
mut def put(y: Int): Unit = x = y
7+
update def put(y: Int): Unit = x = y
88

99
class Pair[+X, +Y](val fst: X, val snd: Y)
1010

tests/neg-custom-args/captures/sepchecks.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ trait Rdr[T]:
88
class Ref[T](init: T) extends Rdr[T], Mutable:
99
private var current = init
1010
def get: T = current
11-
mut def put(x: T): Unit = current = x
11+
update def put(x: T): Unit = current = x
1212

1313
def Test(c: Object^): Unit =
1414
val a: Ref[Int]^ = Ref(1)
@@ -39,7 +39,7 @@ def Test(c: Object^): Unit =
3939
class Matrix(nrows: Int, ncols: Int) extends IMatrix, Mutable:
4040
val arr = Array.fill(nrows, ncols)(0.0)
4141
def apply(i: Int, j: Int): Double = arr(i)(j)
42-
mut def update(i: Int, j: Int, x: Double): Unit = arr(i)(j) = x
42+
update def update(i: Int, j: Int, x: Double): Unit = arr(i)(j) = x
4343

4444
def mul(x: IMatrix^{cap.rd}, y: IMatrix^{cap.rd}, z: Matrix^): Matrix^ = ???
4545

tests/neg-custom-args/captures/update-call.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@ import caps.Mutable
22

33
trait IterableOnce[T] extends Mutable:
44
def iterator: Iterator[T]^{this}
5-
mut def foreach(op: T => Unit): Unit
5+
update def foreach(op: T => Unit): Unit
66

77
trait Iterator[T] extends IterableOnce[T]:
88
def iterator = this
99
def hasNext: Boolean
10-
mut def next(): T
11-
mut def foreach(op: T => Unit): Unit = ???
12-
override mut def toString = ??? // error
10+
update def next(): T
11+
update def foreach(op: T => Unit): Unit = ???
12+
override update def toString = ??? // error
1313

1414
trait Iterable[T] extends IterableOnce[T]:
1515
def iterator: Iterator[T] = ???
1616
def foreach(op: T => Unit) = iterator.foreach(op)
1717

1818
trait BadIterator[T] extends Iterator[T]:
19-
override mut def hasNext: Boolean // error
19+
override update def hasNext: Boolean // error

tests/pos-custom-args/captures/mutRef.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ import caps.Mutable
22
class Ref(init: Int) extends Mutable:
33
private var current = init
44
def get: Int = current
5-
mut def put(x: Int): Unit = current = x
5+
update def put(x: Int): Unit = current = x

tests/pos-custom-args/captures/sep-pairs.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import caps.{cap, consume, use}
44
class Ref extends Mutable:
55
var x = 0
66
def get: Int = x
7-
mut def put(y: Int): Unit = x = y
7+
update def put(y: Int): Unit = x = y
88

99
case class Pair[+A, +B](fst: A, snd: B)
1010

0 commit comments

Comments
 (0)