SpaceLogic

trait SpaceLogic

abstract space logic

abstract space logic

class Object
trait Matchable
class Any

Value members

Abstract methods

Is the type tp decomposable? i.e. all values of the type can be covered by its decomposed types.

Is the type tp decomposable? i.e. all values of the type can be covered by its decomposed types.

Abstract sealed class, OrType, Boolean and Java enums can be decomposed.

def decompose(tp: Type): List[Space]

Get components of decomposable types

Get components of decomposable types

Return a space containing the values of both types.

Return a space containing the values of both types.

The types should be atomic (non-decomposable) and unrelated (neither should be a subtype of the other).

True if we can assume that the two unapply methods are the same. That is, given the same parameter, they return the same result.

True if we can assume that the two unapply methods are the same. That is, given the same parameter, they return the same result.

We assume that unapply methods are pure, but the same method may be called with different prefixes, thus behaving differently.

def isSubType(tp1: Type, tp2: Type): Boolean

Is tp1 a subtype of tp2?

Is tp1 a subtype of tp2?

def show(sp: Space): String

Display space in string format

Display space in string format

def signature(unapp: TermRef, scrutineeTp: Type, argLen: Int): List[Type]

Return term parameter types of the extractor unapp

Return term parameter types of the extractor unapp

Concrete methods

def flatten(space: Space)(using Context): Seq[Space]

Flatten space to get rid of Or for pretty print

Flatten space to get rid of Or for pretty print

def intersect(a: Space, b: Space)(using Context): Space

Intersection of two spaces

Intersection of two spaces

def isSubspace(a: Space, b: Space)(using Context): Boolean

Is a a subspace of b? Equivalent to a - b == Empty, but faster

Is a a subspace of b? Equivalent to a - b == Empty, but faster

def minus(a: Space, b: Space)(using Context): Space

The space of a not covered by b

The space of a not covered by b

def simplify(space: Space, aggressive: Boolean)(using Context): Space

Simplify space using the laws, there's no nested union after simplify

Simplify space using the laws, there's no nested union after simplify

Value Params
aggressive

if true and OR space has less than 5 components, simplify will collapse sp1 | sp2 to sp1 if sp2 is a subspace of sp1. This reduces noise in counterexamples.