diff --git a/lib/rbs/environment.rb b/lib/rbs/environment.rb index 0fb434714..777e46de3 100644 --- a/lib/rbs/environment.rb +++ b/lib/rbs/environment.rb @@ -58,12 +58,13 @@ def initialize def initialize_copy(other) @sources = other.sources.dup - @class_decls = other.class_decls.dup + @class_decls = other.class_decls.transform_values(&:dup) @interface_decls = other.interface_decls.dup @type_alias_decls = other.type_alias_decls.dup @constant_decls = other.constant_decls.dup @global_decls = other.global_decls.dup @class_alias_decls = other.class_alias_decls.dup + @normalize_module_name_cache = other.instance_variable_get(:@normalize_module_name_cache).dup end def self.from_loader(loader) diff --git a/lib/rbs/environment/class_entry.rb b/lib/rbs/environment/class_entry.rb index 73762330a..03fe326dc 100644 --- a/lib/rbs/environment/class_entry.rb +++ b/lib/rbs/environment/class_entry.rb @@ -12,6 +12,11 @@ def initialize(name) @context_decls = [] end + def initialize_copy(other) + @context_decls = other.context_decls.dup + self + end + def <<(context_decl) context_decls << context_decl @primary_decl = nil diff --git a/lib/rbs/environment/module_entry.rb b/lib/rbs/environment/module_entry.rb index 1f65cf490..47356c1b2 100644 --- a/lib/rbs/environment/module_entry.rb +++ b/lib/rbs/environment/module_entry.rb @@ -12,6 +12,11 @@ def initialize(name) @context_decls = [] end + def initialize_copy(other) + @context_decls = other.context_decls.dup + self + end + def <<(context_decl) context_decls << context_decl self