Skip to content

Commit

Permalink
Fixed inherirance from Module class. (#1530)
Browse files Browse the repository at this point in the history
  • Loading branch information
iliabylich authored and elia committed Jul 15, 2016
1 parent fc9c07a commit 1e3ccbb
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ Whitespace conventions:

- Fixed `defined?` for methods raising exceptions
- Fixed `Kernel#loop` (to catch StopIteration error)
- Fixed inheritance from the `Module` class.



Expand Down
2 changes: 1 addition & 1 deletion opal/corelib/module.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ def self.allocate
%x{
var module;
module = Opal.module_allocate();
module = Opal.module_allocate(self);
Opal.create_scope(Opal.Module.$$scope, module, null);
return module;
}
Expand Down
7 changes: 3 additions & 4 deletions opal/corelib/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@
}
}
else {
module = Opal.module_allocate();
module = Opal.module_allocate(Module);
Opal.create_scope(base.$$scope, module, name);
}

Expand All @@ -520,16 +520,15 @@
// Internal function to create a new module instance. This simply sets up
// the prototype hierarchy and method tables.
//
Opal.module_allocate = function() {
Opal.module_allocate = function(superclass) {
var mtor = function() {};
mtor.prototype = Module_alloc.prototype;
mtor.prototype = superclass.$$alloc.prototype;

function module_constructor() {}
module_constructor.prototype = new mtor();

var module = new module_constructor();
var module_prototype = {};
var superclass = Module;

// @property $$id Each class is assigned a unique `id` that helps
// comparation and implementation of `#object_id`
Expand Down
3 changes: 0 additions & 3 deletions spec/filters/bugs/module.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
fails "Module#class_eval raises a TypeError when the given eval-string can't be converted to string using to_str"
fails "Module#class_eval raises a TypeError when the given filename can't be converted to string using to_str"
fails "Module#class_eval uses the optional filename and lineno parameters for error messages"
fails "Module#class_exec defines method in the receiver's scope"
fails "Module#const_get raises a NameError if the constant is defined in the receiver's supperclass and the inherit flag is false" # requires to not copy the whole $$scope on inheriting
fails "Module#constants doesn't returns inherited constants when passed false"
fails "Module#constants doesn't returns inherited constants when passed nil"
Expand All @@ -85,7 +84,6 @@
fails "Module#include doesn't include module if it is included in a super class"
fails "Module#include? raises a TypeError when no module was given"
fails "Module#include? returns true if the given module is included by self or one of it's ancestors"
fails "Module#initialize is called on subclasses"
fails "Module#instance_method gives UnboundMethod method name, Module defined in and Module extracted from"
fails "Module#instance_method raises a NameError if the method has been undefined"
fails "Module#instance_method raises a TypeError if not passed a symbol"
Expand All @@ -105,7 +103,6 @@
fails "Module#module_eval raises a TypeError when the given eval-string can't be converted to string using to_str"
fails "Module#module_eval raises a TypeError when the given filename can't be converted to string using to_str"
fails "Module#module_eval uses the optional filename and lineno parameters for error messages"
fails "Module#module_exec defines method in the receiver's scope"
fails "Module#module_function as a toggle (no arguments) in a Module body does not affect module_evaled method definitions also if outside the eval itself"
fails "Module#module_function as a toggle (no arguments) in a Module body doesn't affect definitions when inside an eval even if the definitions are outside of it"
fails "Module#module_function as a toggle (no arguments) in a Module body has no effect if inside a module_eval if the definitions are outside of it"
Expand Down

0 comments on commit 1e3ccbb

Please sign in to comment.