class Steep::TypeInference::LocalVariableTypeEnv
def annotate(collection)
def annotate(collection) decls = collection.var_type_annotations.each.with_object({}) do |(var, annotation), hash| type = collection.var_type(lvar: var) hash[var] = Entry.new(type: type, annotations: [annotation]) end decls.each do |var, annot| inner_type = annot.type outer_type = self[var] if outer_type relation = Subtyping::Relation.new(sub_type: inner_type, super_type: outer_type) constraints = Subtyping::Constraints.new(unknowns: Set.new) subtyping.check(relation, constraints: constraints, self_type: self_type).else do |result| yield var, outer_type, inner_type, result end end end new_decls = declared_types.merge(decls) new_assigns = assigned_types.reject {|var, _| new_decls.key?(var) } update(declared_types: new_decls, assigned_types: new_assigns) end