Ruby classes should not be includable / extendable
--------------------------------------------------
Key: JRUBY-883
URL: http://jira.codehaus.org/browse/JRUBY-883
Project: JRuby
Issue Type: Bug
Components: Core Classes/Modules
Affects Versions: JRuby 0.9.9
Reporter: Bill Dortch
Attachments: no_class_include.patch
JRuby currently allows classes to be included in and/or extend other
classes/modules:
{code}
class C
def boo
"boo"
end
end
class D
incude C
extend C
end
D.boo #=> "boo"
D.new.boo #=> "boo"
module M
extend C
end
M.boo #=> "boo"
{code}
This is forbidden by MRI Ruby (though it seems potentially useful to me).
The attached patch:
1. Prohibits classes from being used in include/extend
2. Undefines append_features and extend_object in RubyClass (matches MRI)
Error messages are in line with MRI's.
While I was in the neighborhood, I also resolved JRUBY-793. I've included the
fix with this patch, since it affects one of the same classes.
3. Adds class_variable_set and class_variable_get methods. Implementation
matches MRI.
I've included some unit tests as well; the coverage for class_variable get/set
is pretty complete, but a few more tests should be added for include/extend.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email