Class: Rigor::RbsExtended::AssertEffect

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

Overview

Returned for assert / assert-if-true / assert-if-false. condition is one of:

  • :always — refines target at the call's post-scope unconditionally (assert).
  • :if_truthy_return — refines target only when the call's return value is observed as truthy (currently: as the predicate of a subsequent if / unless).
  • :if_falsey_return — symmetric for falsey.

negative mirrors PredicateEffect: true when the directive uses ~ClassName syntax.

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)


30
31
32
# File 'sig/rigor/rbs_extended.rbs', line 30

def class_name
  @class_name
end

#conditionassert_condition (readonly)

Returns the value of attribute condition.

Returns:

  • (assert_condition)


27
28
29
# File 'sig/rigor/rbs_extended.rbs', line 27

def condition
  @condition
end

#negativeBoolean (readonly)

Returns the value of attribute negative.

Returns:

  • (Boolean)


31
32
33
# File 'sig/rigor/rbs_extended.rbs', line 31

def negative
  @negative
end

#target_kindtarget_kind (readonly)

Returns the value of attribute target_kind.

Returns:



28
29
30
# File 'sig/rigor/rbs_extended.rbs', line 28

def target_kind
  @target_kind
end

#target_nameSymbol (readonly)

Returns the value of attribute target_name.

Returns:

  • (Symbol)


29
30
31
# File 'sig/rigor/rbs_extended.rbs', line 29

def target_name
  @target_name
end

Class Method Details

.newAssertEffect

Parameters:

  • condition: (assert_condition)
  • target_kind: (target_kind)
  • target_name: (Symbol)
  • class_name: (String)
  • negative: (Boolean)

Returns:



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

def self.new: (condition: assert_condition, target_kind: target_kind, target_name: Symbol, class_name: String, negative: bool) -> AssertEffect

Instance Method Details

#always?Boolean

Returns:

  • (Boolean)


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

def always? = condition == :always

#if_falsey_return?Boolean

Returns:

  • (Boolean)


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

def if_falsey_return? = condition == :if_falsey_return

#if_truthy_return?Boolean

Returns:

  • (Boolean)


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

def if_truthy_return? = condition == :if_truthy_return

#negative?Boolean

Returns:

  • (Boolean)


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

def negative? = negative == true

#refinement?Boolean

Returns:

  • (Boolean)


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

def refinement? = !refinement_type.nil?

#to_factObject

ADR-7 § "Slice 4-A" canonical translation. Same shape as PredicateEffect#to_fact; the condition field (:always / :if_truthy_return / :if_falsey_return) routes which slot the resulting fact lands in at the read_flow_contribution boundary, but does not surface on the Fact itself.



80
81
82
83
84
85
86
87
# File 'lib/rigor/rbs_extended.rb', line 80

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