CaptureSet

dotty.tools.dotc.cc.CaptureSet
See theCaptureSet companion object
sealed abstract class CaptureSet extends Showable

A class for capture sets. Capture sets can be constants or variables. Capture sets support inclusion constraints <:< where <:< is subcapturing.

They also allow

  • mapping with functions from elements to capture sets
  • filtering with predicates on elements
  • intersecting wo capture sets

That is, constraints can be of the forms

cs1 <:< cs2 cs1 = ∪ {f(x) | x ∈ cs2} where f is a function from capture references to capture sets. cs1 = ∪ {x | x ∈ cs2, p(x)} where p is a predicate on capture references cs1 = cs2 ∩ cs2

We call the resulting constraint system "monadic set constraints". To support capture propagation across maps, mappings are supported only if the mapped function is either a bijection or if it is idempotent on capture references (c.f. doc comment on map below).

Attributes

Companion
object
Graph
Supertypes
trait Showable
class Object
trait Matchable
class Any
Known subtypes
class Const
object Fluid
class Var
class DerivedVar
class BiMapped
class Filtered
class Diff
class Mapped
class Intersected
class RefiningVar
Show all

Members list

Value members

Abstract methods

The provided description (set via withDescription) for this capture set or else ""

The provided description (set via withDescription) for this capture set or else ""

Attributes

def elems: Refs

The elements of this capture set. For capture variables, the elements known so far.

The elements of this capture set. For capture variables, the elements known so far.

Attributes

Is this capture set always empty? For unsolved capture veriables, returns always false.

Is this capture set always empty? For unsolved capture veriables, returns always false.

Attributes

Is this capture set constant (i.e. not an unsolved capture variable)? Solved capture variables count as constant.

Is this capture set constant (i.e. not an unsolved capture variable)? Solved capture variables count as constant.

Attributes

An optional level limit, or NoSymbol if none exists. All elements of the set must be in scopes visible from the level limit.

An optional level limit, or NoSymbol if none exists. All elements of the set must be in scopes visible from the level limit.

Attributes

def withDescription(description: String): CaptureSet

This capture set with a description that tells where it comes from

This capture set with a description that tells where it comes from

Attributes

Concrete methods

def **(that: CaptureSet)(using Context): CaptureSet

The largest capture set (via <:<) that is a subset of both this and that

The largest capture set (via <:<) that is a subset of both this and that

Attributes

def +(ref: CaptureRef)(using Context): CaptureSet

The smallest superset (via <:<) of this capture set that also contains ref.

The smallest superset (via <:<) of this capture set that also contains ref.

Attributes

def ++(that: CaptureSet)(using Context): CaptureSet

The smallest capture set (via <:<) that is a superset of both this and that

The smallest capture set (via <:<) that is a superset of both this and that

Attributes

def -(ref: CaptureRef)(using Context): CaptureSet

The largest subset (via <:<) of this capture set that does not account for ref

The largest subset (via <:<) of this capture set that does not account for ref

Attributes

def --(that: Const)(using Context): CaptureSet

The largest subset (via <:<) of this capture set that does not account for any of the elements in the constant capture set that

The largest subset (via <:<) of this capture set that does not account for any of the elements in the constant capture set that

Attributes

def =:=(that: CaptureSet)(using Context): Boolean

Two capture sets are considered =:= equal if they mutually subcapture each other in a frozen state.

Two capture sets are considered =:= equal if they mutually subcapture each other in a frozen state.

Attributes

{x} <:< this where <:< is subcapturing, but treating all variables as frozen.

{x} <:< this where <:< is subcapturing, but treating all variables as frozen.

Attributes

def asConst: Const

Convert to Const. @pre: isConst

Convert to Const. @pre: isConst

Attributes

def asVar: Var

Cast to variable. @pre: !isConst

Cast to variable. @pre: !isConst

Attributes

def disallowRootCapability(handler: () => Context ?=> Unit)(using Context): this.type

Invoke handler if this set has (or later aquires) the root capability cap

Invoke handler if this set has (or later aquires) the root capability cap

Attributes

def ensureWellformed(handler: CaptureRef => Context ?=> Unit)(using Context): this.type

Invoke handler on the elements to ensure wellformedness of the capture set. The handler might add additional elements to the capture set.

