Class: TypeProf::Type::HashGenerator
Relationships & Source Files | |
Inherits: | Object |
Defined in: | lib/typeprof/type.rb |
Class Method Summary
- .new ⇒ HashGenerator constructor
Instance Attribute Summary
- #map_tys readonly
Instance Method Summary
Constructor Details
.new ⇒ HashGenerator
# File 'lib/typeprof/type.rb', line 729
def initialize @map_tys = {} end
Instance Attribute Details
#map_tys (readonly)
[ GitHub ]# File 'lib/typeprof/type.rb', line 733
attr_reader :map_tys
Instance Method Details
#[]=(k_ty, v_ty)
[ GitHub ]# File 'lib/typeprof/type.rb', line 735
def []=(k_ty, v_ty) k_ty.each_child_global do |k_ty| if k_ty.is_a?(Type::Union) # Flatten recursive union self[k_ty] = v_ty else # This is a temporal hack to mitigate type explosion k_ty = Type.any if k_ty.is_a?(Type::Array) k_ty = Type.any if k_ty.is_a?(Type::Hash) if @map_tys[k_ty] @map_tys[k_ty] = @map_tys[k_ty].union(v_ty) else @map_tys[k_ty] = v_ty end end end end