Skip to content

Commit

Permalink
Remove redundant required= for fixed-arity methods
Browse files Browse the repository at this point in the history
  • Loading branch information
headius committed Jan 4, 2024
1 parent 4499a67 commit ca291b9
Show file tree
Hide file tree
Showing 76 changed files with 492 additions and 492 deletions.
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/AbstractRubyMethod.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public final IRubyObject op_eql19(ThreadContext context, IRubyObject other) {
return op_eql(context, other);
}

@JRubyMethod(name = "eql?", required = 1)
@JRubyMethod(name = "eql?")
public IRubyObject op_eql(ThreadContext context, IRubyObject other) {
return RubyBoolean.newBoolean(context, equals(other) );
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/RubyArgsFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ public static IRubyObject eof_p(ThreadContext context, IRubyObject recv) {
}
}

@JRubyMethod(name = "pos=", required = 1)
@JRubyMethod(name = "pos=")
public static IRubyObject set_pos(ThreadContext context, IRubyObject recv, IRubyObject offset) {
return getCurrentDataFile(context, "no stream to set position").pos_set(context, offset);
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/RubyArithmeticSequence.java
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ public IRubyObject each_slice(ThreadContext context, IRubyObject arg, final Bloc
enumeratorizeWithSize(context, this, "each_slice", new IRubyObject[]{arg}, RubyArithmeticSequence::size);
}

@JRubyMethod(required = 1)
@JRubyMethod
public IRubyObject each_with_object(final ThreadContext context, IRubyObject arg, Block block) {
return block.isGiven() ? RubyEnumerable.each_with_objectCommon(context, this, block, arg) :
enumeratorizeWithSize(context, this, "each_with_object", new IRubyObject[]{arg}, RubyArithmeticSequence::size);
Expand Down
38 changes: 19 additions & 19 deletions core/src/main/java/org/jruby/RubyArray.java
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ protected IRubyObject initializeCommon(ThreadContext context, IRubyObject arg0,
/** rb_ary_initialize_copy
*
*/
@JRubyMethod(name = {"initialize_copy"}, required = 1, visibility=PRIVATE)
@JRubyMethod(name = {"initialize_copy"}, visibility=PRIVATE)
@Override
public IRubyObject initialize_copy(IRubyObject orig) {
return this.replace(orig);
Expand Down Expand Up @@ -764,7 +764,7 @@ public RubyArray aryDup() {
/** rb_ary_replace
*
*/
@JRubyMethod(name = {"replace"}, required = 1)
@JRubyMethod(name = {"replace"})
public IRubyObject replace(IRubyObject orig) {
unpack();
modifyCheck();
Expand Down Expand Up @@ -1434,7 +1434,7 @@ protected static IRubyObject size(ThreadContext context, RubyArray self, IRubyOb
/** rb_ary_push - specialized rb_ary_store
*
*/
@JRubyMethod(name = "<<", required = 1)
@JRubyMethod(name = "<<")
public RubyArray append(IRubyObject item) {
unpack();
modify();
Expand Down Expand Up @@ -1465,7 +1465,7 @@ public RubyArray push_m(IRubyObject[] items) {
return push(items);
}

@JRubyMethod(name = "push", alias = "append", required = 1)
@JRubyMethod(name = "push", alias = "append")
public RubyArray push(IRubyObject item) {
append(item);

Expand Down Expand Up @@ -1616,7 +1616,7 @@ public IRubyObject unshift19(IRubyObject[] items) {
/** rb_ary_includes
*
*/
@JRubyMethod(name = "include?", required = 1)
@JRubyMethod(name = "include?")
public RubyBoolean include_p(ThreadContext context, IRubyObject item) {
return RubyBoolean.newBoolean(context, includes(context, item));
}
Expand Down Expand Up @@ -1783,7 +1783,7 @@ public IRubyObject aset19(IRubyObject arg0, IRubyObject arg1, IRubyObject arg2)
/** rb_ary_at
*
*/
@JRubyMethod(name = "at", required = 1)
@JRubyMethod(name = "at")
public IRubyObject at(IRubyObject pos) {
return entry(RubyNumeric.num2long(pos));
}
Expand Down Expand Up @@ -2284,7 +2284,7 @@ public IRubyObject checkArrayType(){
/** rb_ary_equal
*
*/
@JRubyMethod(name = "==", required = 1)
@JRubyMethod(name = "==")
@Override
public IRubyObject op_equal(ThreadContext context, IRubyObject obj) {
if (this == obj) return context.tru;
Expand Down Expand Up @@ -2326,7 +2326,7 @@ public RubyBoolean compare(ThreadContext context, CallSite site, IRubyObject oth
/** rb_ary_eql
*
*/
@JRubyMethod(name = "eql?", required = 1)
@JRubyMethod(name = "eql?")
public IRubyObject eql(ThreadContext context, IRubyObject obj) {
if(!(obj instanceof RubyArray)) {
return context.fals;
Expand Down Expand Up @@ -2941,7 +2941,7 @@ public IRubyObject deconstruct(ThreadContext context) {
/** rb_ary_delete
*
*/
@JRubyMethod(required = 1)
@JRubyMethod
public IRubyObject delete(ThreadContext context, IRubyObject item, Block block) {
unpack();
int i2 = 0;
Expand Down Expand Up @@ -3025,7 +3025,7 @@ public IRubyObject delete_at(int pos) {
/** rb_ary_delete_at_m
*
*/
@JRubyMethod(name = "delete_at", required = 1)
@JRubyMethod(name = "delete_at")
public IRubyObject delete_at(IRubyObject obj) {
return delete_at((int) RubyNumeric.num2long(obj));
}
Expand Down Expand Up @@ -3208,7 +3208,7 @@ private IRubyObject zipCommon(ThreadContext context, IRubyObject[] args, Block b
/** rb_ary_cmp
*
*/
@JRubyMethod(name = "<=>", required = 1)
@JRubyMethod(name = "<=>")
public IRubyObject op_cmp(ThreadContext context, IRubyObject obj) {
final Ruby runtime = context.runtime;

Expand Down Expand Up @@ -3329,7 +3329,7 @@ public IRubyObject slice_bang(IRubyObject arg0, IRubyObject arg1) {
/** rb_ary_assoc
*
*/
@JRubyMethod(name = "assoc", required = 1)
@JRubyMethod(name = "assoc")
public IRubyObject assoc(ThreadContext context, IRubyObject key) {
Ruby runtime = context.runtime;

Expand All @@ -3347,7 +3347,7 @@ public IRubyObject assoc(ThreadContext context, IRubyObject key) {
/** rb_ary_rassoc
*
*/
@JRubyMethod(name = "rassoc", required = 1)
@JRubyMethod(name = "rassoc")
public IRubyObject rassoc(ThreadContext context, IRubyObject value) {
Ruby runtime = context.runtime;

Expand Down Expand Up @@ -3547,7 +3547,7 @@ public IRubyObject nitems() {
/** rb_ary_plus
*
*/
@JRubyMethod(name = "+", required = 1)
@JRubyMethod(name = "+")
public IRubyObject op_plus(IRubyObject obj) {
Ruby runtime = metaClass.runtime;
RubyArray y = obj.convertToArray();
Expand Down Expand Up @@ -3581,7 +3581,7 @@ public IRubyObject op_plus(IRubyObject obj) {
/** rb_ary_times
*
*/
@JRubyMethod(name = "*", required = 1)
@JRubyMethod(name = "*")
public IRubyObject op_times(ThreadContext context, IRubyObject times) {
IRubyObject tmp = times.checkStringType();

Expand Down Expand Up @@ -3743,7 +3743,7 @@ public IRubyObject uniq19(ThreadContext context, Block block) {
/** rb_ary_diff
*
*/
@JRubyMethod(name = "-", required = 1)
@JRubyMethod(name = "-")
public IRubyObject op_diff(IRubyObject other) {
final Ruby runtime = metaClass.runtime;

Expand Down Expand Up @@ -3851,7 +3851,7 @@ public IRubyObject intersect_p(ThreadContext context, IRubyObject other) {
/** MRI: rb_ary_and
*
*/
@JRubyMethod(name = "&", required = 1)
@JRubyMethod(name = "&")
public IRubyObject op_and(IRubyObject other) {
final Ruby runtime = metaClass.runtime;

Expand Down Expand Up @@ -3892,7 +3892,7 @@ public IRubyObject op_and(IRubyObject other) {
/** rb_ary_or
*
*/
@JRubyMethod(name = "|", required = 1)
@JRubyMethod(name = "|")
public IRubyObject op_or(IRubyObject other) {
final Ruby runtime = metaClass.runtime;
RubyArray ary2 = other.convertToArray();
Expand Down Expand Up @@ -5436,7 +5436,7 @@ public static IRubyObject try_convert(ThreadContext context, IRubyObject self, I
return arg.checkArrayType();
}

@JRubyMethod(name = "pack", required = 1)
@JRubyMethod(name = "pack")
public RubyString pack(ThreadContext context, IRubyObject obj) {
RubyString format = obj.convertToString();
try {
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/org/jruby/RubyBasicObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -1165,7 +1165,7 @@ public IRubyObject op_not(ThreadContext context) {
* @param other other object
* @return false if this == other, true otherwise
*/
@JRubyMethod(name = "!=", required = 1)
@JRubyMethod(name = "!=")
public IRubyObject op_not_equal(ThreadContext context, IRubyObject other) {
return RubyBoolean.newBoolean(context, !sites(context).op_equal.call(context, this, this, other).isTrue());
}
Expand Down Expand Up @@ -1964,7 +1964,7 @@ private void callFinalizer(IRubyObject finalizer) {
*
* Will use Java identity equality.
*/
@JRubyMethod(name = "equal?", required = 1)
@JRubyMethod(name = "equal?")
public IRubyObject equal_p(ThreadContext context, IRubyObject other) {
return this == other ? context.tru : context.fals;
}
Expand Down
12 changes: 6 additions & 6 deletions core/src/main/java/org/jruby/RubyBignum.java
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ private IRubyObject subtractOther(ThreadContext context, IRubyObject other) {
/** rb_big_mul
*
*/
@JRubyMethod(name = "*", required = 1)
@JRubyMethod(name = "*")
public IRubyObject op_mul(ThreadContext context, IRubyObject other) {
if (other instanceof RubyFixnum) {
return op_mul(context, ((RubyFixnum) other).value);
Expand Down Expand Up @@ -605,7 +605,7 @@ public IRubyObject idiv(ThreadContext context, long other) {
*
*/
@Override
@JRubyMethod(name = "divmod", required = 1)
@JRubyMethod(name = "divmod")
public IRubyObject divmod(ThreadContext context, IRubyObject other) {
final BigInteger otherValue;
if (other instanceof RubyFixnum) {
Expand Down Expand Up @@ -634,7 +634,7 @@ public IRubyObject divmod(ThreadContext context, IRubyObject other) {
/** rb_big_modulo
*
*/
@JRubyMethod(name = {"%", "modulo"}, required = 1)
@JRubyMethod(name = {"%", "modulo"})
public IRubyObject op_mod(ThreadContext context, IRubyObject other) {
if (other instanceof RubyFixnum) {
return op_mod(context, ((RubyFixnum) other).value);
Expand Down Expand Up @@ -684,7 +684,7 @@ public IRubyObject op_mod19(ThreadContext context, IRubyObject other) {
*
*/
@Override
@JRubyMethod(name = "remainder", required = 1)
@JRubyMethod(name = "remainder")
public IRubyObject remainder(ThreadContext context, IRubyObject other) {
if (other instanceof RubyFloat && ((RubyFloat) other).value == 0) {
throw context.runtime.newZeroDivisionError();
Expand Down Expand Up @@ -714,7 +714,7 @@ public IRubyObject remainder19(ThreadContext context, IRubyObject other) {
*
*/
@Override
@JRubyMethod(name = "quo", required = 1)
@JRubyMethod(name = "quo")
public IRubyObject quo(ThreadContext context, IRubyObject other) {
if (other instanceof RubyInteger && ((RubyInteger) other).getDoubleValue() == 0) {
throw context.runtime.newZeroDivisionError();
Expand All @@ -739,7 +739,7 @@ public final IRubyObject quo19(ThreadContext context, IRubyObject other) {
*
*/
@Override
@JRubyMethod(name = {"**", "power"}, required = 1)
@JRubyMethod(name = {"**", "power"})
public IRubyObject op_pow(ThreadContext context, IRubyObject other) {
Ruby runtime = context.runtime;
if (other == RubyFixnum.zero(runtime)) return RubyFixnum.one(runtime);
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/RubyBinding.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public IRubyObject initialize(ThreadContext context) {
return this;
}

@JRubyMethod(name = "initialize_copy", required = 1, visibility = Visibility.PRIVATE)
@JRubyMethod(name = "initialize_copy", visibility = Visibility.PRIVATE)
@Override
public IRubyObject initialize_copy(IRubyObject other) {
RubyBinding otherBinding = (RubyBinding)other;
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/RubyChain.java
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ private static IRubyObject enumChainTotalSize(ThreadContext context, IRubyObject
return total;
}

@JRubyMethod(name = "+", required = 1)
@JRubyMethod(name = "+")
public IRubyObject op_plus(ThreadContext context, IRubyObject obj) {
return RubyChain.newChain(context, new IRubyObject[] {this, obj});
}
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/org/jruby/RubyClass.java
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,7 @@ private RubyClass initializeCommon(ThreadContext context, RubyClass superClazz,
/** rb_class_init_copy
*
*/
@JRubyMethod(name = "initialize_copy", required = 1, visibility = PRIVATE)
@JRubyMethod(name = "initialize_copy", visibility = PRIVATE)
@Override
public IRubyObject initialize_copy(IRubyObject original) {
checkNotInitialized();
Expand Down Expand Up @@ -1189,7 +1189,7 @@ public RubyModule getRealModule() {
return getRealClass();
}

@JRubyMethod(name = "inherited", required = 1, visibility = PRIVATE)
@JRubyMethod(name = "inherited", visibility = PRIVATE)
public IRubyObject inherited(ThreadContext context, IRubyObject arg) {
return context.nil;
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/RubyClassPathVariable.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public IRubyObject append(IRubyObject obj) {
return append(obj.getRuntime().getCurrentContext(), obj);
}

@JRubyMethod(name = {"append", "<<"}, required = 1)
@JRubyMethod(name = {"append", "<<"})
public IRubyObject append(ThreadContext context, IRubyObject obj) {
IRubyObject[] paths;
if (obj.respondsTo("to_a")) {
Expand Down
12 changes: 6 additions & 6 deletions core/src/main/java/org/jruby/RubyComparable.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public static IRubyObject invcmp(final ThreadContext context, ThreadContext.Recu
/** cmp_equal (cmp_eq inlined here)
*
*/
@JRubyMethod(name = "==", required = 1)
@JRubyMethod(name = "==")
public static IRubyObject op_equal(ThreadContext context, IRubyObject recv, IRubyObject other) {
return callCmpMethod(context, recv, other, context.fals);
}
Expand Down Expand Up @@ -178,7 +178,7 @@ private static IRubyObject callCmpMethod(final ThreadContext context, final IRub
*
*/
// <=> may return nil in many circumstances, e.g. 3 <=> NaN
@JRubyMethod(name = ">", required = 1)
@JRubyMethod(name = ">")
public static RubyBoolean op_gt(ThreadContext context, IRubyObject recv, IRubyObject other) {
IRubyObject result = sites(context).op_cmp.call(context, recv, recv, other);

Expand All @@ -190,7 +190,7 @@ public static RubyBoolean op_gt(ThreadContext context, IRubyObject recv, IRubyOb
/** cmp_ge
*
*/
@JRubyMethod(name = ">=", required = 1)
@JRubyMethod(name = ">=")
public static RubyBoolean op_ge(ThreadContext context, IRubyObject recv, IRubyObject other) {
IRubyObject result = sites(context).op_cmp.call(context, recv, recv, other);

Expand All @@ -202,7 +202,7 @@ public static RubyBoolean op_ge(ThreadContext context, IRubyObject recv, IRubyOb
/** cmp_lt
*
*/
@JRubyMethod(name = "<", required = 1)
@JRubyMethod(name = "<")
public static RubyBoolean op_lt(ThreadContext context, IRubyObject recv, IRubyObject other) {
IRubyObject result = sites(context).op_cmp.call(context, recv, recv, other);

Expand All @@ -222,7 +222,7 @@ public static RubyBoolean op_lt(ThreadContext context, CallSite cmp, IRubyObject
/** cmp_le
*
*/
@JRubyMethod(name = "<=", required = 1)
@JRubyMethod(name = "<=")
public static RubyBoolean op_le(ThreadContext context, IRubyObject recv, IRubyObject other) {
IRubyObject result = sites(context).op_cmp.call(context, recv, recv, other);

Expand All @@ -234,7 +234,7 @@ public static RubyBoolean op_le(ThreadContext context, IRubyObject recv, IRubyOb
/** cmp_between
*
*/
@JRubyMethod(name = "between?", required = 2)
@JRubyMethod(name = "between?")
public static RubyBoolean between_p(ThreadContext context, IRubyObject recv, IRubyObject first, IRubyObject second) {
return RubyBoolean.newBoolean(context, op_lt(context, recv, first).isFalse() && op_gt(context, recv, second).isFalse());
}
Expand Down
Loading

0 comments on commit ca291b9

Please sign in to comment.