abstract class Crystal::ExhaustivenessChecker::Target
inherits Reference
¶
A target to check for exhaustiveness
Every target can also have subtargets, used when matching against a tuple literal.
For example, the BoolTarget will have one subtarget for the value false
and
one for the value true
. When a pattern like {false, ...}
is passed to it,
only patterns for the false
subtarget will be covered.
Direct known subclasses
Crystal::ExhaustivenessChecker::BoolTarget
Crystal::ExhaustivenessChecker::EnumTarget
Crystal::ExhaustivenessChecker::TypeTarget
Class methods¶
Methods¶
abstract
#add_subtargets(type_groups : Array(Array(Type)), index : Int32) : Nil
¶
(type_groups : Array(Array(Type)), index : Int32) : Nil
Add subtargets for the given type groups, starting at index.
abstract
#cover(patterns : Array(Pattern), index : Int32) : Nil
¶
(patterns : Array(Pattern), index : Int32) : Nil
Covers this target and subsequent subtargets with the patterns starting at index.
#cover(pattern : Pattern) : Nil
¶
(pattern : Pattern) : Nil
Tries to cover this target with the given pattern. By default, a TypePattern will cover a target. Other, more specific, patterns will partially cover a target.
abstract
#reject_covered! : Bool
¶
: Bool
Removes covered subtargets from this target, and returns whether this target ended up being entirely covered.