Class: Rigor::RbsExtended::PredicateEffect

Inherits:
Object
  • Object
show all
Defined in:
lib/rigor/rbs_extended.rb,
sig/rigor/rbs_extended.rbs

Overview

Returned for predicate-if-true / predicate-if-false. target_kind is :parameter (with target_name the Ruby parameter symbol) or :self. negative is true when the directive uses the ~ClassName form, in which case the engine narrows AWAY from class_name (Narrowing.narrow_not_class) instead of toward it.

refinement_type is non-nil when the right-hand side is a kebab-case refinement name (non-empty-string, lowercase-string, …) instead of a Capitalised class name. The narrowing tier substitutes the carrier for the current local type; class_name is then nil. negative may be true for refinement-form directives — ~T negation is supported; the narrowing tier computes the complement decomposition (see AssertEffect docs below).

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#class_nameString (readonly)

Returns the value of attribute class_name.

Returns:

  • (String)


12
13
14
# File 'sig/rigor/rbs_extended.rbs', line 12

def class_name
  @class_name
end

#edgepredicate_edge (readonly)

Returns the value of attribute edge.

Returns:

  • (predicate_edge)


9
10
11
# File 'sig/rigor/rbs_extended.rbs', line 9

def edge
  @edge
end

#negativeBoolean (readonly)

Returns the value of attribute negative.

Returns:

  • (Boolean)


13
14
15
# File 'sig/rigor/rbs_extended.rbs', line 13

def negative
  @negative
end

#target_kindtarget_kind (readonly)

Returns the value of attribute target_kind.

Returns:



10
11
12
# File 'sig/rigor/rbs_extended.rbs', line 10

def target_kind
  @target_kind
end

#target_nameSymbol (readonly)

Returns the value of attribute target_name.

Returns:

  • (Symbol)


11
12
13
# File 'sig/rigor/rbs_extended.rbs', line 11

def target_name
  @target_name
end

Class Method Details

.newPredicateEffect

Parameters:

  • edge: (predicate_edge)
  • target_kind: (target_kind)
  • target_name: (Symbol)
  • class_name: (String)
  • negative: (Boolean)

Returns:



15
# File 'sig/rigor/rbs_extended.rbs', line 15

def self.new: (edge: predicate_edge, target_kind: target_kind, target_name: Symbol, class_name: String, negative: bool) -> PredicateEffect

Instance Method Details

#falsey_only?Boolean

Returns:

  • (Boolean)


43
# File 'lib/rigor/rbs_extended.rb', line 43

def falsey_only? = edge == :falsey_only

#negative?Boolean

Returns:

  • (Boolean)


44
# File 'lib/rigor/rbs_extended.rb', line 44

def negative? = negative == true

#refinement?Boolean

Returns:

  • (Boolean)


45
# File 'lib/rigor/rbs_extended.rb', line 45

def refinement? = !refinement_type.nil?

#to_factObject

ADR-7 § "Slice 4-A" canonical translation. Lifts the parser-side carrier into a Rigor::FlowContribution::Fact that the merger and plugin contribution stream consume uniformly. class_name lifts to Nominal[<class>]; refinement_type is already a Rigor::Type and passes through. The edge field doesn't survive the conversion — the slot it lands in (truthy_facts / falsey_facts / ...) encodes that.



52
53
54
55
56
57
58
59
# File 'lib/rigor/rbs_extended.rb', line 52

def to_fact
  FlowContribution::Fact.new(
    target_kind: target_kind,
    target_name: target_name,
    type: refinement_type || Rigor::Type::Combinator.nominal_of(class_name),
    negative: negative == true
  )
end

#truthy_only?Boolean

Returns:

  • (Boolean)


42
# File 'lib/rigor/rbs_extended.rb', line 42

def truthy_only? = edge == :truthy_only