Merge pull request #2519 from rubynerd-forks/ruby-fix-repeated-message-type-field
unwrap descriptor class before comparison of RepeatedField types
This commit is contained in:
commit
0289dd8f90
@ -606,12 +606,20 @@ static void check_repeated_field_type(VALUE val, const upb_fielddef* field) {
|
|||||||
rb_raise(rb_eTypeError, "Repeated field array has wrong element type");
|
rb_raise(rb_eTypeError, "Repeated field array has wrong element type");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self->field_type == UPB_TYPE_MESSAGE ||
|
if (self->field_type == UPB_TYPE_MESSAGE) {
|
||||||
self->field_type == UPB_TYPE_ENUM) {
|
|
||||||
if (self->field_type_class !=
|
if (self->field_type_class !=
|
||||||
get_def_obj(upb_fielddef_subdef(field))) {
|
Descriptor_msgclass(get_def_obj(upb_fielddef_subdef(field)))) {
|
||||||
rb_raise(rb_eTypeError,
|
rb_raise(rb_eTypeError,
|
||||||
"Repeated field array has wrong message/enum class");
|
"Repeated field array has wrong message class");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (self->field_type == UPB_TYPE_ENUM) {
|
||||||
|
if (self->field_type_class !=
|
||||||
|
EnumDescriptor_enummodule(get_def_obj(upb_fielddef_subdef(field)))) {
|
||||||
|
rb_raise(rb_eTypeError,
|
||||||
|
"Repeated field array has wrong enum class");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -126,6 +126,12 @@ class RepeatedFieldTest < Test::Unit::TestCase
|
|||||||
assert_equal false, m.repeated_string.empty?
|
assert_equal false, m.repeated_string.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_reassign
|
||||||
|
m = TestMessage.new
|
||||||
|
m.repeated_msg = Google::Protobuf::RepeatedField.new(:message, TestMessage2, [TestMessage2.new(:foo => 1)])
|
||||||
|
assert_equal m.repeated_msg.first, TestMessage2.new(:foo => 1)
|
||||||
|
end
|
||||||
|
|
||||||
def test_array_accessor
|
def test_array_accessor
|
||||||
m = TestMessage.new
|
m = TestMessage.new
|
||||||
reference_arr = %w(foo bar baz)
|
reference_arr = %w(foo bar baz)
|
||||||
|
Loading…
Reference in New Issue
Block a user