Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

protobuf: Handle AbstractMessage descendants #1411

Merged
merged 5 commits into from
Feb 23, 2023
Merged
Changes from 2 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
10 changes: 8 additions & 2 deletions lib/tapioca/dsl/compilers/protobuf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def decorate
klass.create_method("initialize", parameters: [kwargs_parameter], return_type: "void")
end
else
raise TypeError, "Unexpected descriptor class: #{descriptor.class.name}"
raise TypeError, "Unexpected descriptor class `#{descriptor.class.name}` for constant `#{constant}`"
end
end
end
Expand All @@ -162,7 +162,13 @@ def gather_constants
T.cast(desc, Google::Protobuf::EnumDescriptor).enummodule
end

results = T.cast(ObjectSpace.each_object(marker).to_a, T::Array[Module]).concat(enum_modules)
abstract_message_const = ::Google::Protobuf.const_get(:AbstractMessage)
abstract_message_descendants = descendants_of(abstract_message_const)

results = T.cast(
ObjectSpace.each_object(marker).to_a,
T::Array[Module],
).concat(enum_modules).concat(abstract_message_descendants) - [abstract_message_const]
results.any? ? results + [Google::Protobuf::RepeatedField, Google::Protobuf::Map] : []
end
end
Expand Down