edit: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/IronRuby.Tests/IronRuby.Tests.csproj;C1605253
File: IronRuby.Tests.csproj
===================================================================
--- $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/IronRuby.Tests/IronRuby.Tests.csproj;C1605253  (server)    3/2/2010 5:24 PM
+++ Shelved Change: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/IronRuby.Tests/IronRuby.Tests.csproj;morefixes
@@ -116,6 +116,7 @@
     <Reference Include="System.Xml" />
     <Reference Include="System.Core" Condition="'$(TargetFrameworkVersion)' == 'v4.0'" />
     <Reference Include="Microsoft.CSharp" Condition="'$(TargetFrameworkVersion)' == 'v4.0'" />
+    <Reference Include="System.Numerics" Condition=" '$(TargetFrameworkVersion)' == 'v4.0' " />
   </ItemGroup>
   <ItemGroup>
     <ProjectReference Include="..\..\..\..\..\ndp\fx\src\Core\Microsoft\Scripting\Microsoft.Scripting.ExtensionAttribute.csproj" Condition="'$(TargetFrameworkVersion)' != 'v4.0'">
===================================================================
edit: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/IronRuby.Tests/RubyTests.cs;C1610421
File: RubyTests.cs
===================================================================
--- $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/IronRuby.Tests/RubyTests.cs;C1610421  (server)    3/1/2010 6:49 PM
+++ Shelved Change: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/IronRuby.Tests/RubyTests.cs;morefixes
@@ -70,6 +70,7 @@
                 Scenario_RubyCategorizer1,
                 NameMangling1,
                 NameMangling2,
+                DelegateChainClone1,
 
                 Constants1A,
                 Constants1B,
@@ -515,6 +516,7 @@
                 ClrHashEqualsToString3,
                 ClrToString1,
                 ClrHashEquals4,
+                ClrTypeVariance1,
                 HostingDefaultOptions1,
                 Interactive1,
                 Interactive2,
@@ -670,6 +672,7 @@
                 ClassDuplication5,
                 StructDup1,
                 ClassDuplication6,
+                ClassDuplication7,
                 Clone1,
                 Dup1,
                 Structs1,
@@ -755,6 +758,9 @@
                 Dlr_DynamicObject1, 
 
                 Serialization1,
+#if !CLR2
+                ClrBigIntegerV4,
+#endif
             };
         }
     }
===================================================================
edit: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/IronRuby.Tests/Runtime/ClrTests.cs;C1605253
File: ClrTests.cs
===================================================================
--- $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/IronRuby.Tests/Runtime/ClrTests.cs;C1605253  (server)    3/1/2010 6:47 PM
+++ Shelved Change: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/IronRuby.Tests/Runtime/ClrTests.cs;morefixes
@@ -26,6 +26,9 @@
 using Microsoft.Scripting.Math;
 using Microsoft.Scripting.Runtime;
 using Microsoft.Scripting.Utils;
+#if !CLR2
+using BigInt = System.Numerics.BigInteger;
+#endif
 
 namespace InteropTests.Generics1 {
     public class C {
@@ -2963,7 +2966,7 @@
 
         #endregion
 
-        #region Misc: Inclusions, Aliases
+        #region Misc: Inclusions, Aliases, Co/contra-variance
 
         /// <summary>
         /// CLR class re-def and inclusions.
@@ -3002,7 +3005,59 @@
 puts a.count");
             }, "3");
         }
+
+        public class ClassWithTypeVariance1 {
+            public int Foo(IEnumerable<object> e) {
+                int i = 0;
+                foreach (var item in e) {
+                    i++;
+                }
+                return i;
+            }
+        }
 
+        public void ClrTypeVariance1() {
+            Context.ObjectClass.SetConstant("C", new ClassWithTypeVariance1());
+            TestOutput(@"
+include System::Collections::Generic
+
+class E
+  include IEnumerable[System::String]
+  
+  def get_enumerator
+    list = List[System::String].new
+    list.add 'a'    
+    list.add 'b'
+    list.add 'c'
+    list.get_enumerator
+  end
+end
+
+p C.foo(E.new) rescue p $!
+", 
+#if CLR2
+"#<TypeError: can't convert E into System::Collections::Generic::IEnumerable[Object]>"
+#else
+"3"
+#endif
+);
+        }
+
+#if !CLR2
+        public void ClrBigIntegerV4() {
+            Context.ObjectClass.SetConstant("BI", new BigInt(100000000000));
+            TestOutput(@"
+p BI + BI
+p BI + 1000000000000
+p 1000000000000 / BI
+", @"
+200000000000
+1100000000000
+10
+");
+        }
+#endif
+
         #endregion
     }
 }