Invoke handler on the elements to ensure wellformedness of the capture set. The handler might add additional elements to the capture set.

Attributes

The largest subset (via <:<) of this capture set that only contains elements for which p is true.

The largest subset (via <:<) of this capture set that only contains elements for which p is true.

Attributes

final def isNotEmpty: Boolean

Is this capture set definitely non-empty?

Is this capture set definitely non-empty?

Attributes

final def isUniversal(using Context): Boolean

Does this capture set contain the root reference cap as element?

Does this capture set contain the root reference cap as element?

Attributes

def map(tm: TypeMap)(using Context): CaptureSet

Capture set obtained by applying tm to all elements of the current capture set and joining the results. If the current capture set is a variable, the same transformation is applied to all future additions of new elements.

Capture set obtained by applying tm to all elements of the current capture set and joining the results. If the current capture set is a variable, the same transformation is applied to all future additions of new elements.

Note: We have a problem how we handle the situation where we have a mapped set

cs2 = tm(cs1)

and then the propagation solver adds a new element x to cs2. What do we know in this case about cs1? We can answer this question in a sound way only if tm is a bijection on capture references or it is idempotent on capture references. (see definition in IdempotentCapRefMap). If tm is a bijection we know that tm^-1(x) must be in cs1. If tm is idempotent one possible solution is that x is in cs1, which is what we assume in this case. That strategy is sound but not complete.

If tm is some other map, we don't know how to handle this case. For now, we simply refuse to handle other maps. If they do need to be handled, OtherMapped provides some approximation to a solution, but it is neither sound nor complete.

Attributes

A more optimistic version of accountsFor, which does not take variable supersets of the x reference into account. A set might account for x if it accounts for x in a state where we assume all supersets of x have just the elements known at this point. On the other hand if x's capture set has no known elements, a set cs might account for x only if it subsumes x or it contains the root capability cap.

A more optimistic version of accountsFor, which does not take variable supersets of the x reference into account. A set might account for x if it accounts for x in a state where we assume all supersets of x have just the elements known at this point. On the other hand if x's capture set has no known elements, a set cs might account for x only if it subsumes x or it contains the root capability cap.

Attributes

A more optimistic version of subCaptures used to choose one of two typing rules for selections and applications. cs1 mightSubcapture cs2 if cs2 might account for every element currently known to be in cs1.

A more optimistic version of subCaptures used to choose one of two typing rules for selections and applications. cs1 mightSubcapture cs2 if cs2 might account for every element currently known to be in cs1.

Attributes

More info enabled by -Y flags

More info enabled by -Y flags

Attributes

final def subCaptures(that: CaptureSet, frozen: Boolean)(using Context): CompareResult

The subcapturing test.

The subcapturing test.

Value parameters

frozen

if true, no new variables or dependent sets are allowed to be added when making this test. An attempt to add either will result in failure.

Attributes

A mapping resulting from substituting parameters of a BindingType to a list of types

A mapping resulting from substituting parameters of a BindingType to a list of types

Attributes

A regular @retains or @retainsByName annotation with the elements of this set as arguments.

A regular @retains or @retainsByName annotation with the elements of this set as arguments.

Attributes

override def toText(printer: Printer): Text

The text representation of this showable element. This normally dispatches to a pattern matching method in Printers.

The text representation of this showable element. This normally dispatches to a pattern matching method in Printers.

Attributes

Definition Classes

Inherited methods

def fallbackToText(printer: Printer): Text

A fallback text representation, if the pattern matching in Printers does not have a case for this showable element

A fallback text representation, if the pattern matching in Printers does not have a case for this showable element

Attributes

Inherited from:
Showable
def show(using Context): String

The string representation of this showable element.

The string representation of this showable element.

Attributes

Inherited from:
Showable
def showIndented(margin: Int)(using Context): String

The string representation with each line after the first one indented by the given given margin (in spaces).

The string representation with each line after the first one indented by the given given margin (in spaces).

Attributes

Inherited from:
Showable
def showSummary(depth: Int)(using Context): String

The summarized string representation of this showable element. Recursion depth is limited to some smallish value. Default is Config.summarizeDepth.

The summarized string representation of this showable element. Recursion depth is limited to some smallish value. Default is Config.summarizeDepth.

Attributes

Inherited from:
Showable