Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion lib/tapioca/gem/pipeline.rb
Original file line number Diff line number Diff line change
Expand Up @@ -480,9 +480,20 @@ def add_to_alias_namespace(name)

#: (String name) -> bool
def alias_namespaced?(name)
@alias_namespace.any? do |namespace|
return true if @alias_namespace.any? do |namespace|
name.start_with?(namespace)
end

parts = name.split("::")
parts.pop

parts.each_index.any? do |index|
namespace = parts.first(index + 1).join("::")
next false unless symbol_in_payload?(namespace)

constant = constantize(namespace)
Runtime::Reflection.constant_defined?(constant) && Module === constant && name_of(constant) != namespace
end
end

#: (String name) -> void
Expand Down
14 changes: 14 additions & 0 deletions spec/tapioca/gem/pipeline_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,20 @@ module Foo::Bar; end
RBI
end

it "does not generate constants nested in a payload alias" do
mock_gem("yaml") do
add_ruby_file("lib/yaml.rb", <<~RB)
require "yaml"

module YAML
LOADER_VERSION = "0.4.0"
end
RB
end

assert_equal("", compile("yaml"))
end

it "must do mixin attribution properly" do
# This is pattern is taken from the private `typed_parameters` gem.
add_ruby_file("lib/typed_parameters.rb", <<~RUBY)
Expand Down
Loading