1616 * Copyright (C) 2002 Anders Bengtsson <ndrsbngtssn@yahoo.se>
1717 * Copyright (C) 2004 Charles O Nutter <headius@headius.com>
1818 * Copyright (C) 2004 Stefan Matthias Aust <sma@3plus4.de>
19- *
19+ *
2020 * Alternatively, the contents of this file may be used under the terms of
2121 * either of the GNU General Public License Version 2 or later (the "GPL"),
2222 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
3838import org .jruby .internal .runtime .methods .DelegatingDynamicMethod ;
3939import org .jruby .internal .runtime .methods .DynamicMethod ;
4040import org .jruby .internal .runtime .methods .IRMethodArgs ;
41+ import org .jruby .internal .runtime .methods .PartialDelegatingMethod ;
4142import org .jruby .internal .runtime .methods .ProcMethod ;
4243import org .jruby .runtime .ArgumentDescriptor ;
4344import org .jruby .runtime .Block ;
5152import org .jruby .runtime .builtin .IRubyObject ;
5253import org .jruby .runtime .callsite .CacheEntry ;
5354
54- /**
55+ /**
5556 * The RubyMethod class represents a RubyMethod object.
56- *
57+ *
5758 * You can get such a method by calling the "method" method of an object.
58- *
59+ *
5960 * Note: This was renamed from Method.java
60- *
61+ *
6162 * @author jpetersen
6263 * @since 0.2.3
6364 */
@@ -70,7 +71,7 @@ protected RubyMethod(Ruby runtime, RubyClass rubyClass) {
7071 }
7172
7273 /** Create the RubyMethod class and add it to the Ruby runtime.
73- *
74+ *
7475 */
7576 public static RubyClass createMethodClass (Ruby runtime ) {
7677 // TODO: NOT_ALLOCATABLE_ALLOCATOR is probably ok here. Confirm. JRUBY-415
@@ -81,7 +82,7 @@ public static RubyClass createMethodClass(Ruby runtime) {
8182
8283 methodClass .defineAnnotatedMethods (AbstractRubyMethod .class );
8384 methodClass .defineAnnotatedMethods (RubyMethod .class );
84-
85+
8586 return methodClass ;
8687 }
8788
@@ -108,7 +109,7 @@ public static RubyMethod newMethod(
108109 }
109110
110111 /** Call the method.
111- *
112+ *
112113 */
113114 @ JRubyMethod (name = {"call" , "[]" })
114115 public IRubyObject call (ThreadContext context , Block block ) {
@@ -132,7 +133,7 @@ public IRubyObject call(ThreadContext context, IRubyObject[] args, Block block)
132133 }
133134
134135 /** Returns the number of arguments a method accepted.
135- *
136+ *
136137 * @return the number of arguments of a method.
137138 */
138139 @ JRubyMethod
@@ -206,7 +207,7 @@ public RubyMethod rbClone() {
206207 }
207208
208209 /** Create a Proc object.
209- *
210+ *
210211 */
211212 @ JRubyMethod
212213 public IRubyObject to_proc (ThreadContext context ) {
@@ -225,19 +226,19 @@ public IRubyObject to_proc(ThreadContext context) {
225226 body = new MethodBlockBody (runtime .getStaticScopeFactory ().getDummyScope (), signature , entry , argsDesc ,
226227 receiver , originModule , originName , getFilename (), line == -1 ? -1 : line - 1 );
227228 Block b = MethodBlockBody .createMethodBlock (body );
228-
229+
229230 return RubyProc .newProc (runtime , b , Block .Type .LAMBDA );
230231 }
231232
232233 @ JRubyMethod
233234 public RubyUnboundMethod unbind () {
234235 RubyUnboundMethod unboundMethod =
235- RubyUnboundMethod .newUnboundMethod (implementationModule , methodName , originModule , originName , entry );
236+ RubyUnboundMethod .newUnboundMethod (implementationModule , methodName , originModule , originName , entry );
236237 unboundMethod .infectBy (this );
237-
238+
238239 return unboundMethod ;
239240 }
240-
241+
241242 @ JRubyMethod (name = {"inspect" , "to_s" })
242243 @ Override
243244 public IRubyObject inspect () {
@@ -246,7 +247,7 @@ public IRubyObject inspect() {
246247
247248 RubyString str = RubyString .newString (runtime , "#<" );
248249 String sharp = "#" ;
249-
250+
250251 str .catString (getType ().getName ()).catString (": " );
251252
252253 RubyModule definedClass ;
@@ -347,7 +348,19 @@ public IRubyObject curry(ThreadContext context, IRubyObject[] args) {
347348
348349 @ JRubyMethod
349350 public IRubyObject super_method (ThreadContext context ) {
350- return super_method (context , receiver , sourceModule .getSuperClass ());
351+ RubyModule superClass = null ;
352+ if (method instanceof PartialDelegatingMethod ) {
353+ PartialDelegatingMethod delegate = (PartialDelegatingMethod )method ;
354+ RubyModule definedClass = delegate .getRealMethod ().getDefinedClass ();
355+ RubyModule module = definedClass .findImplementer (sourceModule .getDelegate ());
356+
357+ if (module != null ) {
358+ superClass = module .getSuperClass ();
359+ }
360+ } else {
361+ superClass = sourceModule .getSuperClass ();
362+ }
363+ return super_method (context , receiver , superClass );
351364 }
352365
353366 @ JRubyMethod
0 commit comments