123456789_123456789_123456789_123456789_123456789_

Class: TypeProf::TypedBlock

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Block
Instance Chain:
Inherits: TypeProf::Block
Defined in: lib/typeprof/block.rb

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(msig, ret_ty) ⇒ TypedBlock

[ GitHub ]

  
# File 'lib/typeprof/block.rb', line 70

def initialize(msig, ret_ty)
  @msig = msig
  @ret_ty = ret_ty
end

Instance Attribute Details

#msig (readonly)

[ GitHub ]

  
# File 'lib/typeprof/block.rb', line 75

attr_reader :msig, :ret_ty

#ret_ty (readonly)

[ GitHub ]

  
# File 'lib/typeprof/block.rb', line 75

attr_reader :msig, :ret_ty

Instance Method Details

#consistent?(other) ⇒ Boolean

[ GitHub ]

  
# File 'lib/typeprof/block.rb', line 77

def consistent?(other)
  if other.is_a?(ISeqBlock)
    raise "assert false"
  else
    self == other
  end
end

#do_call(aargs, caller_ep, caller_env, scratch, replace_recv_ty:, replace_cref:, &ctn)

[ GitHub ]

  
# File 'lib/typeprof/block.rb', line 91

def do_call(aargs, caller_ep, caller_env, scratch, replace_recv_ty:, replace_cref:, &ctn)
  aargs = scratch.globalize_type(aargs, caller_env, caller_ep)
  subst = aargs.consistent_with_method_signature?(@msig)
  unless subst
    scratch.warn(caller_ep, "The arguments is not compatible to RBS block")
  end
  # check?
  #subst = { Type::Var.new(:self) => caller_env.static_env.recv_ty }
  # XXX: Update type vars
  ret_ty = @ret_ty.remove_type_vars
  ctn[ret_ty, caller_ep, caller_env]
end

#substitute(subst, depth)

[ GitHub ]

  
# File 'lib/typeprof/block.rb', line 85

def substitute(subst, depth)
  msig = @msig.substitute(subst, depth)
  ret_ty = @ret_ty.substitute(subst, depth)
  TypedBlock.new(msig, ret_ty)
end