Skip to content

Commit

Permalink
Drop sets preventing cycles (cause there are none anymore)
Browse files Browse the repository at this point in the history
  • Loading branch information
straight-shoota committed Oct 8, 2024
1 parent 6ee7bbd commit 507f766
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 25 deletions.
7 changes: 0 additions & 7 deletions src/compiler/crystal/semantic/abstract_def_checker.cr
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
# ```
class Crystal::AbstractDefChecker
def initialize(@program : Program)
@all_checked = Set(Type).new
end

def run
Expand All @@ -41,12 +40,6 @@ class Crystal::AbstractDefChecker
end

def check_single(type)
if @all_checked.includes?(type)
::raise "AbstractDefChecker duplicate: #{type} (#{type.class})"
return
end
@all_checked << type

if type.abstract? || type.module?
type.defs.try &.each_value do |defs_with_metadata|
defs_with_metadata.each do |def_with_metadata|
Expand Down
8 changes: 0 additions & 8 deletions src/compiler/crystal/semantic/recursive_struct_checker.cr
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@
# Because the type of `Test.@test` would be: `Test | Nil`.
class Crystal::RecursiveStructChecker
@program : Program
@all_checked : Set(Type)

def initialize(@program)
@all_checked = Set(Type).new
end

def run
Expand All @@ -34,12 +32,6 @@ class Crystal::RecursiveStructChecker
end

def check_single(type)
has_not_been_checked = @all_checked.add?(type)
unless has_not_been_checked
raise "RecursiveStructChecker duplicate: #{type} (#{type.class})"
return
end

if struct?(type)
target = type
checked = Set(Type).new
Expand Down
13 changes: 3 additions & 10 deletions src/compiler/crystal/semantic/type_declaration_processor.cr
Original file line number Diff line number Diff line change
Expand Up @@ -621,17 +621,10 @@ struct Crystal::TypeDeclarationProcessor
end

private def remove_duplicate_instance_vars_declarations
# All the types that we checked for duplicate variables
duplicates_checked = Set(Type).new
remove_duplicate_instance_vars_declarations(@program, duplicates_checked)
remove_duplicate_instance_vars_declarations(@program)
end

private def remove_duplicate_instance_vars_declarations(type : Type, duplicates_checked : Set(Type))
unless duplicates_checked.add?(type)
raise "remove_duplicate_instance_vars_declarations duplicate: #{type} (#{type.class})"
return
end

private def remove_duplicate_instance_vars_declarations(type : Type)
# If a class has an instance variable that already exists in a superclass, remove it.
# Ideally we should process instance variables in a top-down fashion, but it's tricky
# with modules and multiple-inheritance. Removing duplicates at the end is maybe
Expand All @@ -653,7 +646,7 @@ struct Crystal::TypeDeclarationProcessor
end

type.types?.try &.each_value do |nested_type|
remove_duplicate_instance_vars_declarations(nested_type, duplicates_checked)
remove_duplicate_instance_vars_declarations(nested_type)
end
end

Expand Down

0 comments on commit 507f766

Please sign in to comment.