Object
# File rbs-2.1.0/lib/rbs/type_alias_dependency.rb, line 25 def build_dependencies return if @direct_dependencies # Initialize hash(a directed graph) @direct_dependencies = {} # Initialize dependencies as an empty hash @dependencies = {} # Iterate over alias declarations inserted into environment env.alias_decls.each do |name, entry| # Construct a directed graph by recursively extracting type aliases @direct_dependencies[name] = direct_dependency(entry.decl.type) # Initialize dependencies with an empty hash @dependencies[name] = {} end end
Check if an alias type definition is circular & prohibited
# File rbs-2.1.0/lib/rbs/type_alias_dependency.rb, line 17 def circular_definition?(alias_name) # Construct transitive closure, if not constructed already transitive_closure() unless @dependencies # Check for recursive type alias @dependencies[alias_name][alias_name] end
# File rbs-2.1.0/lib/rbs/type_alias_dependency.rb, line 41 def transitive_closure # Construct a graph of direct dependencies build_dependencies() # Construct transitive closure by using DFS(recursive technique) @direct_dependencies.each_key do |name| dependency(name, name) end end