Skip to content

Commit

Permalink
Set MetaClass of cloned object (#4919)
Browse files Browse the repository at this point in the history
In MRI, `method_clone` uses CLASS_OF method objects

```
clone = TypedData_Make_Struct(CLASS_OF(self), struct METHOD, &method_data_type, data);
```

By this change, `TestMethod#test_clone` will be passed.
  • Loading branch information
yui-knk authored and kares committed Jan 1, 2018
1 parent f8fb28d commit 0a9dc53
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 3 additions & 1 deletion core/src/main/java/org/jruby/RubyMethod.java
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,9 @@ private long hashCodeImpl() {
@JRubyMethod(name = "clone")
@Override
public RubyMethod rbClone() {
return newMethod(implementationModule, methodName, originModule, originName, method, receiver);
RubyMethod newMethod = newMethod(implementationModule, methodName, originModule, originName, method, receiver);
newMethod.setMetaClass(getMetaClass());
return newMethod;
}

/** Create a Proc object.
Expand Down
1 change: 0 additions & 1 deletion test/mri/excludes/TestMethod.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
exclude :test_alias_owner, "needs investigation"
exclude :test_body, "fails due RubyVM constant"
exclude :test_callee, "needs investigation"
exclude :test_clone, "needs investigation"
exclude :test_define_method_visibility, "needs investigation"
exclude :test_define_method_with_symbol, "scope changes in define_method methods?"
exclude :test_gced_bmethod, "often 'Timeout::Error: execution of assert_normal_exit expired' on CI"
Expand Down

0 comments on commit 0a9dc53

Please sign in to comment.