Permalink
Browse files

Minor fixes:

- Some methods were declared as taking RubyArray parameters instead of IList
- One more instance of RequireNotFrozen
  • Loading branch information...
1 parent 3f5b7a6 commit b3efe762f258769928f063da7eca17e96c02b870 Orion Edwards [GGL] committed Jan 6, 2012
@@ -542,25 +542,19 @@ public static class IListOps {
[RubyMethod("[]=")]
public static object SetElement(ConversionStorage<IList>/*!*/ arrayTryCast, ConversionStorage<int> fixnumCast,
- RubyArray/*!*/ self, object index, object length, object value) {
+ IList/*!*/ self, object index, object length, object value) {
- self.RequireNotFrozen(); // rubyspec says we must check for frozen before trying to coerce the index
+ RequireNotFrozen(self); // rubyspec says we must check for frozen before trying to coerce the index
return SetElement(arrayTryCast, self as IList, Protocols.CastToFixnum(fixnumCast, index), Protocols.CastToFixnum(fixnumCast, length), value);
}
[RubyMethod("[]=")]
- public static object SetElement(ConversionStorage<IList>/*!*/ arrayTryCast, RubyArray/*!*/ self,
- [DefaultProtocol]int index, [DefaultProtocol]int length, object value) {
-
- return SetElement(arrayTryCast, self as IList, index, length, value);
- }
-
- [RubyMethod("[]=")]
public static object SetElement(ConversionStorage<IList>/*!*/ arrayTryCast, IList/*!*/ self,
[DefaultProtocol]int index, [DefaultProtocol]int length, object value) {
if (length < 0) {
throw RubyExceptions.CreateIndexError("negative length ({0})", length);
}
+ RequireNotFrozen(self);
index = NormalizeIndexThrowIfNegative(self, index);
@@ -1015,10 +1009,7 @@ public static class IListOps {
[RubyMethod("fill")]
public static IList/*!*/ Fill(IList/*!*/ self, object obj, [DefaultParameterValue(0)]int start) {
- var rubyArray = self as RubyArray;
- if (rubyArray != null) {
- rubyArray.RequireNotFrozen(); // rubyspec says we must check for frozen before doing anything else
- }
+ RequireNotFrozen(self);
// Note: Array#fill(obj, start) is not equivalent to Array#fill(obj, start, 0)
// (as per MRI behavior, the latter can expand the array if start > length, but the former doesn't)
@@ -7840,11 +7840,10 @@ public sealed class BuiltinsLibraryInitializer : IronRuby.Builtins.LibraryInitia
);
DefineLibraryMethod(module, "[]=", 0x51,
- new[] { 0x00010000U, 0x00010000U, 0x00000000U, 0x00060000U, 0x00060000U, 0x00000000U, 0x00000000U},
+ new[] { 0x00010000U, 0x00010000U, 0x00000000U, 0x00060000U, 0x00000000U, 0x00000000U},
new Func<IronRuby.Builtins.RubyArray, System.Int32, System.Object, System.Object>(IronRuby.Builtins.IListOps.SetElement),
new Func<System.Collections.IList, System.Int32, System.Object, System.Object>(IronRuby.Builtins.IListOps.SetElement),
- new Func<IronRuby.Runtime.ConversionStorage<System.Collections.IList>, IronRuby.Runtime.ConversionStorage<System.Int32>, IronRuby.Builtins.RubyArray, System.Object, System.Object, System.Object, System.Object>(IronRuby.Builtins.IListOps.SetElement),
- new Func<IronRuby.Runtime.ConversionStorage<System.Collections.IList>, IronRuby.Builtins.RubyArray, System.Int32, System.Int32, System.Object, System.Object>(IronRuby.Builtins.IListOps.SetElement),
+ new Func<IronRuby.Runtime.ConversionStorage<System.Collections.IList>, IronRuby.Runtime.ConversionStorage<System.Int32>, System.Collections.IList, System.Object, System.Object, System.Object, System.Object>(IronRuby.Builtins.IListOps.SetElement),
new Func<IronRuby.Runtime.ConversionStorage<System.Collections.IList>, System.Collections.IList, System.Int32, System.Int32, System.Object, System.Object>(IronRuby.Builtins.IListOps.SetElement),
new Func<IronRuby.Runtime.ConversionStorage<System.Collections.IList>, IronRuby.Runtime.ConversionStorage<System.Int32>, IronRuby.Builtins.RubyArray, System.Object, System.Object, System.Object>(IronRuby.Builtins.IListOps.SetElement),
new Func<IronRuby.Runtime.ConversionStorage<System.Collections.IList>, IronRuby.Runtime.ConversionStorage<System.Int32>, System.Collections.IList, System.Object, System.Object, System.Object>(IronRuby.Builtins.IListOps.SetElement)

0 comments on commit b3efe76

Please sign in to comment.