Skip to content

Commit 05728c0

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 ef37ebf commit 05728c0

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
@@ -555,7 +555,6 @@ object StdNames {
555555
val materializeTypeTag: N = "materializeTypeTag"
556556
val mirror : N = "mirror"
557557
val moduleClass : N = "moduleClass"
558-
val mut: N = "mut"
559558
val name: N = "name"
560559
val nameDollar: N = "$name"
561560
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
@@ -3346,7 +3346,7 @@ object Parsers {
33463346
case nme.infix => Mod.Infix()
33473347
case nme.tracked => Mod.Tracked()
33483348
case nme.erased if in.erasedEnabled => Mod.Erased()
3349-
case nme.mut if Feature.ccEnabled => Mod.Mut()
3349+
case nme.update if Feature.ccEnabled => Mod.Update()
33503350
}
33513351
}
33523352

@@ -4763,7 +4763,7 @@ object Parsers {
47634763
Nil
47644764
tree match
47654765
case tree: MemberDef
4766-
if !(tree.mods.flags & ModifierFlags).isEmpty && !tree.mods.isMutableVar => // vars are OK, mut defs are not
4766+
if !(tree.mods.flags & ModifierFlags).isEmpty && !tree.mods.isMutableVar => // vars are OK, update defs are not
47674767
fail(em"refinement cannot be ${(tree.mods.flags & ModifierFlags).flagStrings().mkString("`", "`, `", "`")}")
47684768
case tree: DefDef if tree.termParamss.nestedExists(!_.rhs.isEmpty) =>
47694769
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.opaque, nme.open, nme.transparent, nme.infix)
302+
final val softModifierNames = Set(nme.inline, 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

0 commit comments

Comments
 (0)