Class: Steep::TypeInference::SendArgs::BlockPassArg
- Includes:
- Equatable
- Defined in:
- lib/steep/type_inference/send_args.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#node ⇒ Object
readonly
Returns the value of attribute node.
Instance Method Summary collapse
- #block_missing? ⇒ Boolean
- #compatible? ⇒ Boolean
-
#initialize(node:, block:) ⇒ BlockPassArg
constructor
A new instance of BlockPassArg.
- #no_block? ⇒ Boolean
- #node_type ⇒ Object
- #pair ⇒ Object
- #unexpected_block? ⇒ Boolean
Methods included from Equatable
Constructor Details
#initialize(node:, block:) ⇒ BlockPassArg
Returns a new instance of BlockPassArg.
438 439 440 441 |
# File 'lib/steep/type_inference/send_args.rb', line 438 def initialize(node:, block:) @node = node @block = block end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
436 437 438 |
# File 'lib/steep/type_inference/send_args.rb', line 436 def block @block end |
#node ⇒ Object (readonly)
Returns the value of attribute node.
435 436 437 |
# File 'lib/steep/type_inference/send_args.rb', line 435 def node @node end |
Instance Method Details
#block_missing? ⇒ Boolean
457 458 459 |
# File 'lib/steep/type_inference/send_args.rb', line 457 def block_missing? !node && block&.required? end |
#compatible? ⇒ Boolean
449 450 451 452 453 454 455 |
# File 'lib/steep/type_inference/send_args.rb', line 449 def compatible? if node block ? true : false else !block || block.optional? end end |
#no_block? ⇒ Boolean
445 446 447 |
# File 'lib/steep/type_inference/send_args.rb', line 445 def no_block? !node && !block end |
#node_type ⇒ Object
476 477 478 479 480 481 482 483 484 485 486 |
# File 'lib/steep/type_inference/send_args.rb', line 476 def node_type raise unless block type = AST::Types::Proc.new(type: block.type, block: nil, self_type: block.self_type) if block.optional? type = AST::Types::Union.build(types: [type, AST::Builtin.nil_type]) end type end |
#pair ⇒ Object
465 466 467 468 469 470 471 472 473 474 |
# File 'lib/steep/type_inference/send_args.rb', line 465 def pair raise unless compatible? if node && block [ node, block.type ] end end |
#unexpected_block? ⇒ Boolean
461 462 463 |
# File 'lib/steep/type_inference/send_args.rb', line 461 def unexpected_block? node && !block end |