lib/rbs/definition_builder/ancestor_builder.rb in rbs-1.0.0.pre vs lib/rbs/definition_builder/ancestor_builder.rb in rbs-1.0.0.pre2
- old
+ new
@@ -28,18 +28,66 @@
if block
if s = super_class
yield s
end
+ each_self_type(&block)
+ each_included_module(&block)
+ each_included_interface(&block)
+ each_prepended_module(&block)
+ each_extended_module(&block)
+ each_extended_interface(&block)
+ else
+ enum_for :each_ancestor
+ end
+ end
+
+ def each_self_type(&block)
+ if block
self_types&.each(&block)
+ else
+ enum_for :each_self_type
+ end
+ end
+
+ def each_included_module(&block)
+ if block
included_modules&.each(&block)
+ else
+ enum_for :each_included_module
+ end
+ end
+
+ def each_included_interface(&block)
+ if block
included_interfaces&.each(&block)
+ else
+ enum_for :each_included_interface
+ end
+ end
+
+ def each_prepended_module(&block)
+ if block
prepended_modules&.each(&block)
+ else
+ enum_for :each_prepended_module
+ end
+ end
+
+ def each_extended_module(&block)
+ if block
extended_modules&.each(&block)
+ else
+ enum_for :each_extended_module
+ end
+ end
+
+ def each_extended_interface(&block)
+ if block
extended_interfaces&.each(&block)
else
- enum_for :each_ancestor
+ enum_for :each_extended_interface
end
end
def self.class_instance(type_name:, params:, super_class:)
new(
@@ -134,11 +182,11 @@
super_types.uniq!
return if super_types.size == 1
- raise SuperclassMismatchError.new(name: type_name, super_classes: super_types, entry: entry)
+ raise SuperclassMismatchError.new(name: type_name, entry: entry)
end
def one_instance_ancestors(type_name)
as = one_instance_ancestors_cache[type_name] and return as
@@ -455,10 +503,11 @@
building_ancestors.push self_ancestor
one_ancestors = one_interface_ancestors(type_name)
ancestors = []
- one_ancestors.included_interfaces.each do |a|
+ included_interfaces = one_ancestors.included_interfaces or raise
+ included_interfaces.each do |a|
included_ancestors = interface_ancestors(a.name, building_ancestors: building_ancestors)
ancestors.unshift(*included_ancestors.apply(a.args, location: entry.decl.location))
end
ancestors.unshift(self_ancestor)