Mutability

dotty.tools.dotc.cc.Mutability
object Mutability

Handling mutability and read-only access

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Mutability.type

Members list

Value members

Concrete methods

def adaptReadOnly(actual: Type, original: Type, expected: Type, tree: Tree)(using Context): Type

Adapt type actual so that it represents a read-only access if needed. actual is the widened version of original with capture set improved by the VAR rule. The conditions for adaptation are as follows (see modularity.md, section "Read-Only Accesses" for context)

Adapt type actual so that it represents a read-only access if needed. actual is the widened version of original with capture set improved by the VAR rule. The conditions for adaptation are as follows (see modularity.md, section "Read-Only Accesses" for context)

  1. The original reference is a this of a type extending Mutable and the access is not from an update method of the class of this.
  2. The original reference refers to a type extending Mutable and is a path where a prefix of that path has a read-only capture set.
  3. The expected type corresponding to some part of actual that refers to a type extending Mutable is a value type that is not a mutable type. In that case this part is adapted to a read-only capture set.

Attributes

def checkUpdate(qualType: Type, pos: SrcPos)(msg: => String)(using Context): Unit

Check that we can call an update method of qualType or perform an assignment of a field of qualType.

Check that we can call an update method of qualType or perform an assignment of a field of qualType.

Attributes

Extensions

Extensions

extension (ref: TermRef | ThisType)

Map ref to ref.readOnly if its type extends Mutble, and one of the following is true: it appears in a non-exclusive context, or the expected type is a value type that is not a mutable type.

Map ref to ref.readOnly if its type extends Mutble, and one of the following is true: it appears in a non-exclusive context, or the expected type is a value type that is not a mutable type.

Attributes

extension (sym: Symbol)

A read-only methid is a real method (not an accessor) in a type extending Mutable that is not an update method.

A read-only methid is a real method (not an accessor) in a type extending Mutable that is not an update method.

Attributes

An update method is either a method marked with update or a setter of a non-transparent var.

An update method is either a method marked with update or a setter of a non-transparent var.

Attributes

extension (tp: Type)

Is this a type extending Mutable that has non-private update methods or mutable fields?

Is this a type extending Mutable that has non-private update methods or mutable fields?

Attributes