Skip to content

Commit

Permalink
Always use dispatch_super() for handling super calls
Browse files Browse the repository at this point in the history
  • Loading branch information
adambeynon committed Sep 25, 2013
1 parent 26eaf56 commit d387311
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 22 deletions.
23 changes: 2 additions & 21 deletions lib/opal/parser.rb
Expand Up @@ -2077,29 +2077,10 @@ def process_super(sexp, level)
end

def js_super args, pass_block, sexp
if @scope.def_in_class?
@scope.uses_block!
mid = @scope.mid.to_s

if @scope.uses_super
sid = @scope.uses_super
else
sid = @scope.uses_super = "super_#{unique_temp}"
end

if pass_block
@scope.uses_block!
[f("(#{sid}._p = $iter, #{sid}.apply(#{current_self}, ", sexp), args, f("))", sexp)]
else
[f("#{sid}.apply(#{current_self}, ", sexp), args, f(")", sexp)]
end


elsif @scope.type == :def
if @scope.type == :def
@scope.uses_block!
@scope.identify!
cls_name = @scope.parent.name || "#{current_self}._klass._proto"
jsid = mid_to_jsid @scope.mid.to_s

if pass_block
@scope.uses_block!
Expand All @@ -2115,7 +2096,7 @@ def js_super args, pass_block, sexp
end

elsif @scope.type == :iter
chain, defn, mid = @scope.get_super_chain
chain, _, mid = @scope.get_super_chain
trys = chain.map { |c| "#{c}._sup" }.join ' || '
[f("(#{trys} || #{current_self}._klass._super._proto[#{mid}]).apply(#{current_self}, ", sexp), args, f(")", sexp)]
else
Expand Down
3 changes: 2 additions & 1 deletion spec/filters/bugs/language.rb
Expand Up @@ -282,6 +282,7 @@
fails "The super keyword calls the method on the calling class including modules"
fails "The super keyword searches the full inheritence chain including modules"
fails "The super keyword calls the correct method when the superclass argument list is different from the subclass"
fails "The super keyword respects the original module a method is aliased from"

fails "The until modifier with begin .. end block restart the current iteration without reevaluting condition with redo"
fails "The until modifier with begin .. end block skips to end of body with next"
Expand Down Expand Up @@ -335,4 +336,4 @@
fails "The yield call taking no arguments ignores assignment to the explicit block argument and calls the passed block"
fails "The yield call taking a single splatted argument passes no values when give nil as an argument"
fails "The yield call taking multiple arguments with a splat does not pass an argument value if the splatted argument is nil"
end
end

0 comments on commit d387311

Please sign in to comment.