===================================================================
edit: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/IronRuby.Tests/Runtime/ModuleTests.cs;C1158858
File: ModuleTests.cs
===================================================================
--- $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/IronRuby.Tests/Runtime/ModuleTests.cs;C1158858  (server)    3/2/2010 9:35 AM
+++ Shelved Change: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/IronRuby.Tests/Runtime/ModuleTests.cs;morefixes
@@ -153,6 +153,20 @@
             }, output);
         }
 
+        public void ClassDuplication7() {
+            TestOutput(@"
+class C
+  def foo
+  end
+end
+
+D = C.dup
+p D.instance_method(:foo)
+", @"
+#<UnboundMethod: D#foo>
+");
+        }
+
         public void Structs1() {
             AssertOutput(() => CompilerTest(@"
 S = Struct.new(:f,:g)
===================================================================
edit: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/IronRuby.Tests/Runtime/RubyUtilsTests.cs;C1546541
File: RubyUtilsTests.cs
===================================================================
--- $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/IronRuby.Tests/Runtime/RubyUtilsTests.cs;C1546541  (server)    3/1/2010 7:00 PM
+++ Shelved Change: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/IronRuby.Tests/Runtime/RubyUtilsTests.cs;morefixes
@@ -13,7 +13,11 @@
  *
  * ***************************************************************************/
 
+using System;
 using IronRuby.Runtime;
+using IronRuby.Builtins;
+using System.Collections.Generic;
+using System.Text;
 
 namespace IronRuby.Tests {
     public partial class Tests {
@@ -155,5 +159,27 @@
             Assert(RubyUtils.TryMangleMethodName("Class") == null);
             Assert(RubyUtils.TryMangleMethodName("Message") == "message"); // we don't special case Exception.Message
         }
+
+        [Options(NoRuntime = true)]
+        public void DelegateChainClone1() {
+            StringBuilder sb = new StringBuilder();
+            Action<RubyModule> f = (_) => { sb.Append('1'); };
+            f += (_) => { sb.Append('2'); };
+            f += (_) => { sb.Append('3'); };
+
+            f(null);
+            Assert(sb.ToString() == "123");
+            sb.Length = 0;
+
+            Action<RubyModule> g = Utils.CloneInvocationChain(f);
+            g += (_) => { sb.Append('4'); };
+            
+            g(null);
+            Assert(sb.ToString() == "1234");
+            sb.Length = 0;
+
+            f(null);
+            Assert(sb.ToString() == "123");
+        }
     }
 }
===================================================================
edit: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/Ruby/Builtins/RubyModule.cs;C1590922
File: RubyModule.cs
===================================================================
--- $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/Ruby/Builtins/RubyModule.cs;C1590922  (server)    2/23/2010 4:47 PM
+++ Shelved Change: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/Ruby/Builtins/RubyModule.cs;morefixes
@@ -540,20 +540,16 @@
 
             Assert.NotNull(module);
 
-#if !SILVERLIGHT // missing Clone on Delegate
             if (module._namespaceTracker != null && _constants == null) {
-#endif
                 // initialize the module so that we can copy all constants from it:
                 module.InitializeConstantsNoLock();
 
                 // initialize all ancestors of self:
                 InitializeConstantsNoLock();
-#if !SILVERLIGHT
             } else {
-                _constantsInitializer = (module._constantsInitializer != null) ? (Action<RubyModule>)module._constantsInitializer.Clone() : null;
+                _constantsInitializer = Utils.CloneInvocationChain(module._constantsInitializer);
                 _constantsState = module._constantsState;
             }
-#endif
 
             _constants = (module._constants != null) ? new Dictionary<string, ConstantStorage>(module._constants) : null;
 
@@ -565,14 +561,16 @@
                 }
             }
 
-#if SILVERLIGHT
-             module.InitializeMethodsNoLock();
-             InitializeMethodsNoLock();
-#else
-            _methodsInitializer = (module._methodsInitializer != null) ? (Action<RubyModule>)module._methodsInitializer.Clone() : null;
+            _methodsInitializer = Utils.CloneInvocationChain(module._methodsInitializer);
             _methodsState = module._methodsState;
-#endif
-            _methods = (module._methods != null) ? new Dictionary<string, RubyMemberInfo>(module._methods) : null;
+            if (module._methods != null) {
+                _methods = new Dictionary<string, RubyMemberInfo>(module._methods.Count);
+                foreach (var method in module._methods) {
+                    _methods[method.Key] = method.Value.Copy(method.Value.Flags, this);
+                }
+            } else {
+                _methods = null;
+            }
 
             _classVariables = (module._classVariables != null) ? new Dictionary<string, object>(module._classVariables) : null;
             _mixins = ArrayUtils.Copy(module._mixins);
@@ -1283,6 +1281,8 @@
 
         // Module#module_function:
         public void SetModuleFunctionNoEventNoLock(RubyContext/*!*/ callerContext, string/*!*/ name, RubyMemberInfo/*!*/ method) {
+            Debug.Assert(!IsClass);
+
             // CLR members: Detaches the member from its underlying type (by creating a copy).
             // TODO: check for CLR instance members, it should be an error to call module_function on them:
             var singletonClass = GetOrCreateSingletonClass();
@@ -1981,7 +1981,7 @@
             Assert.NotNull(trait);
 
             if (tableState == MemberTableState.Uninitialized) {
-                if (initializer != null) {
+                if (initializer != null && initializer != EmptyInitializer) {
                     initializer += trait;
                 } else {
                     initializer = trait;
===================================================================
edit: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/Ruby/Runtime/Utils.cs;C1613222
File: Utils.cs
===================================================================
--- $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/Ruby/Runtime/Utils.cs;C1613222  (server)    2/24/2010 2:31 PM
+++ Shelved Change: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/Ruby/Runtime/Utils.cs;morefixes
@@ -20,15 +20,15 @@
 #endif
 
 using System;
-using Microsoft.Scripting.Utils;
+using System.Globalization;
 using System.Diagnostics;
 using System.Text;
 using System.Reflection;
 using System.Collections;
 using System.Collections.Generic;
-using IronRuby.Builtins;
-using System.Globalization;
 using System.Dynamic;
+using Microsoft.Scripting.Utils;
+using IronRuby.Builtins;
 
 namespace IronRuby.Runtime {
     public static class Utils {
@@ -524,7 +524,29 @@
             foreach (var metaObject in metaObjects) {
                 yield return metaObject != null ? metaObject.Expression : null;
             }
+        }
+
+        internal static Action<RubyModule> CloneInvocationChain(Action<RubyModule> chain) {
+            if (chain == null) {
+                return null;
+            }
+
+            Delegate[] delegates = chain.GetInvocationList();
+            Action<RubyModule> result;
+#if SILVERLIGHT
+            int i = 0;
+            result = (_) => {};
+#else
+            int i = 1;
+            result = (Action<RubyModule>)delegates[0].Clone();
+#endif
+            for (; i < delegates.Length; i++) {
+                result += (Action<RubyModule>)delegates[i];
+            }
+
+            return result;
         }
+
     }
 }
 
===================================================================
edit: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/RubyMemberInfo.cs;C1594104
File: RubyMemberInfo.cs
===================================================================
--- $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/RubyMemberInfo.cs;C1594104  (server)    2/23/2010 4:54 PM
+++ Shelved Change: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/RubyMemberInfo.cs;morefixes
@@ -37,7 +37,18 @@
 
         private readonly RubyMemberFlags _flags;
 
-        // Null for dummy methods.
+        //
+        // A method body can be shared by multiple method definitions, one of them is the primary definition and the others are its copies.
+        // Only three cases of sharing are allowed:
+        // 1) The primary definition's declaring module is a super-class of the copied definition.
+        // 2) The primary definition's declaring module was duplicated and method copies are defined in the duplicate.
+        // 3) The primary definition's declaring module is not a class.
+        // 
+        // We assume these restrictions in the super-call implementation and instance variable storage allocation.
+        // See also: instance_method, method, define_method, module_function, private, protected, public.
+        //
+        // DeclaringModule is null for dummy methods.
+        //
         private readonly RubyModule _declaringModule;
         
         #region Mutable state guarded by ClassHierarchyLock
===================================================================
