@@ -33,6 +33,18 @@ def valid_non_kw_args?(positional_arg_count, optional_max_arg_count=positional_a
33
33
optional_max_arg_count <= max_non_kw_args
34
34
end
35
35
36
+ def classify_arity ( arity = @method . arity )
37
+ if arity < 0
38
+ # `~` inverts the one's complement and gives us the
39
+ # number of required args
40
+ @min_non_kw_args = ~arity
41
+ @max_non_kw_args = INFINITY
42
+ else
43
+ @min_non_kw_args = arity
44
+ @max_non_kw_args = arity
45
+ end
46
+ end
47
+
36
48
if RubyFeatures . optional_and_splat_args_supported?
37
49
def description
38
50
@description ||= begin
@@ -137,18 +149,7 @@ def unlimited_args?
137
149
false
138
150
end
139
151
140
- def classify_parameters
141
- arity = @method . arity
142
- if arity < 0
143
- # `~` inverts the one's complement and gives us the
144
- # number of required args
145
- @min_non_kw_args = ~arity
146
- @max_non_kw_args = INFINITY
147
- else
148
- @min_non_kw_args = arity
149
- @max_non_kw_args = arity
150
- end
151
- end
152
+ alias_method :classify_parameters , :classify_arity
152
153
end
153
154
154
155
INFINITY = 1 / 0.0
@@ -166,13 +167,7 @@ class MethodSignature < remove_const(:MethodSignature)
166
167
def classify_parameters
167
168
super
168
169
if ( arity = @method . arity ) != 0 && @method . parameters . empty?
169
- if arity < 0
170
- @min_non_kw_args = ~arity
171
- @max_non_kw_args = INFINITY
172
- else
173
- @min_non_kw_args = arity
174
- @max_non_kw_args = arity
175
- end
170
+ classify_arity ( arity )
176
171
end
177
172
end
178
173
end
@@ -185,25 +180,14 @@ class MethodSignature < remove_const(:MethodSignature)
185
180
186
181
def classify_parameters
187
182
super
188
- if @method . arity == -1
189
- arity = java_single_overload_arity
190
- if arity < 0
191
- @min_non_kw_args = ~arity
192
- @max_non_kw_args = INFINITY
193
- else
194
- @min_non_kw_args = arity
195
- @max_non_kw_args = arity
196
- end
197
- end
198
- end
199
-
200
- def java_single_overload_arity
201
- return @method . arity unless @method . owner . respond_to? ( :java_class )
183
+ return unless @method . arity == -1 && @method . owner . respond_to? ( :java_class )
202
184
java_instance_methods = @method . owner . java_class . java_instance_methods
203
185
compatible_overloads = java_instance_methods . select do |java_method |
204
186
@method == @method . owner . instance_method ( java_method . name )
205
187
end
206
- ( compatible_overloads . size == 1 ) ? compatible_overloads . first . arity : @method . arity
188
+ if compatible_overloads . size == 1
189
+ classify_arity ( compatible_overloads . first . arity )
190
+ end
207
191
end
208
192
end
209
193
end
0 commit comments