Class: Rigor::RbsExtended::AssertEffect

Inherits:
Data
  • Object
show all
Defined in:
lib/rigor/rbs_extended.rb

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

Instance Method Summary collapse

Instance Attribute Details

#class_nameObject (readonly)

Returns the value of attribute class_name

Returns:

  • (Object)

    the current value of class_name



101
102
103
# File 'lib/rigor/rbs_extended.rb', line 101

def class_name
  @class_name
end

#conditionObject (readonly)

Returns the value of attribute condition

Returns:

  • (Object)

    the current value of condition



101
102
103
# File 'lib/rigor/rbs_extended.rb', line 101

def condition
  @condition
end

#negativeObject (readonly)

Returns the value of attribute negative

Returns:

  • (Object)

    the current value of negative



101
102
103
# File 'lib/rigor/rbs_extended.rb', line 101

def negative
  @negative
end

#refinement_typeObject (readonly)

Returns the value of attribute refinement_type

Returns:

  • (Object)

    the current value of refinement_type



101
102
103
# File 'lib/rigor/rbs_extended.rb', line 101

def refinement_type
  @refinement_type
end

#target_kindObject (readonly)

Returns the value of attribute target_kind

Returns:

  • (Object)

    the current value of target_kind



101
102
103
# File 'lib/rigor/rbs_extended.rb', line 101

def target_kind
  @target_kind
end

#target_nameObject (readonly)

Returns the value of attribute target_name

Returns:

  • (Object)

    the current value of target_name



101
102
103
# File 'lib/rigor/rbs_extended.rb', line 101

def target_name
  @target_name
end

Instance Method Details

#always?Boolean

Returns:

  • (Boolean)


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

def always? = condition == :always

#if_falsey_return?Boolean

Returns:

  • (Boolean)


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

def if_falsey_return? = condition == :if_falsey_return

#if_truthy_return?Boolean

Returns:

  • (Boolean)


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

def if_truthy_return? = condition == :if_truthy_return

#negative?Boolean

Returns:

  • (Boolean)


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

def negative? = negative == true

#refinement?Boolean

Returns:

  • (Boolean)


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

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.



114
115
116
117
118
119
120
121
# File 'lib/rigor/rbs_extended.rb', line 114

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