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. One of the following conditions must hold for adaptions to be applied (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. One of the following conditions must hold for adaptions to be applied (see modularity.md, section "Read-Only Accesses" for context):

  1. The original reference is a this of a type extending Stateful and the access is not from an update method of the class of this.
  2. The original reference refers to a type extending Stateful 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 Stateful is a value type that is not a stateful 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

def freeze(tp: Type, pos: SrcPos)(using Context): Type

Apply caps.freeze(...). Strip all capture sets of covariant Mutable types, turning them into CaptureSet.emptyOfMutable. Only Mutable types that contribute to the overall capture set are considered, since that is the set analyzed by consume/use checking. That means that double-flip covariant and boxed capture sets are not dropped.

Apply caps.freeze(...). Strip all capture sets of covariant Mutable types, turning them into CaptureSet.emptyOfMutable. Only Mutable types that contribute to the overall capture set are considered, since that is the set analyzed by consume/use checking. That means that double-flip covariant and boxed capture sets are not dropped.

Attributes

Extensions

Extensions

extension (ref: TermRef | ThisType)

Map ref to ref.readOnly if its type extends Mutble, and one of the following is true:

Map ref to ref.readOnly if its type extends Mutble, and one of the following is true:

  • it appears in a non-exclusive context,
  • the expected type is a value type that is not a stateful type,
  • the expected type is a read-only selection

Attributes

extension (sym: Symbol)

A read-only member is a lazy val or a method that is not an update method.

A read-only member is a lazy val or a method that is not an update method.

Attributes

An update method is either a method marked with update or a setter of a field of a Stateful class that's not annotated with @uncheckedCaptures. update is implicit for consume methods of Stateful classes.

An update method is either a method marked with update or a setter of a field of a Stateful class that's not annotated with @uncheckedCaptures. update is implicit for consume methods of Stateful classes.

Attributes

extension (tp: Type)

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

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

Attributes