зеркало из https://github.com/github/ruby.git
Transition frozen string to frozen root shape
Co-Authored-By: Aaron Patterson <tenderlove@ruby-lang.org>
This commit is contained in:
Родитель
5ca23caa20
Коммит
0aaa6133ed
8
shape.c
8
shape.c
|
@ -203,14 +203,6 @@ rb_shape_transition_shape_frozen(VALUE obj)
|
|||
rb_shape_t* next_shape;
|
||||
|
||||
if (shape == rb_shape_get_root_shape()) {
|
||||
switch (BUILTIN_TYPE(obj)) {
|
||||
case T_OBJECT:
|
||||
case T_CLASS:
|
||||
case T_MODULE:
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
next_shape = rb_shape_get_frozen_root_shape();
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -10,7 +10,7 @@ describe :rbasic, shared: true do
|
|||
obj, _ = @data.call
|
||||
initial = @specs.get_flags(obj)
|
||||
obj.freeze
|
||||
@specs.get_flags(obj).should == @freeze | initial
|
||||
(@specs.get_flags(obj) & 0xFFFF).should == (@freeze | initial) & 0xFFFF
|
||||
end
|
||||
|
||||
it "supports setting the FREEZE flag" do
|
||||
|
|
|
@ -887,6 +887,18 @@ CODE
|
|||
end
|
||||
end
|
||||
|
||||
class StringWithIVSet < String
|
||||
def set_iv
|
||||
@foo = 1
|
||||
end
|
||||
end
|
||||
|
||||
def test_ivar_set_after_frozen_dup
|
||||
str = StringWithIVSet.new.freeze
|
||||
str.dup.set_iv
|
||||
assert_raise(FrozenError) { str.set_iv }
|
||||
end
|
||||
|
||||
def test_each
|
||||
verbose, $VERBOSE = $VERBOSE, nil
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче