@@ -424,13 +424,8 @@ private void flattenMerge(final ThreadContext context, final IRubyObject set, fi
424
424
}
425
425
}
426
426
else {
427
- set .callMethod (context , "each" , IRubyObject .NULL_ARRAY , new Block (
428
- new EachBody (context .runtime ) {
429
- IRubyObject yieldImpl (ThreadContext context , IRubyObject e ) {
430
- addFlattened (context , seen , e ); return context .nil ;
431
- }
432
- })
433
- );
427
+ // call on superclasses to get SetLike impl
428
+ getType ().getSuperClass ().finvoke (context , this , "flatten_merge" , set );
434
429
}
435
430
}
436
431
@@ -495,7 +490,9 @@ public IRubyObject superset_p(final ThreadContext context, IRubyObject set) {
495
490
size () >= ((RubySet ) set ).size () && allElementsIncluded ((RubySet ) set )
496
491
);
497
492
}
498
- throw context .runtime .newArgumentError ("value must be a set" );
493
+
494
+ // call on superclasses to get SetLike impl
495
+ return getType ().getSuperClass ().finvoke (context , this , "superset?" , set );
499
496
}
500
497
501
498
// Returns true if the set is a proper superset of the given set.
@@ -510,7 +507,9 @@ public IRubyObject proper_superset_p(final ThreadContext context, IRubyObject se
510
507
size () > ((RubySet ) set ).size () && allElementsIncluded ((RubySet ) set )
511
508
);
512
509
}
513
- throw context .runtime .newArgumentError ("value must be a set" );
510
+
511
+ // call on superclasses to get SetLike impl
512
+ return getType ().getSuperClass ().finvoke (context , this , "proper_superset?" , set );
514
513
}
515
514
516
515
@ JRubyMethod (name = "subset?" , alias = { "<=" })
@@ -524,7 +523,9 @@ public IRubyObject subset_p(final ThreadContext context, IRubyObject set) {
524
523
size () <= ((RubySet ) set ).size () && allElementsIncluded ((RubySet ) set )
525
524
);
526
525
}
527
- throw context .runtime .newArgumentError ("value must be a set" );
526
+
527
+ // call on superclasses to get SetLike impl
528
+ return getType ().getSuperClass ().finvoke (context , this , "subset?" , set );
528
529
}
529
530
530
531
@ JRubyMethod (name = "proper_subset?" , alias = { "<" })
@@ -538,7 +539,9 @@ public IRubyObject proper_subset_p(final ThreadContext context, IRubyObject set)
538
539
size () < ((RubySet ) set ).size () && allElementsIncluded ((RubySet ) set )
539
540
);
540
541
}
541
- throw context .runtime .newArgumentError ("value must be a set" );
542
+
543
+ // call on superclasses to get SetLike impl
544
+ return getType ().getSuperClass ().finvoke (context , this , "proper_subset?" , set );
542
545
}
543
546
544
547
/**
@@ -549,7 +552,9 @@ public IRubyObject intersect_p(final ThreadContext context, IRubyObject set) {
549
552
if ( set instanceof RubySet ) {
550
553
return context .runtime .newBoolean ( intersect ((RubySet ) set ) );
551
554
}
552
- throw context .runtime .newArgumentError ("value must be a set" );
555
+
556
+ // call on superclasses to get SetLike impl
557
+ return getType ().getSuperClass ().finvoke (context , this , "intersect?" , set );
553
558
}
554
559
555
560
public boolean intersect (final RubySet set ) {
@@ -577,7 +582,9 @@ public IRubyObject disjoint_p(final ThreadContext context, IRubyObject set) {
577
582
if ( set instanceof RubySet ) {
578
583
return context .runtime .newBoolean ( ! intersect ((RubySet ) set ) );
579
584
}
580
- throw context .runtime .newArgumentError ("value must be a set" );
585
+
586
+ // call on superclasses to get SetLike impl
587
+ return context .runtime .newBoolean (!getType ().getSuperClass ().finvoke (context , this , "intersect?" , set ).isTrue ());
581
588
}
582
589
583
590
@ JRubyMethod
@@ -873,7 +880,9 @@ public IRubyObject op_equal(ThreadContext context, IRubyObject other) {
873
880
return context .tru ;
874
881
}
875
882
}
876
- return context .fals ;
883
+
884
+ // call on superclasses to get SetLike impl
885
+ return getType ().getSuperClass ().finvoke (context , this , "==" , other );
877
886
}
878
887
879
888
@ JRubyMethod (name = "reset" )