<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Compiler/Generation/IRubyType.cs</filename>
    </added>
    <added>
      <filename>Merlin/Main/Runtime/Microsoft.Scripting/Utils/ExpressionUtils.cs</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -66,6 +66,7 @@
     &lt;TreatWarningsAsErrors&gt;true&lt;/TreatWarningsAsErrors&gt;
     &lt;UseVSHostingProcess&gt;true&lt;/UseVSHostingProcess&gt;
     &lt;TargetFrameworkVersion&gt;v4.0&lt;/TargetFrameworkVersion&gt;
+    &lt;UseVSHostingProcess&gt;false&lt;/UseVSHostingProcess&gt;
   &lt;/PropertyGroup&gt;
   &lt;PropertyGroup Condition=&quot; '$(Configuration)|$(Platform)' == 'V4 Release|AnyCPU' &quot;&gt;
     &lt;DebugType&gt;pdbonly&lt;/DebugType&gt;
@@ -77,6 +78,7 @@
     &lt;TreatWarningsAsErrors&gt;true&lt;/TreatWarningsAsErrors&gt;
     &lt;DelaySigned&gt;true&lt;/DelaySigned&gt;
     &lt;TargetFrameworkVersion&gt;v4.0&lt;/TargetFrameworkVersion&gt;
+    &lt;UseVSHostingProcess&gt;false&lt;/UseVSHostingProcess&gt;
   &lt;/PropertyGroup&gt;
   &lt;ItemGroup&gt;
     &lt;Compile Include=&quot;AssemblyInfo.cs&quot; /&gt;</diff>
      <filename>Merlin/Main/Languages/IronPython/IronPythonConsole/IronPythonConsole.csproj</filename>
    </modified>
    <modified>
      <diff>@@ -65,6 +65,7 @@
     &lt;TreatWarningsAsErrors&gt;true&lt;/TreatWarningsAsErrors&gt;
     &lt;UseVSHostingProcess&gt;true&lt;/UseVSHostingProcess&gt;
     &lt;TargetFrameworkVersion&gt;v4.0&lt;/TargetFrameworkVersion&gt;
+    &lt;UseVSHostingProcess&gt;false&lt;/UseVSHostingProcess&gt;
   &lt;/PropertyGroup&gt;
   &lt;PropertyGroup Condition=&quot; '$(Configuration)|$(Platform)' == 'V4 Release|AnyCPU' &quot;&gt;
     &lt;DebugType&gt;pdbonly&lt;/DebugType&gt;
@@ -76,6 +77,7 @@
     &lt;TreatWarningsAsErrors&gt;true&lt;/TreatWarningsAsErrors&gt;
     &lt;DelaySigned&gt;true&lt;/DelaySigned&gt;
     &lt;TargetFrameworkVersion&gt;v4.0&lt;/TargetFrameworkVersion&gt;
+    &lt;UseVSHostingProcess&gt;false&lt;/UseVSHostingProcess&gt;
   &lt;/PropertyGroup&gt;
   &lt;ItemGroup&gt;
     &lt;Compile Include=&quot;..\IronPythonConsole\AssemblyInfo.cs&quot; /&gt;</diff>
      <filename>Merlin/Main/Languages/IronPython/IronPythonConsoleAny/IronPythonConsoleAny.csproj</filename>
    </modified>
    <modified>
      <diff>@@ -74,6 +74,7 @@
     &lt;DefineConstants&gt;TRACE;DEBUG;IRONPYTHON_WINDOW;CLR4;$(SignedSym)&lt;/DefineConstants&gt;
     &lt;ErrorReport&gt;prompt&lt;/ErrorReport&gt;
     &lt;TargetFrameworkVersion&gt;v4.0&lt;/TargetFrameworkVersion&gt;
+    &lt;UseVSHostingProcess&gt;false&lt;/UseVSHostingProcess&gt;
   &lt;/PropertyGroup&gt;
   &lt;PropertyGroup Condition=&quot; '$(Configuration)|$(Platform)' == 'V4 Release|AnyCPU' &quot;&gt;
     &lt;DebugType&gt;pdbonly&lt;/DebugType&gt;
@@ -82,6 +83,7 @@
     &lt;DefineConstants&gt;TRACE;IRONPYTHON_WINDOW;CLR4;$(SignedSym)&lt;/DefineConstants&gt;
     &lt;ErrorReport&gt;prompt&lt;/ErrorReport&gt;
     &lt;TargetFrameworkVersion&gt;v4.0&lt;/TargetFrameworkVersion&gt;
+    &lt;UseVSHostingProcess&gt;false&lt;/UseVSHostingProcess&gt;
   &lt;/PropertyGroup&gt;
   &lt;ItemGroup&gt;
     &lt;Reference Include=&quot;System&quot; /&gt;</diff>
      <filename>Merlin/Main/Languages/IronPython/IronPythonWindow/IronPythonWindow.csproj</filename>
    </modified>
    <modified>
      <diff>@@ -72,6 +72,7 @@
     &lt;DefineConstants&gt;TRACE;DEBUG;IRONPYTHON_WINDOW;CLR4;$(SignedSym)&lt;/DefineConstants&gt;
     &lt;ErrorReport&gt;prompt&lt;/ErrorReport&gt;
     &lt;TargetFrameworkVersion&gt;v4.0&lt;/TargetFrameworkVersion&gt;
+    &lt;UseVSHostingProcess&gt;false&lt;/UseVSHostingProcess&gt;
   &lt;/PropertyGroup&gt;
   &lt;PropertyGroup Condition=&quot; '$(Configuration)|$(Platform)' == 'V4 Release|AnyCPU' &quot;&gt;
     &lt;DebugType&gt;pdbonly&lt;/DebugType&gt;
@@ -80,6 +81,7 @@
     &lt;DefineConstants&gt;TRACE;IRONPYTHON_WINDOW;CLR4;$(SignedSym)&lt;/DefineConstants&gt;
     &lt;ErrorReport&gt;prompt&lt;/ErrorReport&gt;
     &lt;TargetFrameworkVersion&gt;v4.0&lt;/TargetFrameworkVersion&gt;
+    &lt;UseVSHostingProcess&gt;false&lt;/UseVSHostingProcess&gt;
   &lt;/PropertyGroup&gt;
   &lt;ItemGroup&gt;
     &lt;Compile Include=&quot;..\IronPythonWindow\IronPythonWindow.cs&quot; /&gt;</diff>
      <filename>Merlin/Main/Languages/IronPython/IronPythonWindowAny/IronPythonWindowAny.csproj</filename>
    </modified>
    <modified>
      <diff>@@ -52,6 +52,7 @@
     &lt;WarningLevel&gt;4&lt;/WarningLevel&gt;
     &lt;TreatWarningsAsErrors&gt;true&lt;/TreatWarningsAsErrors&gt;
     &lt;TargetFrameworkVersion&gt;v4.0&lt;/TargetFrameworkVersion&gt;
+    &lt;UseVSHostingProcess&gt;false&lt;/UseVSHostingProcess&gt;
   &lt;/PropertyGroup&gt;
   &lt;PropertyGroup Condition=&quot; '$(Configuration)|$(Platform)' == 'V4 Release|AnyCPU' &quot;&gt;
     &lt;DebugType&gt;pdbonly&lt;/DebugType&gt;
@@ -61,6 +62,7 @@
     &lt;ErrorReport&gt;prompt&lt;/ErrorReport&gt;
     &lt;WarningLevel&gt;4&lt;/WarningLevel&gt;
     &lt;TargetFrameworkVersion&gt;v4.0&lt;/TargetFrameworkVersion&gt;
+    &lt;UseVSHostingProcess&gt;false&lt;/UseVSHostingProcess&gt;
   &lt;/PropertyGroup&gt;
   &lt;ItemGroup&gt;
     &lt;Compile Include=&quot;Program.cs&quot; /&gt;</diff>
      <filename>Merlin/Main/Languages/Ruby/Console/Ruby.Console.csproj</filename>
    </modified>
    <modified>
      <diff>@@ -50,6 +50,7 @@
     &lt;WarningLevel&gt;4&lt;/WarningLevel&gt;
     &lt;TreatWarningsAsErrors&gt;true&lt;/TreatWarningsAsErrors&gt;
     &lt;TargetFrameworkVersion&gt;v4.0&lt;/TargetFrameworkVersion&gt;
+    &lt;UseVSHostingProcess&gt;false&lt;/UseVSHostingProcess&gt;
   &lt;/PropertyGroup&gt;
   &lt;PropertyGroup Condition=&quot; '$(Configuration)|$(Platform)' == 'V4 Release|AnyCPU' &quot;&gt;
     &lt;DebugType&gt;pdbonly&lt;/DebugType&gt;
@@ -59,6 +60,7 @@
     &lt;ErrorReport&gt;prompt&lt;/ErrorReport&gt;
     &lt;WarningLevel&gt;4&lt;/WarningLevel&gt;
     &lt;TargetFrameworkVersion&gt;v4.0&lt;/TargetFrameworkVersion&gt;
+    &lt;UseVSHostingProcess&gt;false&lt;/UseVSHostingProcess&gt;
   &lt;/PropertyGroup&gt;
   &lt;ItemGroup&gt;
     &lt;Compile Include=&quot;Program.cs&quot; /&gt;</diff>
      <filename>Merlin/Main/Languages/Ruby/Console/Ruby.ConsoleAny.csproj</filename>
    </modified>
    <modified>
      <diff>@@ -47,6 +47,7 @@
     &lt;DefineConstants&gt;TRACE;CLR4;$(SignedSym)&lt;/DefineConstants&gt;
     &lt;ErrorReport&gt;prompt&lt;/ErrorReport&gt;
     &lt;TargetFrameworkVersion&gt;v4.0&lt;/TargetFrameworkVersion&gt;
+    &lt;UseVSHostingProcess&gt;false&lt;/UseVSHostingProcess&gt;
   &lt;/PropertyGroup&gt;
   &lt;PropertyGroup Condition=&quot; '$(Configuration)|$(Platform)' == 'V4 Debug|AnyCPU' &quot;&gt;
     &lt;DebugSymbols&gt;true&lt;/DebugSymbols&gt;
@@ -56,6 +57,7 @@
     &lt;DefineConstants&gt;TRACE;DEBUG;CLR4;$(SignedSym)&lt;/DefineConstants&gt;
     &lt;ErrorReport&gt;prompt&lt;/ErrorReport&gt;
     &lt;TargetFrameworkVersion&gt;v4.0&lt;/TargetFrameworkVersion&gt;
+    &lt;UseVSHostingProcess&gt;false&lt;/UseVSHostingProcess&gt;
   &lt;/PropertyGroup&gt;
   &lt;ItemGroup&gt;
     &lt;Compile Include=&quot;Driver.cs&quot; /&gt;</diff>
      <filename>Merlin/Main/Languages/Ruby/IronRuby.Tests/IronRuby.Tests.csproj</filename>
    </modified>
    <modified>
      <diff>@@ -406,6 +406,7 @@ namespace IronRuby.Tests {
                 ClrNamespaces2,
                 ClrGenerics1,
                 ClrGenerics2,
+                ClrGenerics3,
                 ClrMethods1,
                 ClrMethods2,
                 ClrMethods3,
@@ -444,7 +445,9 @@ namespace IronRuby.Tests {
                 ClrOverride1,
                 ClrOverride2,
                 ClrOverride3,
-                //TODO: Fix ClrOverride4,
+                ClrOverride4,
+                ClrOverride5,
+                ClrOverride6,
                 ClrEventImpl1,
                 ClrDetachedVirtual1,
                 ClrConstructor1,</diff>
      <filename>Merlin/Main/Languages/Ruby/IronRuby.Tests/RubyTests.cs</filename>
    </modified>
    <modified>
      <diff>@@ -45,6 +45,19 @@ namespace InteropTests.Generics1 {
     public class D&lt;T&gt; : C&lt;T&gt; {
         public override int Arity { get { return 11; } }
     }
+
+    public interface J&lt;T&gt; {
+        void MethodOnJ();
+    }
+
+    public interface I&lt;T&gt; : J&lt;T&gt; {
+        void MethodOnI();
+    }
+
+    public class E&lt;T&gt; : I&lt;T&gt;, J&lt;T&gt; {
+        void I&lt;T&gt;.MethodOnI() { }
+        void J&lt;T&gt;.MethodOnJ() { }
+    }
 }
 
 namespace InteropTests.Namespaces2 {
@@ -1388,7 +1401,7 @@ InteropTests::Generics1::C[Fixnum]
 #&lt;ArgumentError: `InteropTests::Generics1::C[Fixnum]' is not a generic type definition&gt;
 &quot;);
             
-            // C&lt;T&gt; instantiations are subclasses of C&lt;&gt;:
+            // C&lt;&gt; is a mixin for all its instantiations:
             TestOutput(@&quot;
 include InteropTests::Generics1
 C[1].class_eval do
@@ -1405,6 +1418,65 @@ InteropTests::Generics1::C[Fixnum]
 InteropTests::Generics1::C[String]
 [InteropTests::Generics1::C[Float], InteropTests::Generics1::C[T], Object]
 &quot;);
+
+            // It is possible to include a generic type definition into another class. It behaves like a Ruby module.
+            // Besides inclusion of a generic interface instantiation transitively includes its generic type definition.
+            TestOutput(@&quot;
+include InteropTests::Generics1
+
+class ClassA 
+  include C[1]
+  include I[1]
+  p ancestors
+  new
+end
+
+class ClassB
+  include C[Fixnum] rescue p $!
+  include I[Fixnum]
+  p ancestors
+  new
+end
+&quot;, @&quot;
+[ClassA, InteropTests::Generics1::I[T], InteropTests::Generics1::C[T], Object, InteropTests::Generics1, Kernel]
+#&lt;TypeError: wrong argument type Class (expected Module)&gt;
+[ClassB, InteropTests::Generics1::I[Fixnum], InteropTests::Generics1::I[T], Object, InteropTests::Generics1, Kernel]
+&quot;);
+
+            // generic type definitions cannot be instantiated and don't expose their methods:
+            TestOutput(@&quot;
+include InteropTests::Generics1
+p C[Fixnum].new.method(:Arity)
+C[1].new rescue p $!
+C[1].instance_method(:Arity) rescue p $!
+&quot;, @&quot;
+#&lt;Method: InteropTests::Generics1::C[Fixnum]#Arity&gt;
+#&lt;NoMethodError: undefined method `new' for InteropTests::Generics1::C[T]:Module&gt;
+#&lt;NameError: undefined method `Arity' for module `InteropTests::Generics1::C[T]'&gt;
+&quot;);
+        }
+
+        public class GenericClass1&lt;T&gt; {
+            public int Foo(T item) {
+                return 1;
+            }
+        }
+
+        public class GenericSubclass1&lt;T&gt; : GenericClass1&lt;T&gt; {
+        }
+
+        public void ClrGenerics2() {
+            Context.ObjectClass.SetConstant(&quot;T&quot;, Context.GetClass(GetType()));
+
+            // CLR methods with generic arguments defined on a generic type don't get duplicated:
+            // (C&lt;T&gt; inherits from C&lt;&gt; but the generic type definition should be ignored when looking for CLR method overloads):
+            TestOutput(@&quot;
+p T::GenericClass1[Fixnum].new.foo(1)
+p T::GenericSubclass1[Fixnum].new.foo(1)
+&quot;, @&quot;
+1
+1
+&quot;);
         }
 
         public class ClassWithNestedGenericTypes1 {
@@ -1430,7 +1502,7 @@ InteropTests::Generics1::C[String]
             }
         }
 
-        public void ClrGenerics2() {
+        public void ClrGenerics3() {
             Context.ObjectClass.SetConstant(&quot;C1&quot;, Context.GetClass(typeof(ClassWithNestedGenericTypes1)));
             Context.ObjectClass.SetConstant(&quot;C2&quot;, Context.GetClass(typeof(ClassWithNestedGenericTypes2)));
 
@@ -1765,6 +1837,126 @@ p E.new.virtual_method
 &quot;);
         }
 
+        public class ClassWithProperties {
+            private int _prop;
+            private int[] _values = new int[1];
+
+            public virtual int Prop {
+                get { return _prop; }
+                set { _prop = value; }
+            }
+
+            public virtual int this[int i] {
+                get { return _values[i]; }
+                set { _values[i] = value; }
+            }
+            
+            public int[] Report() {
+                Prop = 10;
+                this[0] = 20;
+                return new int[] { Prop, _prop, this[0], _values[0] };
+            }
+        }
+
+        public void ClrOverride5() {
+            Context.ObjectClass.SetConstant(&quot;C&quot;, Context.GetClass(typeof(ClassWithProperties)));
+            TestOutput(@&quot;
+class D &lt; C
+end
+
+p D.new.report
+
+class D &lt; C
+  def prop
+    4
+  end
+
+  def prop= value
+    super(5)
+  end
+
+  def [] index
+    6
+  end
+
+  def []= index, value
+    super(index, 7)
+  end
+end
+
+p D.new.report
+&quot;, @&quot;
+[10, 10, 20, 20]
+[4, 5, 6, 7]
+&quot;);
+        }
+
+        public class ClassWithVirtuals1 {
+            public virtual int Foo() { return 1; }
+            public virtual int Goo() { return 20; }
+            protected int Prot() { return 1000; }
+
+            public virtual int Bar() { return 1; }
+        }
+
+        public class ClassWithVirtuals2 : ClassWithVirtuals1 {
+            public int Report() {
+                return Foo() + Goo();
+            }
+
+            public sealed override int Goo() { return 30; }
+
+            public override int Bar() { return 2; }
+        }
+
+        public class ClassWithVirtuals3 : ClassWithVirtuals2 {
+            public override int Bar() { return 3; }
+        }
+
+        public interface I1 { int f(); }
+        public interface I2 { int g(); }
+
+        public void ClrOverride6() {
+            Context.ObjectClass.SetConstant(&quot;C&quot;, Context.GetClass(typeof(ClassWithVirtuals2)));
+            Context.ObjectClass.SetConstant(&quot;I1&quot;, Context.GetModule(typeof(I1)));
+            Context.ObjectClass.SetConstant(&quot;I2&quot;, Context.GetModule(typeof(I2)));
+            TestOutput(@&quot;
+class D &lt; C
+  include I1
+end
+
+class E &lt; D 
+  include I2
+  
+  def foo
+    super + 100
+  end
+
+  def goo
+    super + prot
+  end
+end
+
+p E.new.report
+p E.new.goo
+&quot;, @&quot;
+131
+1030
+&quot;);
+
+            AssertOutput(() =&gt; CompilerTest(@&quot;
+class C
+  def bar
+    super + 100
+  end
+end
+
+C.new.bar rescue p $!
+&quot;), @&quot;
+#&lt;NoMethodError: Virtual CLR method `bar' called via super from *; Super calls to virtual CLR methods can only be used in a Ruby subclass of the class declaring the method&gt;
+&quot;, OutputFlags.Match);
+        }
+
         /// &lt;summary&gt;
         /// See RubyMethodGroupBase.BuildCallNoFlow.
         /// &lt;/summary&gt;</diff>
      <filename>Merlin/Main/Languages/Ruby/IronRuby.Tests/Runtime/ClrTests.cs</filename>
    </modified>
    <modified>
      <diff>@@ -15,12 +15,15 @@
 
 #if !CLR2
 using System.Linq.Expressions;
+using CsBinder = Microsoft.CSharp.RuntimeBinder.Binder;
+using CSharpBinderFlags = Microsoft.CSharp.RuntimeBinder.CSharpBinderFlags;
 #else
 using Microsoft.Scripting.Ast;
 using dynamic = System.Object;
 #endif
 
 using System;
+using System.Diagnostics;
 using System.Dynamic;
 using System.Runtime.CompilerServices;
 using IronRuby.Builtins;
@@ -30,6 +33,7 @@ using Microsoft.Scripting.Runtime;
 using Microsoft.Scripting.Utils;
 using System.Collections;
 using IronRuby.Runtime;
+using System.Collections.Generic;
 
 namespace IronRuby.Tests {
     #region Custom binders
@@ -496,9 +500,8 @@ class SanityTest
     def self.sanity_test main
         # $ruby_array_list
         assert_equal main.ruby_array_list.Count, 2
-        assert_error lambda { main.ruby_array_list[0] }, NameError # Bug !!!!!!!!!!!! Should equal 100
-
-        assert_error lambda { main.ruby_array_list.Count = 1 }, NoMethodError
+        main.ruby_array_list[0]
+    
         assert_equal main.ruby_array_list.ruby_method, 'Hi from Ruby'.to_clr_string
         assert_equal main.ruby_array_list.IndexOf(nil), 123456789
         
@@ -601,6 +604,13 @@ end
             // Ruby attributes are invoked directly via SetMember/GetMember:
             AreEqual(MySetMemberBinder.Invoke(ruby_array_list, &quot;ruby_attribute&quot;, 123), 123);
             AreEqual(MyGetMemberBinder.Invoke(ruby_array_list, &quot;ruby_attribute&quot;), 123);
+#if !CLR2
+            List&lt;object&gt; result = new List&lt;object&gt;();
+            foreach (object item in (dynamic)ruby_array_list) {
+                result.Add(item);
+            }
+            Assert(result.Count == 2 &amp;&amp; (int)result[0] == 100 &amp;&amp; (int)result[1] == 200);
+#endif
         }
 
         public void Dlr_MethodMissing() {</diff>
      <filename>Merlin/Main/Languages/Ruby/IronRuby.Tests/Runtime/DlrInteropTests.cs</filename>
    </modified>
    <modified>
      <diff>@@ -263,6 +263,17 @@ IronRuby.globals.x = 2
 IronRuby.globals.z = IronRuby.globals.x + FooBar
 &quot;);
             Assert(Runtime.Globals.GetVariable&lt;int&gt;(&quot;z&quot;) == 3);
+
+#if !CLR2
+            dynamic scope = Engine.CreateScope();
+            Engine.Execute(@&quot;def foo; 1; end&quot;, scope);
+
+            RubyMethod method = (RubyMethod)scope.foo;
+            Assert(method.Name == &quot;foo&quot;);
+
+            object value = scope.foo();
+            Assert((int)value == 1);
+#endif
         }
 
         public void RubyHosting_Scopes1() {</diff>
      <filename>Merlin/Main/Languages/Ruby/IronRuby.Tests/Runtime/HostingTests.cs</filename>
    </modified>
    <modified>
      <diff>@@ -128,14 +128,7 @@ error
                 File.WriteAllText(Path.Combine(temp, &quot;a.py&quot;), @&quot;
 print 'Hello from Python'
 &quot;);
-                AssertOutput(delegate() {
-                    CompilerTest(@&quot;
-require('a')
-&quot;);
-                }, @&quot;
-Hello from Python
-&quot;);
-
+                AssertExceptionThrown&lt;LoadError&gt;(() =&gt; CompilerTest(@&quot;require('a')&quot;));
             } finally {
                 File.Delete(&quot;b.py&quot;);
             }
@@ -162,9 +155,9 @@ class Bar(object):
                 TestOutput(@&quot;
 a = IronRuby.require('a')
 scopes = IronRuby.loaded_scripts.collect { |z| z.value }
-a.who_is_this.call
+a.who_is_this
 a.foo += 1
-a.bar.new.baz
+a.bar.baz             # a Python class is callable so we get Bar's instance from a.bar
 puts scopes[0].Foo
 &quot;, @&quot;
 Python</diff>
      <filename>Merlin/Main/Languages/Ruby/IronRuby.Tests/Runtime/LoaderTests.cs</filename>
    </modified>
    <modified>
      <diff>@@ -892,7 +892,7 @@ namespace IronRuby.Builtins {
 
             using (self.Context.ClassHierarchyLocker()) {
                 self.ForEachMember(inherited, attributes, foreignMembers, (name, module, member) =&gt; {
-                    if (member.IsInteropMember &amp;&amp; (module.Restrictions &amp; ModuleRestrictions.NoNameMangling) == 0 &amp;&amp; RubyUtils.HasMangledName(name)) {
+                    if (member.IsInteropMember &amp;&amp; (module.Restrictions &amp; ModuleRestrictions.NoNameMapping) == 0 &amp;&amp; RubyUtils.HasMangledName(name)) {
                         result.Add(new ClrName(name));
                     } else {
                         result.Add(CreateMethodName(name, symbolicNames));</diff>
      <filename>Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/ModuleOps.cs</filename>
    </modified>
    <modified>
      <diff>@@ -47,6 +47,11 @@ namespace IronRuby.Builtins {
             return MutableString.Create(value);
         }
 
+        [RubyConstructor]
+        public static MutableString/*!*/ Create(RubyClass/*!*/ self, [NotNull]byte[]/*!*/ value) {
+            return MutableString.CreateBinary(value);
+        }
+
         #region Helpers
 
         internal static bool InExclusiveRangeNormalized(int length, ref int index) {
@@ -343,6 +348,12 @@ namespace IronRuby.Builtins {
 
         #region initialize, initialize_copy
 
+        // Reinitialization. Not called when a factory/non-default ctor is called.
+        [RubyMethod(&quot;initialize&quot;, RubyMethodAttributes.PrivateInstance)]
+        public static MutableString/*!*/ Reinitialize(MutableString/*!*/ self) {
+            return self;
+        }
+
         // &quot;initialize&quot; not called when a factory/non-default ctor is called.
         // &quot;initialize_copy&quot; called from &quot;dup&quot; and &quot;clone&quot;
         [RubyMethod(&quot;initialize&quot;, RubyMethodAttributes.PrivateInstance)]
@@ -350,10 +361,11 @@ namespace IronRuby.Builtins {
         public static MutableString/*!*/ Reinitialize(MutableString/*!*/ self, [DefaultProtocol, NotNull]MutableString other) {
             return Replace(self, other);
         }
-        
-        // Reinitialization. Not called when a factory/non-default ctor is called.
+
         [RubyMethod(&quot;initialize&quot;, RubyMethodAttributes.PrivateInstance)]
-        public static MutableString/*!*/ Reinitialize(MutableString/*!*/ self) {
+        public static MutableString/*!*/ Reinitialize(MutableString/*!*/ self, [NotNull]byte[] other) {
+            self.Clear();
+            self.Append(other);
             return self;
         }
 </diff>
      <filename>Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/MutableStringOps.cs</filename>
    </modified>
    <modified>
      <diff>@@ -17,7 +17,7 @@ using IronRuby.Runtime;
 
 namespace IronRuby.Builtins {
 
-    [RubyClass(&quot;Object&quot;, Extends = typeof(object), Restrictions = ModuleRestrictions.NoNameMangling | ModuleRestrictions.NotPublished)]
+    [RubyClass(&quot;Object&quot;, Extends = typeof(object), Restrictions = ModuleRestrictions.NoNameMapping | ModuleRestrictions.NotPublished)]
     [Includes(typeof(Kernel))]
     public static class ObjectOps {
         [RubyMethod(&quot;initialize&quot;, RubyMethodAttributes.PrivateInstance | RubyMethodAttributes.Empty)]</diff>
      <filename>Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/ObjectOps.cs</filename>
    </modified>
    <modified>
      <diff>@@ -59,7 +59,7 @@ namespace IronRuby.Builtins {
             object loaded;
             
             scope.RubyContext.Loader.LoadFile(
-                null, self, libraryName, LoadFlags.LoadOnce | LoadFlags.AppendExtensions | LoadFlags.ResolveLoaded, out loaded
+                null, self, libraryName, LoadFlags.LoadOnce | LoadFlags.AppendExtensions | LoadFlags.ResolveLoaded | LoadFlags.AnyLanguage, out loaded
             );
 
             Debug.Assert(loaded != null);
@@ -72,7 +72,7 @@ namespace IronRuby.Builtins {
         [RubyMethod(&quot;load&quot;, RubyMethodAttributes.PublicSingleton)]
         public static object/*!*/ Load(RubyScope/*!*/ scope, RubyModule/*!*/ self, MutableString/*!*/ libraryName) {
             object loaded;
-            scope.RubyContext.Loader.LoadFile(null, self, libraryName, LoadFlags.ResolveLoaded, out loaded);
+            scope.RubyContext.Loader.LoadFile(null, self, libraryName, LoadFlags.ResolveLoaded | LoadFlags.AnyLanguage, out loaded);
             Debug.Assert(loaded != null);
             return loaded;
         }</diff>
      <filename>Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Extensions/IronRubyOps.cs</filename>
    </modified>
    <modified>
      <diff>@@ -155,7 +155,8 @@ namespace IronRuby.Builtins {
             );
             DefineGlobalClass(&quot;String&quot;, typeof(IronRuby.Builtins.MutableString), 0x00000007, Context.ObjectClass, LoadString_Instance, null, null, new IronRuby.Builtins.RubyModule[] {def36, def45}, 
                 new Func&lt;IronRuby.Builtins.RubyClass, IronRuby.Builtins.MutableString&gt;(IronRuby.Builtins.MutableStringOps.Create), 
-                new Func&lt;IronRuby.Builtins.RubyClass, IronRuby.Builtins.MutableString, IronRuby.Builtins.MutableString&gt;(IronRuby.Builtins.MutableStringOps.Create)
+                new Func&lt;IronRuby.Builtins.RubyClass, IronRuby.Builtins.MutableString, IronRuby.Builtins.MutableString&gt;(IronRuby.Builtins.MutableStringOps.Create), 
+                new Func&lt;IronRuby.Builtins.RubyClass, System.Byte[], IronRuby.Builtins.MutableString&gt;(IronRuby.Builtins.MutableStringOps.Create)
             );
             DefineGlobalClass(&quot;Struct&quot;, typeof(IronRuby.Builtins.RubyStruct), 0x00000007, Context.ObjectClass, LoadStruct_Instance, LoadStruct_Class, LoadStruct_Constants, new IronRuby.Builtins.RubyModule[] {def36}, 
                 new Action&lt;IronRuby.Builtins.RubyClass, System.Object[]&gt;(IronRuby.Builtins.RubyStructOps.AllocatorUndefined)
@@ -4797,8 +4798,9 @@ namespace IronRuby.Builtins {
             );
             
             DefineLibraryMethod(module, &quot;initialize&quot;, 0x52, 
+                new Func&lt;IronRuby.Builtins.MutableString, IronRuby.Builtins.MutableString&gt;(IronRuby.Builtins.MutableStringOps.Reinitialize), 
                 new Func&lt;IronRuby.Builtins.MutableString, IronRuby.Builtins.MutableString, IronRuby.Builtins.MutableString&gt;(IronRuby.Builtins.MutableStringOps.Reinitialize), 
-                new Func&lt;IronRuby.Builtins.MutableString, IronRuby.Builtins.MutableString&gt;(IronRuby.Builtins.MutableStringOps.Reinitialize)
+                new Func&lt;IronRuby.Builtins.MutableString, System.Byte[], IronRuby.Builtins.MutableString&gt;(IronRuby.Builtins.MutableStringOps.Reinitialize)
             );
             
             DefineLibraryMethod(module, &quot;initialize_copy&quot;, 0x52, </diff>
      <filename>Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Initializers.Generated.cs</filename>
    </modified>
    <modified>
      <diff>@@ -201,7 +201,7 @@ namespace IronRuby.Builtins {
         #endregion
 
         protected RubyClass/*!*/ GetClass(Type/*!*/ type) {
-            Debug.Assert(type != null &amp;&amp; !type.IsInterface);
+            Debug.Assert(type != null &amp;&amp; !RubyModule.IsModuleType(type));
             // TODO: CLR class vs library class:
             return _context.GetOrCreateClass(type);
         }</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Builtins/LibraryInitializer.cs</filename>
    </modified>
    <modified>
      <diff>@@ -697,7 +697,7 @@ namespace IronRuby.Builtins {
             }
 
             Type type = cls.TypeTracker.Type;
-            Debug.Assert(!type.IsInterface);
+            Debug.Assert(!RubyModule.IsModuleType(type));
 
             // Note: We don't cache results as this API is not used so frequently (e.g. for regular method dispatch).
             
@@ -707,13 +707,13 @@ namespace IronRuby.Builtins {
 
             // TODO: should declaring module of the resulting method rather be the base class?
             method = null;
-            return cls.TryGetClrMember(asType ?? type, name, true, 0, out method);
+            return cls.TryGetClrMember(asType ?? type, name, true, true, 0, out method);
         }
 
         // thread safe: doesn't need any lock since it only accesses immutable state
         public bool TryGetClrConstructor(out RubyMemberInfo method) {
             ConstructorInfo[] ctors;
-            if (TypeTracker != null &amp;&amp; !TypeTracker.Type.IsInterface &amp;&amp; (ctors = GetConstructors(TypeTracker.Type)).Length &gt; 0) {
+            if (TypeTracker != null &amp;&amp; (ctors = GetConstructors(TypeTracker.Type)).Length &gt; 0) {
                 method = new RubyMethodGroupInfo(ctors, this, true);
                 return true;
             }
@@ -722,7 +722,7 @@ namespace IronRuby.Builtins {
             return false;
         }
 
-        protected override bool TryGetClrMember(Type/*!*/ type, string/*!*/ name, bool tryUnmangle, out RubyMemberInfo method) {
+        protected override bool TryGetClrMember(Type/*!*/ type, string/*!*/ name, bool mapNames, bool unmangleNames, out RubyMemberInfo method) {
             Context.RequiresClassHierarchyLock();
 
             if (IsFailureCached(type, name, _isSingletonClass)) {
@@ -730,7 +730,7 @@ namespace IronRuby.Builtins {
                 return false;
             }
 
-            if (TryGetClrMember(type, name, tryUnmangle, BindingFlags.DeclaredOnly, out method)) {
+            if (TryGetClrMember(type, name, mapNames, unmangleNames, BindingFlags.DeclaredOnly, out method)) {
                 return true;
             }
 
@@ -743,7 +743,7 @@ namespace IronRuby.Builtins {
         /// Returns a fresh instance of RubyMemberInfo each time it is called. The caller needs to cache it if appropriate.
         /// May add or use method groups to/from super-clases if BindingFlags.DeclaredOnly is used.
         /// &lt;/summary&gt;
-        private bool TryGetClrMember(Type/*!*/ type, string/*!*/ name, bool tryUnmangle, BindingFlags basicBindingFlags, out RubyMemberInfo method) {
+        private bool TryGetClrMember(Type/*!*/ type, string/*!*/ name, bool mapNames, bool unmangleNames, BindingFlags basicBindingFlags, out RubyMemberInfo method) {
             basicBindingFlags |= BindingFlags.Public | BindingFlags.NonPublic;
 
             // We look only for members directly declared on the type and handle method overloads inheritance manually.  
@@ -755,12 +755,12 @@ namespace IronRuby.Builtins {
             }
 
             string operatorName;
-            if (tryUnmangle &amp;&amp; !_isSingletonClass &amp;&amp; (operatorName = RubyUtils.MapOperator(name)) != null) {
+            if (mapNames &amp;&amp; !_isSingletonClass &amp;&amp; (operatorName = RubyUtils.MapOperator(name)) != null) {
                 // instance invocation of an operator:
                 if (TryGetClrMethod(type, basicBindingFlags | BindingFlags.Static, true, name, null, operatorName, null, out method)) {
                     return true;
                 }
-            } else if (tryUnmangle &amp;&amp; (name == &quot;[]&quot; || name == &quot;[]=&quot;)) {
+            } else if (mapNames &amp;&amp; (name == &quot;[]&quot; || name == &quot;[]=&quot;)) {
                 if (type.IsArray &amp;&amp; !_isSingletonClass) {
                     bool isSetter = name.Length == 3;
                     TryGetClrMethod(type, bindingFlags, false, name, null, isSetter ? &quot;Set&quot; : &quot;Get&quot;, null, out method);
@@ -778,7 +778,7 @@ namespace IronRuby.Builtins {
                 }
             } else if (name.LastCharacter() == '=') {
                 string propertyName = name.Substring(0, name.Length - 1);
-                string altName = tryUnmangle ? RubyUtils.TryUnmangleMethodName(propertyName) : null;
+                string altName = unmangleNames ? RubyUtils.TryUnmangleMethodName(propertyName) : null;
                 
                 // property setter:
                 if (TryGetClrProperty(type, bindingFlags, true, name, propertyName, altName, out method)) return true;
@@ -786,7 +786,7 @@ namespace IronRuby.Builtins {
                 // writeable field:
                 if (TryGetClrField(type, bindingFlags, true, propertyName, altName, out method)) return true;
             } else {
-                string altName = tryUnmangle ? RubyUtils.TryUnmangleMethodName(name) : null;
+                string altName = unmangleNames ? RubyUtils.TryUnmangleMethodName(name) : null;
 
                 // method:
                 if (TryGetClrMethod(type, bindingFlags, false, name, null, name, altName, out method)) return true;
@@ -929,7 +929,7 @@ namespace IronRuby.Builtins {
                     }
 
                     // Skip classes that have no tracker, e.g. Fixnum(tracker) &lt;: Integer(null) &lt;: Numeric(null) &lt;: Object(tracker).
-                    // Skip interfaces, their methods are not callable =&gt; do not include them into a method group.
+                    // Skip CLR modules, their methods are not callable =&gt; do not include them into a method group.
                     // Skip all classes once hidden sentinel is encountered (no CLR overloads are visible since then).
                     if (!skipHidden &amp;&amp; module.TypeTracker != null &amp;&amp; module.IsClass) {
                         ancestors.Add((RubyClass)module);</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Builtins/RubyClass.cs</filename>
    </modified>
    <modified>
      <diff>@@ -22,6 +22,7 @@ using Microsoft.Scripting.Ast;
 using System;
 using System.Diagnostics;
 using System.Runtime.CompilerServices;
+using System.Text;
 using IronRuby.Runtime;
 using IronRuby.Runtime.Calls;
 using Microsoft.Scripting.Utils;
@@ -32,6 +33,7 @@ namespace IronRuby.Builtins {
     using Ast = Expression;
     using BlockCallTargetUnsplatN = Func&lt;BlockParam, object, object[], RubyArray, object&gt;;
 
+    [DebuggerDisplay(&quot;{GetDebugView(), nq}&quot;)]
     public partial class RubyMethod {
         private readonly object _target;
         private readonly string/*!*/ _name;
@@ -115,6 +117,7 @@ namespace IronRuby.Builtins {
         #region Curried
 
         // TODO: currently used only to curry a method name for method_missing, but could be easily extended to support general argument currying
+        [DebuggerDisplay(&quot;{GetDebugView(), nq}&quot;)]
         public sealed class Curried : RubyMethod {
             private readonly string/*!*/ _methodNameArg;
 
@@ -131,6 +134,35 @@ namespace IronRuby.Builtins {
             public override Proc/*!*/ ToProc(RubyScope/*!*/ scope) {
                 throw new NotSupportedException();
             }
+
+            private new string/*!*/ GetDebugView() {
+                var result = new StringBuilder();
+                result.Append(&quot;missing &quot;);
+                result.Append(GetTargetClass().Name);
+                result.Append('#');
+                result.Append(_methodNameArg);
+
+                result.Append(&quot;(?)&quot;);
+                return result.ToString();
+            }
+        }
+
+        #endregion
+
+        #region Debug View
+
+        private string/*!*/ GetDebugView() {
+            var result = new StringBuilder();
+            result.Append(_info.Visibility.ToString().ToLowerInvariant());
+            result.Append(' ');
+
+            result.Append(GetTargetClass().Name);
+            result.Append('#');
+            result.Append(_name);
+
+            // TODO: parameter names?
+            result.Append(&quot;()&quot;);
+            return result.ToString();            
         }
 
         #endregion</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Builtins/RubyMethod.cs</filename>
    </modified>
    <modified>
      <diff>@@ -40,10 +40,10 @@ namespace IronRuby.Builtins {
         NoOverrides = 1,
 
         /// &lt;summary&gt;
-        /// Module doesn't allow its methods to be called by mangled names.
+        /// Module doesn't allow its methods to be called by mangled (FooBar -&gt; foo_bar) or mapped ([] -&gt; get_Item) names.
         /// Used for built-ins.
         /// &lt;/summary&gt;
-        NoNameMangling = 2,
+        NoNameMapping = 2,
 
         /// &lt;summary&gt;
         /// Module is not published in the runtime global scope.
@@ -53,7 +53,7 @@ namespace IronRuby.Builtins {
         /// &lt;summary&gt;
         /// Default restrictions for built-in modules.
         /// &lt;/summary&gt;
-        Builtin = NoOverrides | NoNameMangling | NotPublished,
+        Builtin = NoOverrides | NoNameMapping | NotPublished,
 
         All = Builtin
     }
@@ -63,7 +63,7 @@ namespace IronRuby.Builtins {
         None = 0,
 
         NoOverrides = ModuleRestrictions.NoOverrides,
-        NoNameMangling = ModuleRestrictions.NoNameMangling,
+        NoNameMangling = ModuleRestrictions.NoNameMapping,
         NotPublished = ModuleRestrictions.NotPublished,
         RestrictionsMask = ModuleRestrictions.All,
 
@@ -229,8 +229,12 @@ namespace IronRuby.Builtins {
             get { return _typeTracker != null &amp;&amp; _typeTracker.Type.IsInterface; }
         }
 
+        public bool IsClrModule {
+            get { return _typeTracker != null &amp;&amp; IsModuleType(_typeTracker.Type); }
+        }
+
         public virtual Type/*!*/ GetUnderlyingSystemType() {
-            if (IsInterface) {
+            if (IsClrModule) {
                 return _typeTracker.Type;
             } else {
                 throw new InvalidOperationException();
@@ -349,7 +353,7 @@ namespace IronRuby.Builtins {
                         Utils.Log(_name ?? &quot;&lt;anonymous&gt;&quot;, &quot;CT_INIT&quot;);
                         // TODO: use lock-free operations in initializers
                         _constantsInitializer(this);
-                    } else if (!IsInterface &amp;&amp; _typeTracker != null) {
+                    } else if (_typeTracker != null &amp;&amp; !_typeTracker.Type.IsInterface) {
                         // Load types eagerly. We do this only for CLR types that have no constant initializer (not builtins) and 
                         // a constant access is performed (otherwise this method wouldn't be called).
                         // 
@@ -1142,9 +1146,9 @@ namespace IronRuby.Builtins {
 
             ForEachAncestor(inherited, delegate(RubyModule/*!*/ module) {
 
-                // skip interfaces (methods declared on interfaces have already been looked for in the class);
-                // if 'this' is an interface, we want to visit all interface methods:
-                if (module.IsInterface &amp;&amp; !this.IsInterface) return false;
+                // Skip CLR modules (methods declared on CLR modules have already been looked for in the class).
+                // If 'this' is a CLR module, we want to visit all mixed-in methods.
+                if (module.IsClrModule &amp;&amp; !this.IsClrModule) return false;
 
                 // notification that we entered the module (it could have no method):
                 if (action(module, null, null)) return true;
@@ -1539,7 +1543,7 @@ namespace IronRuby.Builtins {
 
             if (virtualLookup) {
                 string mangled;
-                // TODO: set/get_FooBar??
+                // Note: property and default indexers getters and setters use FooBar, FooBar= and [], []= names, respectively, in virtual sites:
                 if ((mangled = RubyUtils.TryMangleMethodName(name)) != null &amp;&amp; TryGetDefinedMethod(mangled, ref skipHidden, out method)
                     &amp;&amp; method.IsRubyMember) {
                     return true;
@@ -1564,12 +1568,13 @@ namespace IronRuby.Builtins {
         private bool TryGetClrMember(string/*!*/ name, bool virtualLookup, out RubyMemberInfo method) {
             // Skip hidden CLR overloads.
             // Skip lookup on types that are not visible, that are interfaces or generic type definitions.
-            if (_typeTracker != null &amp;&amp; !_typeTracker.Type.IsInterface &amp;&amp; !_typeTracker.Type.IsGenericTypeDefinition) {
+            if (_typeTracker != null &amp;&amp; !IsModuleType(_typeTracker.Type)) {
                 // Note: Do not allow mangling for CLR virtual lookups - we want to match the overridden name exactly as is, 
                 // so that it corresponds to the base method call the override stub performs.
-                bool tryUnmangle = !virtualLookup &amp;&amp; (_restrictions &amp; ModuleRestrictions.NoNameMangling) == 0;
+                bool mapNames = (Restrictions &amp; ModuleRestrictions.NoNameMapping) == 0;
+                bool unmangleNames = !virtualLookup &amp;&amp; mapNames;
 
-                if (TryGetClrMember(_typeTracker.Type, name, tryUnmangle, out method)) {
+                if (TryGetClrMember(_typeTracker.Type, name, mapNames, unmangleNames, out method)) {
                     _methods.Add(name, method);
                     return true;
                 }
@@ -1579,7 +1584,7 @@ namespace IronRuby.Builtins {
             return false;
         }
 
-        protected virtual bool TryGetClrMember(Type/*!*/ type, string/*!*/ name, bool tryUnmangle, out RubyMemberInfo method) {
+        protected virtual bool TryGetClrMember(Type/*!*/ type, string/*!*/ name, bool mapNames, bool unmangleNames, out RubyMemberInfo method) {
             method = null;
             return false;
         }
@@ -1600,7 +1605,7 @@ namespace IronRuby.Builtins {
             }
 
             // CLR members (do not include interface members - they are not callable methods, just metadata):
-            if (_typeTracker != null &amp;&amp; !_typeTracker.Type.IsInterface) {
+            if (_typeTracker != null &amp;&amp; !IsModuleType(_typeTracker.Type)) {
                 foreach (string name in EnumerateClrMembers(_typeTracker.Type)) {
                     if (action(this, name, RubyMemberInfo.InteropMember)) {
                         return true;
@@ -1762,6 +1767,13 @@ namespace IronRuby.Builtins {
 
         #region Mixins (thread-safe)
 
+        /// &lt;summary&gt;
+        /// Returns true if the CLR type is treated as Ruby module (as opposed to a Ruby class)
+        /// &lt;/summary&gt;
+        public static bool IsModuleType(Type/*!*/ type) {
+            return type.IsInterface || type.IsGenericTypeDefinition;
+        }
+
         // thread-safe:
         public bool HasAncestor(RubyModule/*!*/ module) {
             using (Context.ClassHierarchyLocker()) {
@@ -1797,23 +1809,14 @@ namespace IronRuby.Builtins {
             RubyModule[] expanded = ExpandMixinsNoLock(GetSuperClass(), _mixins, modules);
 
             foreach (RubyModule module in expanded) {
-                if (module.IsInterface) {
-                    if (!CanIncludeClrInterface) {
-                        bool alreadyIncluded = false;
-                        foreach (RubyModule includedModule in _mixins) {
-                            if (includedModule == module) {
-                                alreadyIncluded = true;
-                                break;
-                            }
-                        }
-                        if (!alreadyIncluded) {
-                            throw new InvalidOperationException(String.Format(
-                                &quot;Interface {0} cannot be included in class {1} because its underlying type has already been created.&quot;,
-                                module.Name, Name
-                                ));
-                        }
+                if (module.IsInterface &amp;&amp; !CanIncludeClrInterface) {
+                    if (Array.IndexOf(_mixins, module) == -1) {
+                        throw new InvalidOperationException(String.Format(
+                            &quot;Interface `{0}' cannot be included in class `{1}' because its underlying type has already been created&quot;,
+                            module.Name, Name
+                        ));
                     }
-                }
+                } 
             }
 
             MixinsUpdated(_mixins, _mixins = expanded);</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Builtins/RubyModule.cs</filename>
    </modified>
    <modified>
      <diff>@@ -35,42 +35,7 @@ using IronRuby.Runtime.Calls;
 
 namespace IronRuby.Compiler.Generation {
 
-    public abstract partial class ClsTypeEmitter {
-        class SpecialNames {
-            private readonly Dictionary&lt;string/*!*/, List&lt;string/*!*/&gt;/*!*/&gt;/*!*/ _specialNames;
-
-            internal SpecialNames() {
-                _specialNames = new Dictionary&lt;string, List&lt;string&gt;&gt;();
-            }
-
-            internal void SetSpecialName(string/*!*/ specialName, List&lt;string/*!*/&gt;/*!*/ names) {
-                _specialNames[specialName] = names;
-            }
-
-            internal void SetSpecialName(string/*!*/ name) {
-                List&lt;string&gt; names = new List&lt;string&gt;(1);
-                names.Add(name);
-                _specialNames[name] = names;
-            }
-
-            internal IEnumerable&lt;string&gt; GetBaseName(MethodInfo/*!*/ mi) {
-                string newName;
-                if (mi.Name.StartsWith(BaseMethodPrefix)) {
-                    newName = mi.Name.Substring(BaseMethodPrefix.Length);
-                } else if (mi.Name.StartsWith(FieldGetterPrefix)) {
-                    newName = mi.Name.Substring(FieldGetterPrefix.Length);
-                } else if (mi.Name.StartsWith(FieldSetterPrefix)) {
-                    newName = mi.Name.Substring(FieldSetterPrefix.Length);
-                } else {
-                    throw new InvalidOperationException();
-                }
-
-                Debug.Assert(_specialNames.ContainsKey(newName));
-
-                return _specialNames[newName];
-            }
-        }
-
+    public abstract class ClsTypeEmitter {
         public const string VtableNamesField = &quot;#VTableNames#&quot;;
         public const string BaseMethodPrefix = &quot;#base#&quot;;
         public const string FieldGetterPrefix = &quot;#field_get#&quot;, FieldSetterPrefix = &quot;#field_set#&quot;;
@@ -79,20 +44,14 @@ namespace IronRuby.Compiler.Generation {
         private readonly TypeBuilder _tb;
         private readonly Type _baseType;
         private int _site;
-        private readonly SpecialNames _specialNames;
         private readonly List&lt;Expression&gt; _dynamicSiteFactories;
 
         protected ClsTypeEmitter(TypeBuilder tb) {
             _tb = tb;
             _baseType = tb.BaseType;
-            _specialNames = new SpecialNames();
             _dynamicSiteFactories = new List&lt;Expression&gt;();
         }
 
-        private static bool ShouldOverrideVirtual(MethodInfo/*!*/ mi) {
-            return true;
-        }
-
         private static bool CanOverrideMethod(MethodInfo/*!*/ mi) {
 #if !SILVERLIGHT
             return true;
@@ -111,9 +70,6 @@ namespace IronRuby.Compiler.Generation {
         protected abstract MethodInfo GetGenericConversionSiteFactory(Type toType);
         protected abstract void EmitClassObjectFromInstance(ILGen il);
         
-        protected abstract bool TryGetName(Type clrType, MethodInfo mi, out string name);
-        protected abstract bool TryGetName(Type clrType, EventInfo ei, MethodInfo mi, out string name);
-        protected abstract bool TryGetName(Type clrType, PropertyInfo pi, MethodInfo mi, out string name);
         protected abstract Type/*!*/[]/*!*/ MakeSiteSignature(int nargs);
         protected abstract Type/*!*/ ContextType { get; }
 
@@ -247,8 +203,6 @@ namespace IronRuby.Compiler.Generation {
 
                     fieldAccessorNames.Add(method.Name);
                 }
-
-                _specialNames.SetSpecialName(fi.Name, fieldAccessorNames);
             }
         }
 
@@ -257,10 +211,19 @@ namespace IronRuby.Compiler.Generation {
         /// including statics and non-statics.
         /// &lt;/summary&gt;
         internal void OverrideMethods(Type type) {
-            // if we have conflicting virtual's due to new slots only override the methods on the
-            // most derived class.
+            // if we have conflicting virtual's due to new slots only override the methods on the most derived class.
             var added = new Dictionary&lt;Key&lt;string, MethodSignatureInfo&gt;, MethodInfo&gt;();
 
+            string defaultGetter, defaultSetter;
+            object[] attrs = type.GetCustomAttributes(typeof(DefaultMemberAttribute), false);
+            if (attrs.Length == 1) {
+                string indexer = ((DefaultMemberAttribute)attrs[0]).MemberName;
+                defaultGetter = &quot;get_&quot; + indexer;
+                defaultSetter = &quot;set_&quot; + indexer;
+            } else {
+                defaultGetter = defaultSetter = null;
+            }
+
             MethodInfo overridden;
             MethodInfo[] methods = type.GetMethods(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.FlattenHierarchy);
 
@@ -277,127 +240,37 @@ namespace IronRuby.Compiler.Generation {
                 }
             }
 
-            var overriddenProperties = new Dictionary&lt;PropertyInfo, PropertyBuilder&gt;();
             foreach (MethodInfo mi in added.Values) {
-                if (!ShouldOverrideVirtual(mi) || !CanOverrideMethod(mi)) continue;
-
-                if (mi.IsPublic || mi.IsProtected()) {
-                    if (mi.IsSpecialName) {
-                        OverrideSpecialName(mi, overriddenProperties);
-                    } else {
-                        OverrideBaseMethod(mi);
-                    }
+                if (mi.DeclaringType == typeof(object) &amp;&amp; mi.Name == &quot;Finalize&quot;) {
+                    continue;
                 }
-            }
-        }
 
-        private void OverrideSpecialName(MethodInfo mi, Dictionary&lt;PropertyInfo, PropertyBuilder&gt; overridden) {
-            if (!mi.IsVirtual || mi.IsFinal) {
-                if ((mi.IsProtected() || mi.IsSpecialName) &amp;&amp; (mi.Name.StartsWith(&quot;get_&quot;) || mi.Name.StartsWith(&quot;set_&quot;))) {
-                    // need to be able to call into protected getter/setter methods from derived types,
-                    // even if these methods aren't virtual and we are in partial trust.
-                    _specialNames.SetSpecialName(mi.Name);
-                    MethodBuilder mb = CreateSuperCallHelper(mi);
-
-                    foreach (PropertyInfo pi in mi.DeclaringType.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)) {
-                        if (pi.GetGetMethod(true) == mi || pi.GetSetMethod(true) == mi) {
-                            AddPublicProperty(mi, overridden, mb, pi);
-                            break;
-                        }
-                    }
-                }
-            } else if (!TryOverrideProperty(mi, overridden)) {
-                EventInfo[] eis = mi.DeclaringType.GetEvents(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
-                foreach (EventInfo ei in eis) {
-                    if (ei.GetAddMethod() == mi) {
-                        CreateVTableMethodOverride(mi, mi.Name);
-                        return;
-                    } else if (ei.GetRemoveMethod() == mi) {
-                        CreateVTableMethodOverride(mi, mi.Name);
-                        return;
-                    }
-                }
+                if (mi.IsPublic || mi.IsProtected()) {
+                    if (mi.IsVirtual &amp;&amp; !mi.IsFinal) {
+                        if (CanOverrideMethod(mi)) {
+                            // override non-sealed virtual methods
+                            string name = mi.Name;
+                            if (mi.IsSpecialName) {
+                                if (name == defaultGetter) {
+                                    name = &quot;[]&quot;;
+                                } else if (name == defaultSetter) {
+                                    name = &quot;[]=&quot;;
+                                } else if (name.StartsWith(&quot;get_&quot;)) {
+                                    name = name.Substring(4);
+                                } else if (name.StartsWith(&quot;set_&quot;)) {
+                                    name = name.Substring(4) + &quot;=&quot;;
+                                }
+                            }
 
-                OverrideBaseMethod(mi);
-            }
-        }
+                            CreateVTableMethodOverride(mi, name);
 
-        private bool TryOverrideProperty(MethodInfo mi, Dictionary&lt;PropertyInfo, PropertyBuilder&gt; overridden) {
-            string name;
-            PropertyInfo[] pis = mi.DeclaringType.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
-
-            _specialNames.SetSpecialName(mi.Name);
-            MethodBuilder mb = null;
-            MethodInfo accessor;
-            PropertyInfo foundProperty = null;
-            foreach (PropertyInfo pi in pis) {
-                if (pi.GetIndexParameters().Length &gt; 0) {
-                    if ((accessor = pi.GetGetMethod(true)) != null &amp;&amp; mi.MethodHandle == accessor.MethodHandle) {
-                        mb = CreateVTableMethodOverride(mi, &quot;__getitem__&quot;);
-                        if (!mi.IsAbstract) {
-                            CreateSuperCallHelper(mi);
-                        }
-                        foundProperty = pi;
-                        break;
-                    } else if ((accessor = pi.GetSetMethod(true)) != null &amp;&amp; mi.MethodHandle == accessor.MethodHandle) {
-                        mb = CreateVTableMethodOverride(mi, &quot;__setitem__&quot;);
-                        if (!mi.IsAbstract) {
-                            CreateSuperCallHelper(mi);
-                        }
-                        foundProperty = pi;
-                        break;
-                    }
-                } else if ((accessor = pi.GetGetMethod(true)) != null &amp;&amp; mi.MethodHandle == accessor.MethodHandle) {
-                    if (mi.Name != &quot;get_PythonType&quot;) {
-                        if (!TryGetName(mi.DeclaringType, pi, mi, out name)) {
-                            return true;
-                        }
-                        mb = CreateVTableGetterOverride(mi, name);
-                        if (!mi.IsAbstract) {
+                            // define a stub for calling base virtual methods from dynamic methods:
                             CreateSuperCallHelper(mi);
                         }
-                    }
-                    foundProperty = pi;
-                    break;
-                } else if ((accessor = pi.GetSetMethod(true)) != null &amp;&amp; mi.MethodHandle == accessor.MethodHandle) {
-                    if (!TryGetName(mi.DeclaringType, pi, mi, out name)) {
-                        return true;
-                    }
-                    mb = CreateVTableSetterOverride(mi, name);
-                    if (!mi.IsAbstract) {
+                    } else if (mi.IsProtected()) {
+                        // define a stub for calling protected methods from dynamic methods:
                         CreateSuperCallHelper(mi);
                     }
-                    foundProperty = pi;
-                    break;
-                }
-            }
-
-            if (foundProperty != null) {
-                AddPublicProperty(mi, overridden, mb, foundProperty);
-                return true;
-            }
-            return false;
-        }
-
-        private void AddPublicProperty(MethodInfo mi, Dictionary&lt;PropertyInfo, PropertyBuilder&gt; overridden, MethodBuilder mb, PropertyInfo foundProperty) {
-            MethodInfo getter = foundProperty.GetGetMethod(true);
-            MethodInfo setter = foundProperty.GetSetMethod(true);
-            if (getter != null &amp;&amp; getter.IsProtected() || setter != null &amp;&amp; setter.IsProtected()) {
-                PropertyBuilder builder;
-                if (!overridden.TryGetValue(foundProperty, out builder)) {
-                    ParameterInfo[] indexArgs = foundProperty.GetIndexParameters();
-                    Type[] paramTypes = new Type[indexArgs.Length];
-                    for (int i = 0; i &lt; paramTypes.Length; i++) {
-                        paramTypes[i] = indexArgs[i].ParameterType;
-                    }
-
-                    overridden[foundProperty] = builder = _tb.DefineProperty(foundProperty.Name, foundProperty.Attributes, foundProperty.PropertyType, paramTypes);
-                }
-
-                if (foundProperty.GetGetMethod(true) == mi) {
-                    builder.SetGetMethod(mb);
-                } else if (foundProperty.GetSetMethod(true) == mi) {
-                    builder.SetSetMethod(mb);
                 }
             }
         }
@@ -427,35 +300,6 @@ namespace IronRuby.Compiler.Generation {
             }
         }
 
-        private void OverrideBaseMethod(MethodInfo mi) {
-            if ((!mi.IsVirtual || mi.IsFinal) &amp;&amp; !mi.IsProtected()) {
-                return;
-            }
-
-            Type baseType;
-            if (_baseType == mi.DeclaringType || _baseType.IsSubclassOf(mi.DeclaringType)) {
-                baseType = _baseType;
-            } else {
-                // We must be inherting from an interface
-                Debug.Assert(mi.DeclaringType.IsInterface);
-                baseType = mi.DeclaringType;
-            }
-
-            string name = null;
-            if (!TryGetName(baseType, mi, out name)) return;
-
-            if (mi.DeclaringType == typeof(object) &amp;&amp; mi.Name == &quot;Finalize&quot;) return;
-
-            _specialNames.SetSpecialName(mi.Name);
-
-            if (!mi.IsStatic) {
-                CreateVTableMethodOverride(mi, name);
-            }
-            if (!mi.IsAbstract) {
-                CreateSuperCallHelper(mi);
-            }
-        }
-
         private MethodBuilder CreateVTableGetterOverride(MethodInfo mi, string name) {
             MethodBuilder impl;
             ILGen il = DefineMethodOverride(MethodAttributes.Public, mi, out impl);
@@ -527,39 +371,12 @@ namespace IronRuby.Compiler.Generation {
             }
         }
 
-        private MethodBuilder CreateVTableSetterOverride(MethodInfo mi, string name) {
-            MethodBuilder impl;
-            ILGen il = DefineMethodOverride(MethodAttributes.Public, mi, out impl);
-
-            EmitVirtualSiteCall(il, mi, name);
-
-            _tb.DefineMethodOverride(impl, mi);
-            return impl;
-        }
-
         private MethodBuilder CreateVTableMethodOverride(MethodInfo mi, string name) {
             ParameterInfo[] parameters = mi.GetParameters();
             MethodBuilder impl;
-            ILGen il;
-            if (mi.IsVirtual &amp;&amp; !mi.IsFinal) {
-                il = DefineMethodOverride(MethodAttributes.Public, mi, out impl);
-            } else {
-                impl = _tb.DefineMethod(
-                    mi.Name,
-                    mi.IsVirtual ?
-                        (mi.Attributes | MethodAttributes.NewSlot) :
-                        ((mi.Attributes &amp; ~MethodAttributes.MemberAccessMask) | MethodAttributes.Public),
-                    mi.CallingConvention
-                );
-                ReflectionUtils.CopyMethodSignature(mi, impl, false);
-                il = CreateILGen(impl.GetILGenerator());
-            }
-
+            ILGen il = DefineMethodOverride(MethodAttributes.Public, mi, out impl);
             EmitVirtualSiteCall(il, mi, name);
-
-            if (mi.IsVirtual &amp;&amp; !mi.IsFinal) {
-                _tb.DefineMethodOverride(impl, mi);
-            }
+            _tb.DefineMethodOverride(impl, mi);
             return impl;
         }
 
@@ -623,7 +440,6 @@ namespace IronRuby.Compiler.Generation {
                 _cctor.Emit(OpCodes.Ret);
             }
             Type result = _tb.CreateType();
-            new OverrideBuilder(_baseType).AddBaseMethods(result, _specialNames);
             return result;
         }
 </diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Compiler/Generation/ClsTypeEmitter.cs</filename>
    </modified>
    <modified>
      <diff>@@ -15,8 +15,12 @@
 
 using System;
 using System.Collections.Generic;
+using System.ComponentModel;
 using System.Reflection.Emit;
+using System.Runtime.Serialization;
 using Microsoft.Scripting.Utils;
+using IronRuby.Runtime;
+using IronRuby.Runtime.Calls;
 
 namespace IronRuby.Compiler.Generation {
     public class InterfacesBuilder : IFeatureBuilder {
@@ -24,7 +28,7 @@ namespace IronRuby.Compiler.Generation {
         #region ITypeFeature
 
         sealed class TypeFeature : ITypeFeature {
-            internal static readonly TypeFeature/*!*/ _empty = new TypeFeature(Type.EmptyTypes);
+            internal static readonly TypeFeature/*!*/ Empty = new TypeFeature(Type.EmptyTypes);
 
             private readonly Type/*!*/[]/*!*/ _interfaces;
             private readonly int _hash;
@@ -97,7 +101,7 @@ namespace IronRuby.Compiler.Generation {
 
         internal static ITypeFeature/*!*/ MakeFeature(IList&lt;Type/*!*/&gt;/*!*/ interfaceTypes) {
             if (interfaceTypes.Count == 0) {
-                return TypeFeature._empty;
+                return TypeFeature.Empty;
             }
             return new TypeFeature(interfaceTypes);
         }
@@ -117,8 +121,16 @@ namespace IronRuby.Compiler.Generation {
             // TODO: Exclude IDynamicMetaObjectProvider, IRubyObject, etc. or handle specially
             Dictionary&lt;Type, bool&gt; doneTypes = new Dictionary&lt;Type, bool&gt;();
             foreach (Type interfaceType in _interfaces) {
-                _tb.AddInterfaceImplementation(interfaceType);
-                ImplementInterface(emitter, interfaceType, doneTypes);
+                if (interfaceType != typeof(IRubyType) &amp;&amp; 
+                    interfaceType != typeof(IRubyObject) &amp;&amp; 
+#if !SILVERLIGHT
+                    interfaceType != typeof(ICustomTypeDescriptor) &amp;&amp;
+                    interfaceType != typeof(ISerializable) &amp;&amp;
+#endif
+                    interfaceType != typeof(IRubyDynamicMetaObjectProvider)) {
+                    _tb.AddInterfaceImplementation(interfaceType);
+                    ImplementInterface(emitter, interfaceType, doneTypes);
+                }
             }
         }
 </diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Compiler/Generation/InterfacesBuilder.cs</filename>
    </modified>
    <modified>
      <diff>@@ -64,32 +64,42 @@ namespace IronRuby.Compiler.Generation {
         #endregion
 
         protected readonly TypeBuilder/*!*/ _tb;
-        protected readonly FieldBuilder/*!*/ _immediateClassField;
-        protected readonly FieldBuilder/*!*/ _instanceDataField;
+        private RubyTypeEmitter _emitter;
 
         internal RubyTypeBuilder(TypeBuilder/*!*/ tb) {
             _tb = tb;
-            _immediateClassField = _tb.DefineField(RubyObject.ImmediateClassFieldName, typeof(RubyClass), FieldAttributes.Private);
-            _instanceDataField = _tb.DefineField(RubyObject.InstanceDataFieldName, typeof(RubyInstanceData), FieldAttributes.Private);
+        }
+
+        internal bool IsDerivedRubyType {
+            get { return _emitter.ImmediateClassField == null; }
+        }
+
+        internal FieldBuilder ImmediateClassField {
+            get { return _emitter.ImmediateClassField; }
+        }
+
+        internal FieldBuilder InstanceDataField {
+            get { return _emitter.InstanceDataField; }
         }
 
         public void Implement(ClsTypeEmitter/*!*/ emitter) {
+            _emitter = (RubyTypeEmitter)emitter;
             DefineConstructors();
-            DefineRubyObjectImplementation();
-            DefineSerializer();
 
-            RubyTypeEmitter re = (emitter as RubyTypeEmitter);
-            Assert.NotNull(re);
-            re.ImmediateClassField = _immediateClassField;
-
-            DefineDynamicObjectImplementation();
+            if (!IsDerivedRubyType) {
+                DefineRubyObjectImplementation();
+                DefineSerializer();
+                DefineDynamicObjectImplementation();
 
 #if !SILVERLIGHT // ICustomTypeDescriptor
-            DefineCustomTypeDescriptor();
+                DefineCustomTypeDescriptor();
 #endif
-
+                DefineRubyTypeImplementation();
+            }
         }
 
+        #region Constructors
+
 #if !SILVERLIGHT
         private static readonly Type/*!*/[]/*!*/ _deserializerSignature = new Type[] { typeof(SerializationInfo), typeof(StreamingContext) };
 #endif
@@ -217,9 +227,11 @@ namespace IronRuby.Compiler.Generation {
 
                 // We need to initialize before calling base ctor since the ctor can call virtual methods.
                 // _immediateClass = immediateClass:
-                il.EmitLoadArg(0);
-                il.EmitLoadArg(1 + ctor.ClassParamIndex);
-                il.EmitFieldSet(_immediateClassField);
+                if (!IsDerivedRubyType) {
+                    il.EmitLoadArg(0);
+                    il.EmitLoadArg(1 + ctor.ClassParamIndex);
+                    il.EmitFieldSet(ImmediateClassField);
+                }
 
                 // base ctor call:
                 il.EmitLoadArg(0);
@@ -270,14 +282,17 @@ namespace IronRuby.Compiler.Generation {
             il.Emit(OpCodes.Call, baseCtor);
 
             il.EmitLoadArg(0);
-            il.EmitFieldAddress(_instanceDataField);
+            il.EmitFieldAddress(InstanceDataField);
             il.EmitLoadArg(0);
-            il.EmitFieldAddress(_immediateClassField);
+            il.EmitFieldAddress(ImmediateClassField);
             il.EmitLoadArg(1);
             il.EmitCall(Methods.DeserializeObject);
             il.Emit(OpCodes.Ret);
         }
 #endif
+        #endregion
+
+        #region &quot;Built-in&quot; Interfaces
 
         private void DefineRubyObjectImplementation() {
             _tb.AddInterfaceImplementation(typeof(IRubyObject));
@@ -296,43 +311,43 @@ namespace IronRuby.Compiler.Generation {
 
             ILGen il;
 
-            // RubyClass! IRubyObject.ImmediateClass { get { return _immediateClassField; } }
+            // RubyClass! get_ImmediateClass { get { return _immediateClassField; } }
             il = DefineMethodOverride(_tb, Methods.IRubyObject_get_ImmediateClass);
             il.EmitLoadArg(0);
-            il.EmitFieldGet(_immediateClassField);
+            il.EmitFieldGet(ImmediateClassField);
             il.Emit(OpCodes.Ret);
 
-            // RubyClass! IRubyObject.ImmediateClass { set { _immediateClassField = value; } }
-            il = DefineMethodOverride(_tb, Methods.IRubyObject_set_ImmediateClass);
+            // RubyClass! IRubyObject.set_ImmediateClass { _immediateClassField = value; }
+            il = DefinePrivateInterfaceMethodOverride(_tb, Methods.IRubyObject_set_ImmediateClass);
             il.EmitLoadArg(0);
             il.EmitLoadArg(1);
-            il.EmitFieldSet(_immediateClassField);
+            il.EmitFieldSet(ImmediateClassField);
             il.Emit(OpCodes.Ret);
 
             // RubyInstanceData IRubyObject.TryGetInstanceData() { return _instanceData; }
-            il = DefineMethodOverride(_tb, Methods.IRubyObject_TryGetInstanceData);
+            il = DefinePrivateInterfaceMethodOverride(_tb, Methods.IRubyObject_TryGetInstanceData);
             il.EmitLoadArg(0);
-            il.EmitFieldGet(_instanceDataField);
+            il.EmitFieldGet(InstanceDataField);
             il.Emit(OpCodes.Ret);
 
             // RubyInstanceData! IRubyObject.GetInstanceData() { return RubyOps.GetInstanceData(ref _instanceData); }
-            il = DefineMethodOverride(_tb, Methods.IRubyObject_GetInstanceData);
+            il = DefinePrivateInterfaceMethodOverride(_tb, Methods.IRubyObject_GetInstanceData);
             il.EmitLoadArg(0);
-            il.EmitFieldAddress(_instanceDataField);
+            il.EmitFieldAddress(InstanceDataField);
             il.EmitCall(Methods.GetInstanceData);
             il.Emit(OpCodes.Ret);
 
             // bool IRubyObject.IsFrozen { get { return RubyOps.IsObjectFrozen(_instanceData); } }
-            il = DefineMethodOverride(_tb, Methods.IRubyObjectState_get_IsFrozen);
+            il = DefinePrivateInterfaceMethodOverride(_tb, Methods.IRubyObjectState_get_IsFrozen);
             il.EmitLoadArg(0);
-            il.EmitFieldGet(_instanceDataField);
+            il.EmitFieldGet(InstanceDataField);
             il.EmitCall(Methods.IsObjectFrozen);
             il.Emit(OpCodes.Ret);
 
             // void IRubyObject.Freeze { RubyOps.FreezeObject(ref _instanceData); }
-            il = DefineMethodOverride(_tb, Methods.IRubyObjectState_Freeze);
+            il = DefinePrivateInterfaceMethodOverride(_tb, Methods.IRubyObjectState_Freeze);
             il.EmitLoadArg(0);
-            il.EmitFieldAddress(_instanceDataField);
+            il.EmitFieldAddress(InstanceDataField);
             il.EmitCall(Methods.FreezeObject);
             il.Emit(OpCodes.Ret);
 
@@ -340,15 +355,15 @@ namespace IronRuby.Compiler.Generation {
             //   get { return RubyOps.IsObjectTainted(_instanceData); }
             //   set { return RubyOps.SetObjectTaint(ref _instanceData, value); }
             // }
-            il = DefineMethodOverride(_tb, Methods.IRubyObjectState_get_IsTainted);
+            il = DefinePrivateInterfaceMethodOverride(_tb, Methods.IRubyObjectState_get_IsTainted);
             il.EmitLoadArg(0);
-            il.EmitFieldGet(_instanceDataField);
+            il.EmitFieldGet(InstanceDataField);
             il.EmitCall(Methods.IsObjectTainted);
             il.Emit(OpCodes.Ret);
 
-            il = DefineMethodOverride(_tb, Methods.IRubyObjectState_set_IsTainted);
+            il = DefinePrivateInterfaceMethodOverride(_tb, Methods.IRubyObjectState_set_IsTainted);
             il.EmitLoadArg(0);
-            il.EmitFieldAddress(_instanceDataField);
+            il.EmitFieldAddress(InstanceDataField);
             il.EmitLoadArg(1);
             il.EmitCall(Methods.SetObjectTaint);
             il.Emit(OpCodes.Ret);
@@ -356,20 +371,20 @@ namespace IronRuby.Compiler.Generation {
             // TODO: can we merge this with #base#GetHashCode/Equals/ToString?
 
             // int IRubyObject.BaseGetHashCode() { return base.GetHashCode(); }
-            il = DefineMethodOverride(_tb, Methods.IRubyObject_BaseGetHashCode);
+            il = DefinePrivateInterfaceMethodOverride(_tb, Methods.IRubyObject_BaseGetHashCode);
             il.EmitLoadArg(0);
             il.EmitCall(_tb.BaseType.GetMethod(&quot;GetHashCode&quot;, Type.EmptyTypes));
             il.Emit(OpCodes.Ret);
 
             // int IRubyObject.BaseEquals(object other) { return base.Equals(other); }
-            il = DefineMethodOverride(_tb, Methods.IRubyObject_BaseEquals);
+            il = DefinePrivateInterfaceMethodOverride(_tb, Methods.IRubyObject_BaseEquals);
             il.EmitLoadArg(0);
             il.EmitLoadArg(1);
             il.EmitCall(_tb.BaseType.GetMethod(&quot;Equals&quot;, new[] { typeof(object) }));
             il.Emit(OpCodes.Ret);
 
             // string IRubyObject.BaseToString() { return base.ToString(); }
-            il = DefineMethodOverride(_tb, Methods.IRubyObject_BaseToString);
+            il = DefinePrivateInterfaceMethodOverride(_tb, Methods.IRubyObject_BaseToString);
             il.EmitLoadArg(0);
             MethodInfo toString = _tb.BaseType.GetMethod(&quot;ToString&quot;, Type.EmptyTypes);
             if (toString.DeclaringType == typeof(object)) {
@@ -380,6 +395,21 @@ namespace IronRuby.Compiler.Generation {
             il.Emit(OpCodes.Ret);
         }
 
+        private void DefineDynamicObjectImplementation() {
+            _tb.AddInterfaceImplementation(typeof(IRubyDynamicMetaObjectProvider));
+
+            // MetaObject! IDynamicMetaObjectProvider.GetMetaObject(Expression! parameter) { return RubyOps.GetMetaObject(this, parameter); }
+            ILGen il = DefinePrivateInterfaceMethodOverride(_tb, typeof(IDynamicMetaObjectProvider).GetMethod(&quot;GetMetaObject&quot;));
+            il.EmitLoadArg(0);
+            il.EmitLoadArg(1);
+            il.EmitCall(Methods.GetMetaObject);
+            il.Emit(OpCodes.Ret);
+        }
+
+        private void DefineRubyTypeImplementation() {
+            _tb.AddInterfaceImplementation(typeof(IRubyType));
+        }
+        
         private void DefineSerializer() {
 #if !SILVERLIGHT
             ILGen il;
@@ -407,38 +437,46 @@ namespace IronRuby.Compiler.Generation {
             }
 
             il.EmitLoadArg(0);
-            il.EmitFieldGet(_instanceDataField);
+            il.EmitFieldGet(InstanceDataField);
             il.EmitLoadArg(0);
-            il.EmitFieldGet(_immediateClassField);
+            il.EmitFieldGet(ImmediateClassField);
             il.EmitLoadArg(1);
             il.EmitCall(Methods.SerializeObject);
             il.Emit(OpCodes.Ret);
 #endif
         }
 
-        private void DefineDynamicObjectImplementation() {
-            _tb.AddInterfaceImplementation(typeof(IRubyDynamicMetaObjectProvider));
-
-            // MetaObject! IDynamicMetaObjectProvider.GetMetaObject(Expression! parameter) {
-            //   return RubyOps.GetMetaObject(this, parameter);
-            // }
+#if !SILVERLIGHT // ICustomTypeDescriptor
+        private void DefineCustomTypeDescriptor() {
+            _tb.AddInterfaceImplementation(typeof(ICustomTypeDescriptor));
 
-            MethodInfo decl = typeof(IDynamicMetaObjectProvider).GetMethod(&quot;GetMetaObject&quot;);
-            MethodBuilder impl = _tb.DefineMethod(
-                decl.Name,
-                decl.Attributes &amp; ~(MethodAttributes.Abstract | MethodAttributes.ReservedMask),
-                decl.ReturnType,
-                ReflectionUtils.GetParameterTypes(decl.GetParameters())
-            );
+            foreach (MethodInfo m in typeof(ICustomTypeDescriptor).GetMethods()) {
+                ImplementCTDOverride(m);
+            }
+        }
 
-            ILGen il = new ILGen(impl.GetILGenerator());
+        private void ImplementCTDOverride(MethodInfo m) {
+            MethodBuilder builder;
+            ILGen il = DefinePrivateInterfaceMethodOverride(_tb, m, out builder);
             il.EmitLoadArg(0);
-            il.EmitLoadArg(1);
-            il.EmitCall(Methods.GetMetaObject);
-            il.Emit(OpCodes.Ret);
 
-            _tb.DefineMethodOverride(impl, decl);
+            ParameterInfo[] pis = m.GetParameters();
+            Type[] paramTypes = new Type[pis.Length + 1];
+            paramTypes[0] = typeof(object);
+            for (int i = 0; i &lt; pis.Length; i++) {
+                il.EmitLoadArg(i + 1);
+                paramTypes[i + 1] = pis[i].ParameterType;
+            }
+
+            il.EmitCall(typeof(CustomTypeDescHelpers), m.Name, paramTypes);
+            il.EmitBoxing(m.ReturnType);
+            il.Emit(OpCodes.Ret);
         }
+#endif
+
+        #endregion
+
+        #region Utils
 
         private static ILGen/*!*/ DefineMethodOverride(TypeBuilder/*!*/ tb, MethodInfo/*!*/ decl) {
             MethodBuilder impl;
@@ -479,32 +517,6 @@ namespace IronRuby.Compiler.Generation {
             return new ILGen(impl.GetILGenerator());
         }
 
-#if !SILVERLIGHT // ICustomTypeDescriptor
-        private void DefineCustomTypeDescriptor() {
-            _tb.AddInterfaceImplementation(typeof(ICustomTypeDescriptor));
-
-            foreach (MethodInfo m in typeof(ICustomTypeDescriptor).GetMethods()) {
-                ImplementCTDOverride(m);
-            }
-        }
-
-        private void ImplementCTDOverride(MethodInfo m) {
-            MethodBuilder builder;
-            ILGen il = DefinePrivateInterfaceMethodOverride(_tb, m, out builder);
-            il.EmitLoadArg(0);
-
-            ParameterInfo[] pis = m.GetParameters();
-            Type[] paramTypes = new Type[pis.Length + 1];
-            paramTypes[0] = typeof(object);
-            for (int i = 0; i &lt; pis.Length; i++) {
-                il.EmitLoadArg(i + 1);
-                paramTypes[i + 1] = pis[i].ParameterType;
-            }
-
-            il.EmitCall(typeof(CustomTypeDescHelpers), m.Name, paramTypes);
-            il.EmitBoxing(m.ReturnType);
-            il.Emit(OpCodes.Ret);
-        }
-#endif
+        #endregion
     }
 }</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Compiler/Generation/RubyTypeBuilder.cs</filename>
    </modified>
    <modified>
      <diff>@@ -60,6 +60,7 @@ namespace IronRuby.Compiler.Generation {
                     InterfacesBuilder.MakeFeature(interfaces)
                 };
             }
+            noOverrides |= typeof(IRubyType).IsAssignableFrom(baseType);
 
             TypeDescription typeInfo = new TypeDescription(baseType, features, noOverrides);
             Type type = _newTypes.GetOrCreateValue(typeInfo,
@@ -104,13 +105,14 @@ namespace IronRuby.Compiler.Generation {
             TypeBuilder tb = Snippets.Shared.DefinePublicType(typeName, baseType);
             Utils.Log(typeName, &quot;TYPE_BUILDER&quot;);
 
-            IFeatureBuilder[] _features = new IFeatureBuilder[typeInfo.Features.Count];
-            ClsTypeEmitter emitter = new RubyTypeEmitter(tb);
+            IFeatureBuilder[] features = new IFeatureBuilder[typeInfo.Features.Count];
+            RubyTypeEmitter emitter = new RubyTypeEmitter(tb);
+
             for (int i = 0; i &lt; typeInfo.Features.Count; i++) {
-                _features[i] = typeInfo.Features[i].MakeBuilder(tb);
+                features[i] = typeInfo.Features[i].MakeBuilder(tb);
             }
 
-            foreach (IFeatureBuilder feature in _features) {
+            foreach (IFeatureBuilder feature in features) {
                 feature.Implement(emitter);
             }
 </diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Compiler/Generation/RubyTypeDispenser.cs</filename>
    </modified>
    <modified>
      <diff>@@ -23,9 +23,7 @@ using System;
 using System.Reflection;
 using System.Reflection.Emit;
 using System.Runtime.CompilerServices;
-using Microsoft.Scripting;
 using Microsoft.Scripting.Generation;
-using Microsoft.Scripting.Runtime;
 using IronRuby.Builtins;
 using IronRuby.Runtime;
 using IronRuby.Runtime.Calls;
@@ -35,15 +33,28 @@ using System.Collections.Generic;
 
 namespace IronRuby.Compiler.Generation {
     public class RubyTypeEmitter : ClsTypeEmitter {
-        private FieldBuilder _immediateClassField;
+        private readonly FieldBuilder _immediateClassField;
+        private readonly FieldBuilder _instanceDataField;
 
         public RubyTypeEmitter(TypeBuilder tb)
             : base(tb) {
+
+            if (!typeof(IRubyType).IsAssignableFrom(tb.BaseType)) {
+                _immediateClassField = tb.DefineField(RubyObject.ImmediateClassFieldName, typeof(RubyClass), FieldAttributes.Private);
+                _instanceDataField = tb.DefineField(RubyObject.InstanceDataFieldName, typeof(RubyInstanceData), FieldAttributes.Private);
+            }
+        }
+
+        internal bool IsDerivedRubyType {
+            get { return _immediateClassField == null; }
         }
 
         internal FieldBuilder ImmediateClassField {
             get { return _immediateClassField; }
-            set { _immediateClassField = value; }
+        }
+
+        internal FieldBuilder InstanceDataField {
+            get { return _instanceDataField; }
         }
 
         public static void AddRemoveEventHelper(object method, object instance, object dt, object eventValue, string name) {
@@ -133,29 +144,6 @@ namespace IronRuby.Compiler.Generation {
             }
         }
 
-        protected override bool TryGetName(Type clrType, MethodInfo mi, out string name) {
-            name = mi.Name;
-            return true;
-        }
-
-        protected override bool TryGetName(Type clrType, EventInfo ei, MethodInfo mi, out string name) {
-            // TODO: Determine naming convention?
-            name = ei.Name;
-            return true;
-        }
-
-        protected override bool TryGetName(Type clrType, PropertyInfo pi, MethodInfo mi, out string name) {
-            if (mi.Name.StartsWith(&quot;get_&quot;)) {
-                name = pi.Name;
-            } else if (mi.Name.StartsWith(&quot;set_&quot;)) {
-                name = pi.Name + &quot;=&quot;;
-            } else {
-                name = null;
-                return false;
-            }
-            return true;
-        }
-
         protected override Type/*!*/[]/*!*/ MakeSiteSignature(int nargs) {
             Type[] sig = new Type[nargs + 4];
             sig[0] = typeof(CallSite);</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Compiler/Generation/RubyTypeEmitter.cs</filename>
    </modified>
    <modified>
      <diff>@@ -216,10 +216,10 @@ namespace IronRuby.Compiler {
         private static MethodInfo _GetCurrentMatchGroup;
         public static MethodInfo/*!*/ GetCurrentMatchLastGroup { get { return _GetCurrentMatchLastGroup ?? (_GetCurrentMatchLastGroup = GetMethod(typeof(RubyOps), &quot;GetCurrentMatchLastGroup&quot;)); } }
         private static MethodInfo _GetCurrentMatchLastGroup;
-        public static MethodInfo/*!*/ GetCurrentPreMatch { get { return _GetCurrentPreMatch ?? (_GetCurrentPreMatch = GetMethod(typeof(RubyOps), &quot;GetCurrentPreMatch&quot;)); } }
-        private static MethodInfo _GetCurrentPreMatch;
         public static MethodInfo/*!*/ GetCurrentPostMatch { get { return _GetCurrentPostMatch ?? (_GetCurrentPostMatch = GetMethod(typeof(RubyOps), &quot;GetCurrentPostMatch&quot;)); } }
         private static MethodInfo _GetCurrentPostMatch;
+        public static MethodInfo/*!*/ GetCurrentPreMatch { get { return _GetCurrentPreMatch ?? (_GetCurrentPreMatch = GetMethod(typeof(RubyOps), &quot;GetCurrentPreMatch&quot;)); } }
+        private static MethodInfo _GetCurrentPreMatch;
         public static MethodInfo/*!*/ GetDefaultExceptionMessage { get { return _GetDefaultExceptionMessage ?? (_GetDefaultExceptionMessage = GetMethod(typeof(RubyOps), &quot;GetDefaultExceptionMessage&quot;)); } }
         private static MethodInfo _GetDefaultExceptionMessage;
         public static MethodInfo/*!*/ GetEmptyScope { get { return _GetEmptyScope ?? (_GetEmptyScope = GetMethod(typeof(RubyOps), &quot;GetEmptyScope&quot;)); } }
@@ -360,6 +360,8 @@ namespace IronRuby.Compiler {
         private static MethodInfo _MakeArrayN;
         public static MethodInfo/*!*/ MakeClrProtectedMethodCalledError { get { return _MakeClrProtectedMethodCalledError ?? (_MakeClrProtectedMethodCalledError = GetMethod(typeof(RubyOps), &quot;MakeClrProtectedMethodCalledError&quot;)); } }
         private static MethodInfo _MakeClrProtectedMethodCalledError;
+        public static MethodInfo/*!*/ MakeClrVirtualMethodCalledError { get { return _MakeClrVirtualMethodCalledError ?? (_MakeClrVirtualMethodCalledError = GetMethod(typeof(RubyOps), &quot;MakeClrVirtualMethodCalledError&quot;)); } }
+        private static MethodInfo _MakeClrVirtualMethodCalledError;
         public static MethodInfo/*!*/ MakeConstructorUndefinedError { get { return _MakeConstructorUndefinedError ?? (_MakeConstructorUndefinedError = GetMethod(typeof(RubyOps), &quot;MakeConstructorUndefinedError&quot;)); } }
         private static MethodInfo _MakeConstructorUndefinedError;
         public static MethodInfo/*!*/ MakeHash { get { return _MakeHash ?? (_MakeHash = GetMethod(typeof(RubyOps), &quot;MakeHash&quot;)); } }</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Compiler/ReflectionCache.Generated.cs</filename>
    </modified>
    <modified>
      <diff></diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Ruby.Build.csproj</filename>
    </modified>
    <modified>
      <diff>@@ -247,6 +247,7 @@
     &lt;Compile Include=&quot;Compiler\Ast\Walkers\NodeTypes.cs&quot; /&gt;
     &lt;Compile Include=&quot;Compiler\Ast\Walkers\Walker.cs&quot; /&gt;
     &lt;Compile Include=&quot;Compiler\Errors.cs&quot; /&gt;
+    &lt;Compile Include=&quot;Compiler\Generation\IRubyType.cs&quot; /&gt;
     &lt;Compile Include=&quot;Compiler\Parser\ParserStack.cs&quot; /&gt;
     &lt;Compile Include=&quot;Runtime\BinaryContentProvider.cs&quot; /&gt;
     &lt;Compile Include=&quot;Runtime\CallSiteStorages.cs&quot; /&gt;
@@ -273,7 +274,6 @@
     &lt;Compile Include=&quot;Runtime\CheckedMonitor.cs&quot; /&gt;
     &lt;Compile Include=&quot;Runtime\ClrName.cs&quot; /&gt;
     &lt;Compile Include=&quot;Runtime\CustomTypeDescHelpers.cs&quot; /&gt;
-    &lt;Compile Include=&quot;Compiler\Generation\OverriddenMembers.cs&quot; /&gt;
     &lt;Compile Include=&quot;Compiler\Generation\RubyTypeDispenser.cs&quot; /&gt;
     &lt;Compile Include=&quot;Compiler\Generation\InterfacesBuilder.cs&quot; /&gt;
     &lt;Compile Include=&quot;Compiler\Generation\RubyTypeEmitter.cs&quot; /&gt;</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Ruby.csproj</filename>
    </modified>
    <modified>
      <diff>@@ -184,11 +184,17 @@ namespace IronRuby.Runtime.Calls {
 
         internal class InvokeMember : InvokeMemberBinder, IInteropBinder {
             private readonly RubyContext/*!*/ _context;
+            private readonly string _mangled;
 
             internal InvokeMember(RubyContext/*!*/ context, string/*!*/ name, CallInfo/*!*/ callInfo)
+                : this(context, name, null, callInfo) {
+            }
+
+            private InvokeMember(RubyContext/*!*/ context, string/*!*/ name, string mangled, CallInfo/*!*/ callInfo)
                 : base(name, false, callInfo) {
                 Assert.NotNull(context);
                 _context = context;
+                _mangled = mangled;
             }
 
             public RubyContext Context {
@@ -206,7 +212,14 @@ namespace IronRuby.Runtime.Calls {
                 }
 #endif
 
-                return FallbackInvokeMember(this, Name, CallInfo, target, args, errorSuggestion);
+                if (_mangled == null) {
+                    string unmangled = RubyUtils.TryUnmangleMethodName(Name);
+                    if (unmangled != null) {
+                        return new InvokeMember(_context, unmangled, Name, CallInfo).Bind(target, args);
+                    }
+                }
+
+                return FallbackInvokeMember(this, _mangled ?? Name, CallInfo, target, args, errorSuggestion);
             }
 
             internal static DynamicMetaObject FallbackInvokeMember(IInteropBinder/*!*/ binder, string/*!*/ methodName, CallInfo/*!*/ callInfo,</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/InteropBinder.cs</filename>
    </modified>
    <modified>
      <diff>@@ -27,6 +27,7 @@ using Microsoft.Scripting.Utils;
 using System.Threading;
 using System.Diagnostics;
 using IronRuby.Runtime.Conversions;
+using System.Reflection;
 
 namespace IronRuby.Runtime.Calls {
     public sealed class RubyBinder : DefaultBinder {
@@ -81,7 +82,7 @@ namespace IronRuby.Runtime.Calls {
             return result;
         }
 
-#if DEBUG &amp;&amp; !SILVERLIGHT &amp;&amp; CLR2
+#if DEBUG &amp;&amp; !SILVERLIGHT
         // ExpressionWriter might call ToString on a live object that might dynamically invoke a method.
         // We need to prevent recursion in such case.
         [ThreadStatic]
@@ -89,11 +90,14 @@ namespace IronRuby.Runtime.Calls {
 
         private static int _precompiledRuleCounter;
         private static int _ruleCounter;
+#if !CLR2
+        private static MethodInfo _dumpViewMethod; 
+#endif
 #endif
 
         [Conditional(&quot;DEBUG&quot;)]
         internal static void DumpPrecompiledRule(DynamicMetaObjectBinder/*!*/ action, MethodDispatcher/*!*/ dispatcher) {
-#if DEBUG &amp;&amp; !SILVERLIGHT &amp;&amp; CLR2
+#if DEBUG &amp;&amp; !SILVERLIGHT
             if (RubyOptions.ShowRules) {
                 var oldColor = Console.ForegroundColor;
                 Console.ForegroundColor = ConsoleColor.Cyan;
@@ -107,7 +111,7 @@ namespace IronRuby.Runtime.Calls {
 
         [Conditional(&quot;DEBUG&quot;)]
         internal static void DumpRule(DynamicMetaObjectBinder/*!*/ action, BindingRestrictions/*!*/ restrictions, Expression/*!*/ expr) {
-#if DEBUG &amp;&amp; !SILVERLIGHT &amp;&amp; CLR2
+#if DEBUG &amp;&amp; !SILVERLIGHT
             if (RubyOptions.ShowRules) {
                 var oldColor = Console.ForegroundColor;
                 try {
@@ -117,8 +121,19 @@ namespace IronRuby.Runtime.Calls {
                     if (!_DumpingExpression) {
                         var d = (restrictions != BindingRestrictions.Empty) ? Expression.IfThen(restrictions.ToExpression(), expr) : expr;
                         _DumpingExpression = true;
+#if CLR2
                         d.DumpExpression(Console.Out);
-                        Console.WriteLine();
+#else
+                        try {
+                            if (_dumpViewMethod == null) {
+                                _dumpViewMethod = typeof(Expression).GetMethod(&quot;get_DebugView&quot;, BindingFlags.NonPublic | BindingFlags.Instance);
+                            }
+                            Console.WriteLine(_dumpViewMethod.Invoke(d, ArrayUtils.EmptyObjects));
+                            Console.WriteLine();
+                        } catch {
+                            // nop
+                        }
+#endif
                     }
                 } finally {
                     _DumpingExpression = false;</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/RubyBinder.cs</filename>
    </modified>
    <modified>
      <diff>@@ -26,6 +26,7 @@ using System.Diagnostics;
 using System.Reflection;
 using IronRuby.Builtins;
 using IronRuby.Compiler;
+using IronRuby.Compiler.Generation;
 using Microsoft.Scripting.Actions.Calls;
 using Microsoft.Scripting.Generation;
 using Microsoft.Scripting.Utils;
@@ -173,22 +174,98 @@ namespace IronRuby.Runtime.Calls {
             return typeof(SuperCallAction);
         }
 
-        protected virtual MethodBase/*!*/[]/*!*/ GetStaticDispatchMethods(Type/*!*/ baseType, string/*!*/ name) {
-            return MethodBases;
-        }
-
         internal override void BuildSuperCallNoFlow(MetaObjectBuilder/*!*/ metaBuilder, CallArguments/*!*/ args, string/*!*/ name, RubyModule/*!*/ declaringModule) {
             Assert.NotNull(declaringModule, metaBuilder, args);
-
-            IList&lt;MethodBase&gt; methods;
-            if (!declaringModule.IsSingletonClass) {
-                Type associatedType = GetAssociatedSystemType(declaringModule);
-                methods = GetStaticDispatchMethods(associatedType, name);
+            var visibleOverloads = GetVisibleOverloads(args, MethodBases, true);
+            if (visibleOverloads.Count == 0) {
+                metaBuilder.SetError(Methods.MakeClrVirtualMethodCalledError.OpCall(
+                    args.MetaContext.Expression, args.MetaTarget.Expression, Ast.Constant(name)
+                ));
             } else {
-                methods = MethodBases;
+                BuildCallNoFlow(metaBuilder, args, name, visibleOverloads, CallConvention, ImplicitProtocolConversions);
             }
+        }
+
+        internal static IList&lt;MethodBase&gt;/*!*/ GetVisibleOverloads(CallArguments/*!*/ args, IList&lt;MethodBase&gt;/*!*/ overloads, bool isSuperCall) {
+            IList&lt;MethodBase&gt; newOverloads = null;
+            Debug.Assert(overloads.Count &gt; 0);
+
+            // handle CLR-protected and virtual methods:
+
+            // TODO (opt):
+            // We might be able to cache the callable overloads in a MethodGroup. 
+            // However, the _overloadOwners of that group would need to point to the original overload owners, not the current class, in order
+            // to preserve semantics of overload deletion/redefinition (deletion of the protected overload would need to imply deletion
+            // of the correpsondig public overload in the cached MethodGroup).
+            if (isSuperCall || !args.RubyContext.DomainManager.Configuration.PrivateBinding) {
+                Type underlyingType = null;
+                BindingFlags bindingFlags = 0;
+
+                for (int i = 0; i &lt; overloads.Count; i++) {
+                    var overload = overloads[i];
+                    if ((isSuperCall &amp;&amp; overload.IsVirtual &amp;&amp; !overload.IsFinal) || overload.IsProtected()) {
+                        if (newOverloads == null) {
+                            newOverloads = CollectionUtils.GetRange(overloads, 0, i);
+
+                            RubyClass cls;
+                            IRubyType rt = args.Target as IRubyType;
+                            if (rt != null) {
+                                bindingFlags = BindingFlags.Instance;
+                                underlyingType = args.Target.GetType();
+                            } else if ((cls = args.Target as RubyClass) != null &amp;&amp; cls.IsRubyClass &amp;&amp; !cls.IsSingletonClass) {
+                                bindingFlags = BindingFlags.Static;
+                                underlyingType = cls.GetUnderlyingSystemType();
+                            }
+                        }
+
+                        if (underlyingType != null) {
+                            // TODO (opt): we can define a method on the emitted type that does this more efficently:
+                            Type[] genericArguments = overload.IsGenericMethod ? overload.GetGenericArguments() : null;
+
+                            MethodInfo visibleMethod = GetMethodOverload(
+                                ReflectionUtils.GetParameterTypes(overload.GetParameters()),
+                                genericArguments,
+                                underlyingType,
+                                ClsTypeEmitter.BaseMethodPrefix + overload.Name,
+                                BindingFlags.Public | bindingFlags | BindingFlags.InvokeMethod
+                            );
+
+                            Debug.Assert(visibleMethod != null);
+
+                            newOverloads.Add(visibleMethod);
+                        }
+                    } else if (newOverloads != null) {
+                        newOverloads.Add(overload);
+                    }
+                }
+            }
+
+            return newOverloads ?? overloads;
+        }
+
+        private static MethodInfo/*!*/ GetMethodOverload(Type/*!*/[]/*!*/ parameterTypes, Type/*!*/[] genericParameterTypes,
+            Type/*!*/ type, string/*!*/ name, BindingFlags bindingFlags) {
 
-            BuildCallNoFlow(metaBuilder, args, name, methods, CallConvention, ImplicitProtocolConversions);
+            var overloads = type.GetMember(name, MemberTypes.Method, bindingFlags);
+            for (int i = 0; i &lt; overloads.Length; i++) {
+                MethodInfo overload = (MethodInfo)overloads[i];
+                MethodInfo originalOverload = overload;
+                if ((genericParameterTypes != null) != overload.IsGenericMethod) {
+                    continue;
+                }
+
+                if (overload.IsGenericMethod) {
+                    if (overload.GetGenericArguments().Length != genericParameterTypes.Length) {
+                        continue;
+                    }
+                    overload = overload.MakeGenericMethod(genericParameterTypes);
+                }
+
+                if (ReflectionUtils.GetParameterTypes(overload.GetParameters()).ValueEquals(parameterTypes)) {
+                    return originalOverload;
+                }
+            }
+            return null;
         }
 
         internal static BindingTarget/*!*/ ResolveOverload(MetaObjectBuilder/*!*/ metaBuilder, CallArguments/*!*/ args, string/*!*/ name,</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/RubyMethodGroupBase.cs</filename>
    </modified>
    <modified>
      <diff>@@ -38,9 +38,6 @@ namespace IronRuby.Runtime.Calls {
     /// A group of CLR methods that are treated as a single Ruby method.
     /// &lt;/summary&gt;
     public class RubyMethodGroupInfo : RubyMethodGroupBase {
-        private MethodBase/*!*/[] _staticDispatchMethods;
-        private bool? _hasVirtuals;
-
         // True: The group contains only static methods and can only be called statically (with no receiver).
         // False: The group contain instance methods and/or extension methods, or operators.
         private readonly bool _isStatic;
@@ -54,8 +51,6 @@ namespace IronRuby.Runtime.Calls {
         private RubyMethodGroupInfo(RubyMethodGroupInfo/*!*/ info, RubyMemberFlags flags, RubyModule/*!*/ module)
             : base(info.MethodBases, flags, module) {
             _isStatic = info._isStatic;
-            _hasVirtuals = info._hasVirtuals;
-            _staticDispatchMethods = info._staticDispatchMethods;
         }
 
         // copy ctor
@@ -88,88 +83,10 @@ namespace IronRuby.Runtime.Calls {
             return ArrayUtils.MakeArray(MethodBases);
         }
         
-        #region Static dispatch to virtual methods
-
-        private bool HasVirtuals {
-            get {
-                if (!_hasVirtuals.HasValue) {
-                    if (_isStatic) {
-                        _hasVirtuals = false;
-                    } else {
-                        bool hasVirtuals = false;
-                        foreach (MethodBase method in MethodBases) {
-                            if (method.IsVirtual) {
-                                hasVirtuals = true;
-                                break;
-                            }
-                        }
-                        _hasVirtuals = hasVirtuals;
-                    }
-                }
-                return _hasVirtuals.Value;
-            }
-        }
-
-        protected override MethodBase/*!*/[]/*!*/ GetStaticDispatchMethods(Type/*!*/ baseType, string/*!*/ name) {
-            if (!HasVirtuals) {
-                return MethodBases;
-            }
-            if (_staticDispatchMethods == null) {
-                _staticDispatchMethods = new MethodBase[MethodBases.Length];
-                for (int i = 0; i &lt; MethodBases.Length; i++) {
-                    MethodBase method = MethodBases[i];
-                    _staticDispatchMethods[i] = method;
-
-                    MethodInfo methodInfo = method as MethodInfo;
-                    if (methodInfo != null &amp;&amp; methodInfo.IsVirtual) {
-                        _staticDispatchMethods[i] = WrapMethod(methodInfo, baseType);
-                    }
-                }
-            }
-            return _staticDispatchMethods;
-        }
-
-#if DEBUG
-        internal const string SuperCallMethodWrapperNameSuffix = &quot;$RubyMethodGroupInfo.SuperCallMethodWrapper&quot;;
-#else
-        internal const string SuperCallMethodWrapperNameSuffix = &quot;&quot;;
-#endif
-
-        public static DynamicMethod/*!*/ WrapMethod(MethodInfo/*!*/ info, Type/*!*/ associatedType) {
-            var originalParams = info.GetParameters();
-            var newParams = new Type[originalParams.Length + 1];
-            
-            newParams[0] = info.DeclaringType;
-            for (int i = 0; i &lt; originalParams.Length; i++) {
-                newParams[i + 1] = originalParams[i].ParameterType;
-            }
-
-            DynamicMethod result = new DynamicMethod(
-                RubyExceptionData.EncodeMethodName(null, info.Name, SourceSpan.None) + SuperCallMethodWrapperNameSuffix,
-                info.ReturnType, newParams, associatedType
-            );
-
-            ILGenerator ilg = result.GetILGenerator();
-            if (info.IsAbstract) {
-                ilg.Emit(OpCodes.Ldtoken, info);
-                ilg.EmitCall(OpCodes.Call, Methods.MakeAbstractMethodCalledError, null);
-                ilg.Emit(OpCodes.Throw);
-            } else {
-                for (int i = 0; i &lt; newParams.Length; i++) {
-                    ilg.Emit(OpCodes.Ldarg, i);
-                }
-                ilg.EmitCall(OpCodes.Call, info, null);
-                ilg.Emit(OpCodes.Ret);
-            }
-            return result;
-        }
-
-        #endregion
-
         #region Dynamic Call
 
         internal override void BuildCallNoFlow(MetaObjectBuilder/*!*/ metaBuilder, CallArguments/*!*/ args, string/*!*/ name) {
-            var visibleOverloads = GetVisibleOverloads(args, MethodBases);
+            var visibleOverloads = GetVisibleOverloads(args, MethodBases, false);
             if (visibleOverloads.Count == 0) {
                 metaBuilder.SetError(Methods.MakeClrProtectedMethodCalledError.OpCall(
                     args.MetaContext.Expression, args.MetaTarget.Expression, Ast.Constant(name)
@@ -179,92 +96,6 @@ namespace IronRuby.Runtime.Calls {
             }
         }
 
-        private IList&lt;MethodBase&gt;/*!*/ GetVisibleOverloads(CallArguments/*!*/ args, IList&lt;MethodBase&gt;/*!*/ overloads) {
-            IList&lt;MethodBase&gt; newOverloads = null;
-            Debug.Assert(overloads.Count &gt; 0);
-
-            // handle CLR-protected methods:
-
-            // TODO (opt):
-            // We might be able to cache the callable overloads in a MethodGroup. 
-            // However, the _overloadOwners of that group would need to point to the original overload owners, not the current class, in order
-            // to preserve semantics of overload deletion/redefinition (deletion of the protected overload would need to imply deletion
-            // of the correpsondig public overload in the cached MethodGroup).
-            if (!args.RubyContext.DomainManager.Configuration.PrivateBinding) {
-                Type underlyingType = null;
-                BindingFlags bindingFlags = 0;
-
-                for (int i = 0; i &lt; overloads.Count; i++) {
-                    var overload = overloads[i];
-                    if (overload.IsProtected()) {
-                        if (newOverloads == null) {
-                            newOverloads = CollectionUtils.GetRange(overloads, 0, i);
-
-                            RubyClass cls = args.Target as RubyClass;
-                            if (cls != null) {
-                                // target is a non-singleton class, look for the methods on its underlying type if it is Ruby class.
-                                bindingFlags = BindingFlags.Static;
-                            } else {
-                                // use the first non-singleton class:
-                                cls = args.TargetClass.GetNonSingletonClass();
-                                bindingFlags = BindingFlags.Instance;
-                            }
-
-                            if (cls.IsRubyClass &amp;&amp; !cls.IsSingletonClass) {
-                                underlyingType = cls.GetUnderlyingSystemType();
-                            }
-                        }
-
-                        if (underlyingType != null) {
-                            // TODO (opt): we can define a method on the emitted type that does this more efficently:
-                            Type[] genericArguments = overload.IsGenericMethod ? overload.GetGenericArguments() : null;
-
-                            MethodInfo visibleMethod = GetMethodOverload(
-                                ReflectionUtils.GetParameterTypes(overload.GetParameters()), 
-                                genericArguments,
-                                underlyingType,
-                                ClsTypeEmitter.BaseMethodPrefix + overload.Name, 
-                                BindingFlags.Public | bindingFlags | BindingFlags.DeclaredOnly | BindingFlags.InvokeMethod
-                            );
-
-                            Debug.Assert(visibleMethod != null);
-
-                            newOverloads.Add(visibleMethod);
-                        }
-                    } else if (newOverloads != null) {
-                        newOverloads.Add(overload);
-                    }
-                }
-            }
-
-            return newOverloads ?? overloads;
-        }
-
-        private static MethodInfo/*!*/ GetMethodOverload(Type/*!*/[]/*!*/ parameterTypes, Type/*!*/[] genericParameterTypes, 
-            Type/*!*/ type, string/*!*/ name, BindingFlags bindingFlags) {
-
-            var overloads = type.GetMember(name, MemberTypes.Method, bindingFlags);
-            for (int i = 0; i &lt; overloads.Length; i++) {
-                MethodInfo overload = (MethodInfo)overloads[i];
-                MethodInfo originalOverload = overload;
-                if ((genericParameterTypes != null) != overload.IsGenericMethod) {
-                    continue;
-                }
-
-                if (overload.IsGenericMethod) {
-                    if (overload.GetGenericArguments().Length != genericParameterTypes.Length) {
-                        continue;
-                    }
-                    overload = overload.MakeGenericMethod(genericParameterTypes);
-                }
-
-                if (ReflectionUtils.GetParameterTypes(overload.GetParameters()).ValueEquals(parameterTypes)) {
-                    return originalOverload;
-                }
-            }
-            return null;
-        }
-
         #endregion
     }
 }</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/RubyMethodGroupInfo.cs</filename>
    </modified>
    <modified>
      <diff>@@ -103,9 +103,7 @@ namespace IronRuby.Runtime.Calls {
 
             if (_callConvention == SelfCallConvention.SelfIsInstance) {
                 if (CompilerHelpers.IsStatic(method)) {
-                    Debug.Assert(RubyUtils.IsOperator(method) || CompilerHelpers.IsExtension(method) || 
-                        method.Name.EndsWith(RubyMethodGroupInfo.SuperCallMethodWrapperNameSuffix)
-                    );
+                    Debug.Assert(RubyUtils.IsOperator(method) || CompilerHelpers.IsExtension(method));
 
                     // receiver maps to the first parameter:
                     mapping.AddParameter(new ParameterWrapper(infos[i], infos[i].ParameterType, null, true, false, false, true));
@@ -674,13 +672,23 @@ namespace IronRuby.Runtime.Calls {
                 case BindingResult.AmbiguousMatch:
                     exceptionValue = MakeAmbiguousCallError(target);
                     break;
+
                 case BindingResult.IncorrectArgumentCount:
                     exceptionValue = MakeIncorrectArgumentCountError(target);
                     break;
+
                 case BindingResult.CallFailure:
                     exceptionValue = MakeCallFailureError(target);
                     break;
-                default: throw new InvalidOperationException();
+
+                case BindingResult.NoCallableMethod:
+                    exceptionValue = Methods.CreateArgumentsError.OpCall(
+                        AstUtils.Constant(String.Format(&quot;Method '{0}' is not callable&quot;, target.Name))
+                    );
+                    break;
+
+                default: 
+                    throw new InvalidOperationException();
             }
             return Microsoft.Scripting.Actions.ErrorInfo.FromException(exceptionValue);
         }
@@ -771,14 +779,17 @@ namespace IronRuby.Runtime.Calls {
                             }
                         }
                         break;
+
                     case CallFailureReason.TypeInference:
                         // TODO: Display generic parameters so it's clear what we couldn't infer.
                         return Methods.CreateArgumentsError.OpCall(
                             AstUtils.Constant(String.Format(&quot;generic arguments could not be infered for method '{0}'&quot;, target.Name))
                         );
+
                     case CallFailureReason.DuplicateKeyword:
                     case CallFailureReason.UnassignableKeyword:
-                    default: throw new InvalidOperationException();
+                    default: 
+                        throw new InvalidOperationException();
                 }
             }
             throw new InvalidOperationException();</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/RubyOverloadResolver.cs</filename>
    </modified>
    <modified>
      <diff>@@ -38,6 +38,7 @@ namespace IronRuby.Runtime {
         LoadIsolated = 2,
         AppendExtensions = 4,
         ResolveLoaded = 8,
+        AnyLanguage = 16,
 
         Require = LoadOnce | AppendExtensions,
     }
@@ -496,7 +497,13 @@ namespace IronRuby.Runtime {
         private bool LoadFromPath(Scope globalScope, object self, string/*!*/ path, LoadFlags flags, out object loaded) {
             Assert.NotNull(path);
 
-            string[] sourceFileExtensions = DomainManager.Configuration.GetFileExtensions();
+            string[] sourceFileExtensions;
+            if ((flags &amp; LoadFlags.AnyLanguage) != 0) {
+                sourceFileExtensions = DomainManager.Configuration.GetFileExtensions();
+            } else {
+                sourceFileExtensions = DomainManager.Configuration.GetFileExtensions(_context);
+            }
+
             ResolvedFile file = FindFile(path, (flags &amp; LoadFlags.AppendExtensions) != 0, sourceFileExtensions);
             if (file == null) {
                 throw RubyExceptions.CreateLoadError(String.Format(&quot;no such file to load -- {0}&quot;, path));
@@ -586,7 +593,10 @@ namespace IronRuby.Runtime {
 
         internal Scope Execute(Scope globalScope, ScriptCode/*!*/ code) {
             if (globalScope == null || code.LanguageContext != _context) {
-                globalScope = code.CreateScope();
+                if (globalScope == null) {
+                    globalScope = code.CreateScope();
+                }
+
                 if (code.SourceUnit.Path != null) {
                     LoadedScripts[Platform.GetFullPath(code.SourceUnit.Path)] = globalScope;
                 }
@@ -733,7 +743,7 @@ namespace IronRuby.Runtime {
         }
 
         private List&lt;string&gt;/*!*/ GetExtensionsOfExistingFiles(string/*!*/ path, IEnumerable&lt;string&gt;/*!*/ extensions) {
-            // all extensions that could be appended to the path to get an sexisting file:
+            // all extensions that could be appended to the path to get an existing file:
             List&lt;string&gt; result = new List&lt;string&gt;();
             foreach (string extension in extensions) {
                 Debug.Assert(extension != null &amp;&amp; extension.StartsWith(&quot;.&quot;));</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Runtime/Loader.cs</filename>
    </modified>
    <modified>
      <diff>@@ -438,7 +438,7 @@ namespace IronRuby.Runtime {
             }
 
             RubyModule module = value as RubyModule;
-            if (module != null &amp;&amp; (module.IsClass || module.IsInterface)) {
+            if (module != null &amp;&amp; (module.IsClass || module.IsClrModule)) {
                 return module.GetUnderlyingSystemType();
             }
 </diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Runtime/Protocols.cs</filename>
    </modified>
    <modified>
      <diff>@@ -688,11 +688,11 @@ namespace IronRuby.Runtime {
             }
         }
 
-        internal RubyModule/*!*/ GetOrCreateModule(Type/*!*/ interfaceType) {
-            Debug.Assert(interfaceType != null &amp;&amp; interfaceType.IsInterface);
+        internal RubyModule/*!*/ GetOrCreateModule(Type/*!*/ moduleType) {
+            Debug.Assert(RubyModule.IsModuleType(moduleType));
 
             lock (ModuleCacheLock) {
-                return GetOrCreateModuleNoLock(interfaceType);
+                return GetOrCreateModuleNoLock(moduleType);
             }
         }
 
@@ -721,8 +721,6 @@ namespace IronRuby.Runtime {
         }
 
         internal RubyClass/*!*/ GetOrCreateClass(Type/*!*/ type) {
-            Debug.Assert(type != null &amp;&amp; !type.IsInterface);
-
             lock (ModuleCacheLock) {
                 return GetOrCreateClassNoLock(type);
             }
@@ -741,31 +739,31 @@ namespace IronRuby.Runtime {
             return result;
         }
 
-        private RubyModule/*!*/ GetOrCreateModuleNoLock(Type/*!*/ interfaceType) {
-            Debug.Assert(interfaceType != null &amp;&amp; interfaceType.IsInterface);
+        private RubyModule/*!*/ GetOrCreateModuleNoLock(Type/*!*/ moduleType) {
+            Debug.Assert(RubyModule.IsModuleType(moduleType));
 
             RubyModule result;
-            if (_moduleCache.TryGetValue(interfaceType, out result)) {
+            if (_moduleCache.TryGetValue(moduleType, out result)) {
                 return result;
             }
 
-            TypeTracker tracker = (TypeTracker)TypeTracker.FromMemberInfo(interfaceType);
+            TypeTracker tracker = (TypeTracker)TypeTracker.FromMemberInfo(moduleType);
 
             RubyModule[] mixins;
-            if (interfaceType.IsGenericType &amp;&amp; !interfaceType.IsGenericTypeDefinition) {
+            if (moduleType.IsGenericType &amp;&amp; !moduleType.IsGenericTypeDefinition) {
                 // I&lt;T0..Tn&gt; mixes in its generic definition I&lt;,..,&gt;
-                mixins = new[] { GetOrCreateModuleNoLock(interfaceType.GetGenericTypeDefinition()) };
+                mixins = new[] { GetOrCreateModuleNoLock(moduleType.GetGenericTypeDefinition()) };
             } else {
                 mixins = null;
             }
 
-            result = CreateModule(GetQualifiedNameNoLock(interfaceType), null, null, null, mixins, null, tracker, ModuleRestrictions.None);
-            _moduleCache[interfaceType] = result;
+            result = CreateModule(GetQualifiedNameNoLock(moduleType), null, null, null, mixins, null, tracker, ModuleRestrictions.None);
+            _moduleCache[moduleType] = result;
             return result;
         }
 
         private RubyClass/*!*/ GetOrCreateClassNoLock(Type/*!*/ type) {
-            Debug.Assert(type != null &amp;&amp; !type.IsInterface);
+            Debug.Assert(!RubyModule.IsModuleType(type));
 
             RubyClass result;
             if (TryGetClassNoLock(type, out result)) {
@@ -774,22 +772,19 @@ namespace IronRuby.Runtime {
 
             RubyClass baseClass;
 
-            if (type.IsGenericType &amp;&amp; !type.IsGenericTypeDefinition) {
-                // C&lt;T0..Tn&gt;'s super class is its generic definition C&lt;,..,&gt;
-                baseClass = GetOrCreateClassNoLock(type.GetGenericTypeDefinition());
-            } else if (type.IsByRef) {
+            if (type.IsByRef) {
                 baseClass = _objectClass;
             } else {
                 baseClass = GetOrCreateClassNoLock(type.BaseType);
             }
 
             TypeTracker tracker = (TypeTracker)TypeTracker.FromMemberInfo(type);
-            RubyModule[] interfaceMixins = GetDeclaredInterfaceModulesNoLock(type);
+            RubyModule[] clrMixins = GetClrMixinsNoLock(type);
             RubyModule[] expandedMixins;
 
-            if (interfaceMixins != null) {
+            if (clrMixins != null) {
                 using (ClassHierarchyLocker()) {
-                    expandedMixins = RubyModule.ExpandMixinsNoLock(baseClass, interfaceMixins);
+                    expandedMixins = RubyModule.ExpandMixinsNoLock(baseClass, clrMixins);
                 }
             } else {
                 expandedMixins = RubyModule.EmptyArray;
@@ -808,35 +803,41 @@ namespace IronRuby.Runtime {
             return result;
         }
 
-        private RubyModule[] GetDeclaredInterfaceModulesNoLock(Type/*!*/ type) {
-            // TODO:
-            if (type.IsGenericTypeDefinition) {
-                return null;
-            }
+        /// &lt;summary&gt;
+        /// An interface is mixed into the type that implements it.
+        /// A generic type definition is mixed into its instantiations.
+        /// 
+        /// In both cases these modules don't contribute any callable CLR methods, 
+        /// however Ruby methods defined on them can be called from the target type instances.
+        /// &lt;/summary&gt;
+        private RubyModule[] GetClrMixinsNoLock(Type/*!*/ type) {
+            List&lt;RubyModule&gt; modules = new List&lt;RubyModule&gt;();
 
-            List&lt;RubyModule&gt; interfaces = new List&lt;RubyModule&gt;();
+            if (type.IsGenericType &amp;&amp; !type.IsGenericTypeDefinition) {
+                modules.Add(GetOrCreateModuleNoLock(type.GetGenericTypeDefinition()));
+            }
             
             if (type.IsArray) {
                 if (type.GetArrayRank() &gt; 1) {
                     RubyModule module;
                     if (TryGetModuleNoLock(typeof(MultiDimensionalArray), out module)) {
-                        interfaces.Add(module);
+                        modules.Add(module);
                     }
                 }
             } else if (type.IsEnum) {
                 if (type.IsDefined(typeof(FlagsAttribute), false)) {
                     RubyModule module;
                     if (TryGetModuleNoLock(typeof(FlagEnumeration), out module)) {
-                        interfaces.Add(module);
+                        modules.Add(module);
                     }
                 }
             }
 
             foreach (Type iface in ReflectionUtils.GetDeclaredInterfaces(type)) {
-                interfaces.Add(GetOrCreateModuleNoLock(iface));
+                modules.Add(GetOrCreateModuleNoLock(iface));
             }
 
-            return interfaces.Count &gt; 0 ? interfaces.ToArray() : null;
+            return modules.Count &gt; 0 ? modules.ToArray() : null;
         }
 
         #endregion
@@ -1080,7 +1081,7 @@ namespace IronRuby.Runtime {
         #region Getting Modules and Classes from objects, CLR types and CLR namespaces (thread-safe)
 
         public RubyModule/*!*/ GetModule(Type/*!*/ type) {
-            if (type.IsInterface) {
+            if (RubyModule.IsModuleType(type)) {
                 return GetOrCreateModule(type);
             } else {
                 return GetOrCreateClass(type);
@@ -1092,7 +1093,7 @@ namespace IronRuby.Runtime {
         }
 
         public RubyClass/*!*/ GetClass(Type/*!*/ type) {
-            ContractUtils.Requires(!type.IsInterface);
+            ContractUtils.Requires(!RubyModule.IsModuleType(type));
             return GetOrCreateClass(type);
         }
 
@@ -2106,7 +2107,7 @@ namespace IronRuby.Runtime {
 
         #endregion
 
-        #region Global Scope (TODO: thread-safe)
+        #region Global Scope (thread-safe)
 
         /// &lt;summary&gt;
         /// Creates a scope extension for a DLR scope unless it already exists for the given scope.
@@ -2114,7 +2115,6 @@ namespace IronRuby.Runtime {
         internal RubyGlobalScope/*!*/ InitializeGlobalScope(Scope/*!*/ globalScope, bool createHosted, bool bindGlobals) {
             Assert.NotNull(globalScope);
 
-            // TODO: Scopes are not thread safe but should be!
             var scopeExtension = globalScope.GetExtension(ContextId);
             if (scopeExtension != null) {
                 return (RubyGlobalScope)scopeExtension;
@@ -2124,8 +2124,6 @@ namespace IronRuby.Runtime {
             RubyClass mainSingleton = CreateMainSingleton(mainObject, null);
 
             RubyGlobalScope result = new RubyGlobalScope(this, globalScope, mainObject, createHosted);
-            globalScope.SetExtension(ContextId, result);
-
             if (bindGlobals) {
                 // method_missing:
                 mainSingleton.SetMethodNoEvent(this, Symbols.MethodMissing, 
@@ -2136,8 +2134,7 @@ namespace IronRuby.Runtime {
 
                 mainSingleton.SetGlobalScope(result);
             }
-
-            return result;
+            return (RubyGlobalScope)globalScope.SetExtension(ContextId, result);
         }
 
         public override int ExecuteProgram(SourceUnit/*!*/ program) {</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyContext.cs</filename>
    </modified>
    <modified>
      <diff>@@ -13,21 +13,27 @@
  *
  * ***************************************************************************/
 
+using System.Diagnostics;
+using System.Threading;
+using IronRuby.Builtins;
 using Microsoft.Scripting.Runtime;
 using Microsoft.Scripting.Utils;
-using IronRuby.Builtins;
-using System.Diagnostics;
 
 namespace IronRuby.Runtime {
-    public class RubyGlobalScope : ScopeExtension {
-        private RubyContext/*!*/ _context;
-        private RubyObject/*!*/ _mainObject;
+    /// &lt;summary&gt;
+    /// DLR scope extension.
+    /// Thread safe.
+    /// &lt;/summary&gt;
+    public sealed class RubyGlobalScope : ScopeExtension {
+        private readonly RubyContext/*!*/ _context;
+        private readonly RubyObject/*!*/ _mainObject;
+        private readonly bool _isHosted;
+
+        // interlocked:
         private RubyTopLevelScope _topLocalScope;
-        private bool _isHosted;
 
         public RubyContext/*!*/ Context {
             get { return _context; }
-            set { _context = value; }
         }
 
         public RubyClass/*!*/ MainSingleton {
@@ -44,10 +50,9 @@ namespace IronRuby.Runtime {
 
         public RubyTopLevelScope TopLocalScope {
             get { return _topLocalScope; }
-            internal set { _topLocalScope = value; }
         }
 
-        public RubyGlobalScope(RubyContext/*!*/ context, Scope/*!*/ scope, RubyObject/*!*/ mainObject, bool isHosted)
+        internal RubyGlobalScope(RubyContext/*!*/ context, Scope/*!*/ scope, RubyObject/*!*/ mainObject, bool isHosted)
             : base(scope) {
             Assert.NotNull(context, scope, mainObject);
             Debug.Assert(mainObject.ImmediateClass.IsSingletonClass);
@@ -56,5 +61,9 @@ namespace IronRuby.Runtime {
             _mainObject = mainObject;
             _isHosted = isHosted;
         }
+
+        internal RubyTopLevelScope/*!*/ SetTopLocalScope(RubyTopLevelScope/*!*/ scope) {
+            return Interlocked.CompareExchange(ref _topLocalScope, scope, null);
+        }
     }
 }</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyGlobalScope.cs</filename>
    </modified>
    <modified>
      <diff>@@ -1816,6 +1816,14 @@ namespace IronRuby.Runtime {
             );
         }
 
+        [Emitted]
+        public static Exception/*!*/ MakeClrVirtualMethodCalledError(RubyContext/*!*/ context, object target, string/*!*/ methodName) {
+            return new MissingMethodException(
+                RubyExceptions.FormatMethodMissingMessage(context, target, methodName, &quot;Virtual CLR method `{0}' called via super from {1}; &quot; +
+                &quot;Super calls to virtual CLR methods can only be used in a Ruby subclass of the class declaring the method&quot;)
+            );
+        }
+
         #endregion
 
         [Emitted] //RubyBinder</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyOps.cs</filename>
    </modified>
    <modified>
      <diff>@@ -944,7 +944,7 @@ var closureScope = scope as RubyClosureScope;
                 );
 
                 scope.SetDebugName(bindGlobals ? &quot;top-level-bound&quot; : &quot;top-level&quot;);
-                rubyGlobalScope.TopLocalScope = scope;
+                rubyGlobalScope.SetTopLocalScope(scope);
             } else {
                 // If we reuse a local scope from previous execution all local variables are accessed dynamically.
                 // Therefore we shouldn't have any new static local variables.
@@ -975,6 +975,8 @@ var closureScope = scope as RubyClosureScope;
         public static object ScopeMethodMissing(RubyContext/*!*/ context, Scope/*!*/ globalScope, BlockParam block, object self, SymbolId name, object[]/*!*/ args) {
             Assert.NotNull(context, globalScope);
 
+            // TODO: invoke member:
+
             string str = SymbolTable.IdToString(name);
             if (str.LastCharacter() == '=') {
                 if (args.Length != 1) {</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyScope.cs</filename>
    </modified>
    <modified>
      <diff>@@ -5,12 +5,18 @@ describe &quot;Basic .NET classes&quot; do
     [EmptyClass, Klass, 
       AbstractClass, EmptyAbstractClass, 
       StaticClass, EmptyStaticClass,
-      SealedClass, EmptySealedClass,
-      GenericClass, EmptyGenericClass,
-      Generic2Class, EmptyGeneric2Class
+      SealedClass, EmptySealedClass,      
     ].each do |klass|
         klass.should be_kind_of Class
       end
   end
+
+  it &quot;map to Ruby modules if they represent generic definitions&quot; do
+    [ GenericClass, EmptyGenericClass,
+      Generic2Class, EmptyGeneric2Class
+    ].each do |klass|
+        klass.should be_kind_of Module
+      end
+  end
 end
 </diff>
      <filename>Merlin/Main/Languages/Ruby/Tests/Interop/net/class/mapping_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -6,6 +6,6 @@ end
 
 describe :uninstantiable_generic_class, :shared =&gt; true do
   it &quot;are not able to be instantiated&quot; do
-    lambda { @method.new }.should raise_error(ArgumentError, /generic/)
+    lambda { @method.new }.should raise_error(NoMethodError, /new/)
   end
 end</diff>
      <filename>Merlin/Main/Languages/Ruby/Tests/Interop/net/class/shared/uninstantiable.rb</filename>
    </modified>
    <modified>
      <diff>@@ -46,5 +46,10 @@ namespace Microsoft.Scripting.Actions.Calls {
         /// Actual arguments cannot be constructed.
         /// &lt;/summary&gt;
         InvalidArguments,
+
+        /// &lt;summary&gt;
+        /// No method is callable. For example, all methods have an unbound generic parameter.
+        /// &lt;/summary&gt;
+        NoCallableMethod,
     }
 }</diff>
      <filename>Merlin/Main/Runtime/Microsoft.Dynamic/Actions/Calls/BindingResult.cs</filename>
    </modified>
    <modified>
      <diff>@@ -19,19 +19,23 @@ namespace Microsoft.Scripting.Actions.Calls {
         /// Default value, their was no CallFailure.
         /// &lt;/summary&gt;
         None,
+
         /// &lt;summary&gt;
         /// One of more parameters failed to be converted
         /// &lt;/summary&gt;
         ConversionFailure,
+
         /// &lt;summary&gt;
         /// One or more keyword arguments could not be successfully assigned to a positional argument
         /// &lt;/summary&gt;
         UnassignableKeyword,
+
         /// &lt;summary&gt;
         /// One or more keyword arguments were duplicated or would have taken the spot of a 
         /// provided positional argument.
         /// &lt;/summary&gt;
         DuplicateKeyword,
+
         /// &lt;summary&gt;
         /// Type arguments could not be inferred
         /// &lt;/summary&gt;</diff>
      <filename>Merlin/Main/Runtime/Microsoft.Dynamic/Actions/Calls/CallFailureReason.cs</filename>
    </modified>
    <modified>
      <diff>@@ -389,7 +389,11 @@ namespace Microsoft.Scripting.Actions.Calls {
                 }
             }
 
-            Debug.Assert(failures != null);
+            if (failures == null) {
+                // this can happen if there is no callable method:
+                return new BindingTarget(_methodName, BindingResult.NoCallableMethod);
+            }
+
             if (nameBindingFailures != null) {
                 failures.AddRange(nameBindingFailures);
             }
@@ -971,6 +975,7 @@ namespace Microsoft.Scripting.Actions.Calls {
                 case BindingResult.AmbiguousMatch: return MakeAmbiguousCallError(target);
                 case BindingResult.IncorrectArgumentCount: return MakeIncorrectArgumentCountError(target);
                 case BindingResult.InvalidArguments: return MakeInvalidArgumentsError();
+                case BindingResult.NoCallableMethod: return MakeNoCallableMethodError();
                 default: throw new InvalidOperationException();
             }
         }
@@ -1075,6 +1080,12 @@ namespace Microsoft.Scripting.Actions.Calls {
             return ErrorInfo.FromException(Ast.Call(typeof(BinderOps).GetMethod(&quot;SimpleTypeError&quot;), AstUtils.Constant(&quot;Invalid arguments.&quot;)));
         }
 
+        private ErrorInfo MakeNoCallableMethodError() {
+            return ErrorInfo.FromException(
+                Ast.New(typeof(InvalidOperationException).GetConstructor(new[] { typeof(string) }), AstUtils.Constant(&quot;No callable method.&quot;))
+            );
+        }
+
         #endregion
 
         #region Splatting</diff>
      <filename>Merlin/Main/Runtime/Microsoft.Dynamic/Actions/Calls/OverloadResolver.cs</filename>
    </modified>
    <modified>
      <diff>@@ -53,7 +53,7 @@ namespace Microsoft.Scripting.Hosting.Shell {
                 return HostingHelpers.GetScope(_scope); 
             }
             set {
-                _scope = new ScriptScope(_engine, value);
+                _scope = HostingHelpers.CreateScriptScope(_engine, value);
             }
         }
         </diff>
      <filename>Merlin/Main/Runtime/Microsoft.Dynamic/Hosting/Shell/CommandLine.cs</filename>
    </modified>
    <modified>
      <diff>@@ -14,10 +14,10 @@
  * ***************************************************************************/
 
 using System;
-using System.ComponentModel;
-using System.Dynamic;
-using Microsoft.Scripting.Utils;
+using System.Runtime.Remoting;
+using System.Runtime.Serialization;
 using Microsoft.Scripting.Runtime;
+using Microsoft.Scripting.Utils;
 
 namespace Microsoft.Scripting.Hosting.Providers {
 
@@ -27,37 +27,57 @@ namespace Microsoft.Scripting.Hosting.Providers {
     /// extend it with language specific functionality, for example. 
     /// &lt;/summary&gt;
     public static class HostingHelpers {
+        /// &lt;exception cref=&quot;ArgumentNullException&quot;&gt;&lt;paramref name=&quot;runtime&quot;/&gt; is a &lt;c&gt;null&lt;/c&gt; reference.&lt;/exception&gt;
+        /// &lt;exception cref=&quot;SerializationException&quot;&gt;&lt;paramref name=&quot;runtime&quot;/&gt; is remote.&lt;/exception&gt;
         public static ScriptDomainManager GetDomainManager(ScriptRuntime runtime) {
             ContractUtils.RequiresNotNull(runtime, &quot;runtime&quot;);
             return runtime.Manager;
         }
 
+        /// &lt;exception cref=&quot;ArgumentNullException&quot;&gt;&lt;paramref name=&quot;engine&quot;/&gt;e is a &lt;c&gt;null&lt;/c&gt; reference.&lt;/exception&gt;
+        /// &lt;exception cref=&quot;SerializationException&quot;&gt;&lt;paramref name=&quot;engine&quot;/&gt; is remote.&lt;/exception&gt;
         public static LanguageContext GetLanguageContext(ScriptEngine engine) {
             ContractUtils.RequiresNotNull(engine, &quot;engine&quot;);
             return engine.LanguageContext;
         }
 
+        /// &lt;exception cref=&quot;ArgumentNullException&quot;&gt;&lt;paramref name=&quot;scriptSource&quot;/&gt; is a &lt;c&gt;null&lt;/c&gt; reference.&lt;/exception&gt;
+        /// &lt;exception cref=&quot;SerializationException&quot;&gt;&lt;paramref name=&quot;scriptSource&quot;/&gt; is remote.&lt;/exception&gt;
         public static SourceUnit GetSourceUnit(ScriptSource scriptSource) {
             ContractUtils.RequiresNotNull(scriptSource, &quot;scriptSource&quot;);
             return scriptSource.SourceUnit;
         }
 
+        /// &lt;exception cref=&quot;ArgumentNullException&quot;&gt;&lt;paramref name=&quot;compiledCode&quot;/&gt; is a &lt;c&gt;null&lt;/c&gt; reference.&lt;/exception&gt;
+        /// &lt;exception cref=&quot;SerializationException&quot;&gt;&lt;paramref name=&quot;compiledCode&quot;/&gt; is remote.&lt;/exception&gt;
         public static ScriptCode GetScriptCode(CompiledCode compiledCode) {
             ContractUtils.RequiresNotNull(compiledCode, &quot;compiledCode&quot;);
             return compiledCode.ScriptCode;
         }
 
+        /// &lt;exception cref=&quot;ArgumentNullException&quot;&gt;&lt;paramref name=&quot;io&quot;/&gt; is a &lt;c&gt;null&lt;/c&gt; reference.&lt;/exception&gt;
+        /// &lt;exception cref=&quot;SerializationException&quot;&gt;&lt;paramref name=&quot;io&quot;/&gt; is remote.&lt;/exception&gt;
         public static SharedIO GetSharedIO(ScriptIO io) {
             ContractUtils.RequiresNotNull(io, &quot;io&quot;);
             return io.SharedIO;
         }
 
+        /// &lt;exception cref=&quot;ArgumentNullException&quot;&gt;&lt;paramref name=&quot;scriptScope&quot;/&gt; is a &lt;c&gt;null&lt;/c&gt; reference.&lt;/exception&gt;
+        /// &lt;exception cref=&quot;SerializationException&quot;&gt;&lt;paramref name=&quot;scriptScope&quot;/&gt; is remote.&lt;/exception&gt;
         public static Scope GetScope(ScriptScope scriptScope) {
             ContractUtils.RequiresNotNull(scriptScope, &quot;scriptScope&quot;);
             return scriptScope.Scope;
         }
 
+        /// &lt;exception cref=&quot;ArgumentNullException&quot;&gt;&lt;paramref name=&quot;engine&quot;/&gt; is a &lt;c&gt;null&lt;/c&gt; reference.&lt;/exception&gt;
+        /// &lt;exception cref=&quot;ArgumentNullException&quot;&gt;&lt;paramref name=&quot;scope&quot;/&gt; is a &lt;c&gt;null&lt;/c&gt; reference.&lt;/exception&gt;
+        /// &lt;exception cref=&quot;ArgumentException&quot;&gt;&lt;paramref name=&quot;engine&quot;/&gt; is a transparent proxy.&lt;/exception&gt;
         public static ScriptScope CreateScriptScope(ScriptEngine engine, Scope scope) {
+            ContractUtils.RequiresNotNull(engine, &quot;engine&quot;);
+            ContractUtils.RequiresNotNull(scope, &quot;scope&quot;);
+#if !SILVERLIGHT
+            ContractUtils.Requires(!RemotingServices.IsTransparentProxy(engine), &quot;engine&quot;, &quot;The engine cannot be a transparent proxy&quot;);
+#endif
             return new ScriptScope(engine, scope);
         }
 </diff>
      <filename>Merlin/Main/Runtime/Microsoft.Scripting/Hosting/Providers/HostingHelpers.cs</filename>
    </modified>
    <modified>
      <diff>@@ -192,6 +192,7 @@ namespace Microsoft.Scripting.Hosting {
             return new ScriptScope(this, new Scope());
         }
 
+        [Obsolete(&quot;IAttributesCollection is obsolete, use CreateScope(IDynamicMetaObjectProvider) instead&quot;)]
         public ScriptScope CreateScope(IAttributesCollection dictionary) {
             ContractUtils.RequiresNotNull(dictionary, &quot;dictionary&quot;);
             return new ScriptScope(this, new Scope(dictionary));
@@ -454,7 +455,8 @@ namespace Microsoft.Scripting.Hosting {
 
         #endregion
 
-        #region Scope Variable Access
+        #region Scope Variable Access (obsolete)
+#pragma warning disable 618
 
         /// &lt;summary&gt;
         /// Fetches the value of a variable stored in the scope.
@@ -464,6 +466,7 @@ namespace Microsoft.Scripting.Hosting {
         /// 
         /// If there is a default engine, then the name lookup uses that language's semantics.
         /// &lt;/summary&gt;
+        [Obsolete(&quot;Use ScriptScope.GetVariable instead&quot;)]
         public dynamic GetVariable(ScriptScope scope, string name) {
             ContractUtils.RequiresNotNull(scope, &quot;scope&quot;);
             ContractUtils.RequiresNotNull(name, &quot;name&quot;);
@@ -482,6 +485,7 @@ namespace Microsoft.Scripting.Hosting {
         /// Some languages may refuse to remove some variables.  If the scope has a default language that has bound 
         /// variables that cannot be removed, the language engine throws an exception.
         /// &lt;/summary&gt;
+        [Obsolete(&quot;Use ScriptScope.RemoveVariable instead&quot;)]
         public bool RemoveVariable(ScriptScope scope, string name) {
             ContractUtils.RequiresNotNull(scope, &quot;scope&quot;);
             ContractUtils.RequiresNotNull(name, &quot;name&quot;);
@@ -498,6 +502,7 @@ namespace Microsoft.Scripting.Hosting {
         /// 
         /// If there is a default engine, then the name lookup uses that language's semantics.
         /// &lt;/summary&gt;
+        [Obsolete(&quot;Use ScriptScope.SetVariable instead&quot;)]
         public void SetVariable(ScriptScope scope, string name, object value) {
             ContractUtils.RequiresNotNull(scope, &quot;scope&quot;);
             ContractUtils.RequiresNotNull(name, &quot;name&quot;);
@@ -517,6 +522,7 @@ namespace Microsoft.Scripting.Hosting {
         /// 
         /// If there is a default engine, then the name lookup uses that language's semantics.
         /// &lt;/summary&gt;
+        [Obsolete(&quot;Use ScriptScope.TryGetVariable instead&quot;)]
         public bool TryGetVariable(ScriptScope scope, string name, out object value) {
             ContractUtils.RequiresNotNull(scope, &quot;scope&quot;);
             ContractUtils.RequiresNotNull(name, &quot;name&quot;);
@@ -534,6 +540,10 @@ namespace Microsoft.Scripting.Hosting {
         /// 
         /// Throws an exception if the engine cannot perform the requested type conversion.
         /// &lt;/summary&gt;
+        [Obsolete(
+            &quot;Use ScriptScope.GetVariable&lt;T&gt; instead. If the target scope is not bound to any language &quot; +
+            &quot;or you need control over the conversion use ScriptScope.GetVariable and ScriptEngine.Operations.ConvertTo&lt;T&gt;&quot;
+        )]
         public T GetVariable&lt;T&gt;(ScriptScope scope, string name) {
             ContractUtils.RequiresNotNull(scope, &quot;scope&quot;);
             ContractUtils.RequiresNotNull(name, &quot;name&quot;);
@@ -556,6 +566,10 @@ namespace Microsoft.Scripting.Hosting {
         /// Throws an exception if the engine cannot perform the requested type conversion, 
         /// then it return false and assigns value to default(T).
         /// &lt;/summary&gt;
+        [Obsolete(
+            &quot;Use ScriptScope.GetVariable&lt;T&gt; instead. If the target scope is not bound to any language &quot; +
+            &quot;or you need control over the conversion use ScriptScope.GetVariable and ScriptEngine.Operations.ConvertTo&lt;T&gt;&quot;
+        )]
         public bool TryGetVariable&lt;T&gt;(ScriptScope scope, string name, out T value) {
             ContractUtils.RequiresNotNull(scope, &quot;scope&quot;);
             ContractUtils.RequiresNotNull(name, &quot;name&quot;);
@@ -578,6 +592,7 @@ namespace Microsoft.Scripting.Hosting {
         /// 
         /// If there is a default engine, then the name lookup uses that language's semantics.
         /// &lt;/summary&gt;
+        [Obsolete(&quot;Use ScriptScope.ContainsVariable instead&quot;)]
         public bool ContainsVariable(ScriptScope scope, string name) {
             ContractUtils.RequiresNotNull(scope, &quot;scope&quot;);
             ContractUtils.RequiresNotNull(name, &quot;name&quot;);
@@ -586,9 +601,6 @@ namespace Microsoft.Scripting.Hosting {
             return TryGetVariable(scope, name, out dummy);
         }
 
-        #endregion
-
-        #region Remoting Support
 #if !SILVERLIGHT
 
         /// &lt;summary&gt;
@@ -599,6 +611,7 @@ namespace Microsoft.Scripting.Hosting {
         /// 
         /// If there is a default engine, then the name lookup uses that language's semantics.
         /// &lt;/summary&gt;
+        [Obsolete(&quot;Use ScriptScope.GetVariableHandle instead&quot;)]
         public ObjectHandle GetVariableHandle(ScriptScope scope, string name) {
             ContractUtils.RequiresNotNull(scope, &quot;scope&quot;);
             ContractUtils.RequiresNotNull(name, &quot;name&quot;);
@@ -617,6 +630,7 @@ namespace Microsoft.Scripting.Hosting {
         /// 
         /// If there is a default engine, then the name lookup uses that language's semantics.
         /// &lt;/summary&gt;
+        [Obsolete(&quot;Use ScriptScope.SetVariable instead&quot;)]
         public void SetVariable(ScriptScope scope, string name, ObjectHandle value) {
             ContractUtils.RequiresNotNull(scope, &quot;scope&quot;);
             ContractUtils.RequiresNotNull(name, &quot;name&quot;);
@@ -637,6 +651,7 @@ namespace Microsoft.Scripting.Hosting {
         /// 
         /// If there is a default engine, then the name lookup uses that language's semantics.
         /// &lt;/summary&gt;
+        [Obsolete(&quot;Use ScriptScope.TryGetVariableHandle instead&quot;)]
         public bool TryGetVariableHandle(ScriptScope scope, string name, out ObjectHandle value) {
             ContractUtils.RequiresNotNull(scope, &quot;scope&quot;);
             ContractUtils.RequiresNotNull(name, &quot;name&quot;);
@@ -650,6 +665,7 @@ namespace Microsoft.Scripting.Hosting {
             return false;
         }
 #endif
+#pragma warning restore 618
         #endregion
 
         #region Additional Services</diff>
      <filename>Merlin/Main/Runtime/Microsoft.Scripting/Hosting/ScriptEngine.cs</filename>
    </modified>
    <modified>
      <diff>@@ -16,6 +16,7 @@
 using System;
 using System.Collections.Generic;
 using System.Diagnostics;
+using System.Dynamic;
 using System.IO;
 using System.Reflection;
 using System.Security.Permissions;
@@ -259,12 +260,22 @@ namespace Microsoft.Scripting.Hosting {
             return GetEngine(languageId).CreateScope();
         }
 
+        public ScriptScope CreateScope(IDynamicMetaObjectProvider storage) {
+            return InvariantEngine.CreateScope(storage);
+        }
+
+        public ScriptScope CreateScope(string languageId, IDynamicMetaObjectProvider storage) {
+            return GetEngine(languageId).CreateScope(storage);
+        }
+
+        [Obsolete(&quot;IAttributesCollection is obsolete, use CreateScope(IDynamicMetaObjectProvider) instead&quot;)]
         public ScriptScope CreateScope(IAttributesCollection dictionary) {
             return InvariantEngine.CreateScope(dictionary);
         }
 
-        public ScriptScope CreateScope(string languageId, IAttributesCollection dictionary) {
-            return GetEngine(languageId).CreateScope(dictionary);
+        [Obsolete(&quot;IAttributesCollection is obsolete, use CreateScope(string, IDynamicMetaObjectProvider) instead&quot;)]
+        public ScriptScope CreateScope(string languageId, IAttributesCollection storage) {
+            return GetEngine(languageId).CreateScope(storage);
         }
 
         #endregion</diff>
      <filename>Merlin/Main/Runtime/Microsoft.Scripting/Hosting/ScriptRuntime.cs</filename>
    </modified>
    <modified>
      <diff>@@ -22,7 +22,6 @@ using Microsoft.Scripting.Ast;
 
 using System;
 using System.Collections.Generic;
-using System.Collections.ObjectModel;
 using System.Diagnostics;
 using System.Runtime.Remoting;
 using System.Runtime.Serialization;
@@ -51,10 +50,8 @@ namespace Microsoft.Scripting.Hosting {
         private readonly Scope _scope;
         private readonly ScriptEngine _engine;
 
-        public ScriptScope(ScriptEngine engine, Scope scope) {
-            ContractUtils.RequiresNotNull(engine, &quot;engine&quot;);
-            ContractUtils.RequiresNotNull(scope, &quot;scope&quot;);
-
+        internal ScriptScope(ScriptEngine engine, Scope scope) {
+            Assert.NotNull(engine, scope);
             _scope = scope;
             _engine = engine;
         }
@@ -79,7 +76,7 @@ namespace Microsoft.Scripting.Hosting {
         /// &lt;exception cref=&quot;MissingMemberException&quot;&gt;The specified name is not defined in the scope.&lt;/exception&gt;
         /// &lt;exception cref=&quot;ArgumentNullException&quot;&gt;&lt;paramref name=&quot;name&quot;/&gt; is a &lt;c&gt;null&lt;/c&gt; reference.&lt;/exception&gt;
         public dynamic GetVariable(string name) {
-            return Engine.Operations.GetMember(Scope, name);
+            return _engine.Operations.GetMember(Scope, name);
         }
 
         /// &lt;summary&gt;
@@ -90,7 +87,7 @@ namespace Microsoft.Scripting.Hosting {
         /// &lt;exception cref=&quot;MissingMemberException&quot;&gt;The specified name is not defined in the scope.&lt;/exception&gt;
         /// &lt;exception cref=&quot;ArgumentNullException&quot;&gt;&lt;paramref name=&quot;name&quot;/&gt; is a &lt;c&gt;null&lt;/c&gt; reference.&lt;/exception&gt;
         public T GetVariable&lt;T&gt;(string name) {
-            return _engine.Operations.ConvertTo&lt;T&gt;((object)_engine.GetVariable(this, name));
+            return _engine.Operations.GetMember&lt;T&gt;(Scope, name);
         }
 
         /// &lt;summary&gt;
@@ -98,7 +95,7 @@ namespace Microsoft.Scripting.Hosting {
         /// &lt;/summary&gt;
         /// &lt;exception cref=&quot;ArgumentNullException&quot;&gt;&lt;paramref name=&quot;name&quot;/&gt; is a &lt;c&gt;null&lt;/c&gt; reference.&lt;/exception&gt;
         public bool TryGetVariable(string name, out dynamic value) {
-            return Engine.Operations.TryGetMember(Scope, name, out value);
+            return _engine.Operations.TryGetMember(Scope, name, out value);
         }
 
         /// &lt;summary&gt;
@@ -109,7 +106,7 @@ namespace Microsoft.Scripting.Hosting {
         /// &lt;exception cref=&quot;ArgumentNullException&quot;&gt;&lt;paramref name=&quot;name&quot;/&gt; is a &lt;c&gt;null&lt;/c&gt; reference.&lt;/exception&gt;
         public bool TryGetVariable&lt;T&gt;(string name, out T value) {
             object result;
-            if (Engine.Operations.TryGetMember(Scope, name, out result)) {
+            if (_engine.Operations.TryGetMember(Scope, name, out result)) {
                 value = _engine.Operations.ConvertTo&lt;T&gt;(result);
                 return true;
             }
@@ -122,7 +119,7 @@ namespace Microsoft.Scripting.Hosting {
         /// &lt;/summary&gt;
         /// &lt;exception cref=&quot;ArgumentNullException&quot;&gt;&lt;paramref name=&quot;name&quot;/&gt; is a &lt;c&gt;null&lt;/c&gt; reference.&lt;/exception&gt;
         public void SetVariable(string name, object value) {
-            Engine.Operations.SetMember(Scope, name, value);
+            _engine.Operations.SetMember(Scope, name, value);
         }
 
 #if !SILVERLIGHT
@@ -179,8 +176,8 @@ namespace Microsoft.Scripting.Hosting {
         /// &lt;returns&gt;&lt;c&gt;true&lt;/c&gt; if the value existed in the scope before it has been removed.&lt;/returns&gt;
         /// &lt;exception cref=&quot;ArgumentNullException&quot;&gt;&lt;paramref name=&quot;name&quot;/&gt; is a &lt;c&gt;null&lt;/c&gt; reference.&lt;/exception&gt;
         public bool RemoveVariable(string name) {
-            if (Engine.Operations.ContainsMember(_scope, name)) {
-                Engine.Operations.RemoveMember(_scope, name);
+            if (_engine.Operations.ContainsMember(_scope, name)) {
+                _engine.Operations.RemoveMember(_scope, name);
                 return true;
             }
 
@@ -193,7 +190,7 @@ namespace Microsoft.Scripting.Hosting {
         [System.Diagnostics.CodeAnalysis.SuppressMessage(&quot;Microsoft.Design&quot;, &quot;CA1024:UsePropertiesWhereAppropriate&quot;)]
         public IEnumerable&lt;string&gt; GetVariableNames() {
             // Remoting: we eagerly enumerate all variables to avoid cross domain calls for each item.
-            return Engine.Operations.GetMemberNames((object)_scope.Storage);
+            return _engine.Operations.GetMemberNames((object)_scope.Storage);
         }
 
         /// &lt;summary&gt;
@@ -205,7 +202,7 @@ namespace Microsoft.Scripting.Hosting {
             var result = new List&lt;KeyValuePair&lt;string, object&gt;&gt;();
             
             foreach (string name in GetVariableNames()) {
-                result.Add(new KeyValuePair&lt;string, object&gt;(name, (object)Engine.Operations.GetMember((object)_scope.Storage, name)));
+                result.Add(new KeyValuePair&lt;string, object&gt;(name, (object)_engine.Operations.GetMember((object)_scope.Storage, name)));
             }
 
             result.TrimExcess();</diff>
      <filename>Merlin/Main/Runtime/Microsoft.Scripting/Hosting/ScriptScope.cs</filename>
    </modified>
    <modified>
      <diff></diff>
      <filename>Merlin/Main/Runtime/Microsoft.Scripting/Microsoft.Scripting.Build.csproj</filename>
    </modified>
    <modified>
      <diff>@@ -24,7 +24,6 @@
     &lt;TargetFrameworkVersion&gt;v2.0&lt;/TargetFrameworkVersion&gt;
     &lt;Silverlight3Path&gt;..\..\Utilities\Silverlight\x86ret&lt;/Silverlight3Path&gt;
     &lt;Silverlight4Path&gt;..\..\Utilities\Silverlight\v4-x86fre&lt;/Silverlight4Path&gt;
-
     &lt;!-- The following two lines prevent csc.rsp and Microsoft.NETFramework.props from adding additional assembly references --&gt;
     &lt;NoConfig&gt;true&lt;/NoConfig&gt;
     &lt;AddAdditionalExplicitAssemblyReferences&gt;false&lt;/AddAdditionalExplicitAssemblyReferences&gt;
@@ -242,6 +241,7 @@
     &lt;Compile Include=&quot;Utils\DictionaryUnionEnumerator.cs&quot; /&gt;
     &lt;Compile Include=&quot;Utils\ExceptionFactory.Generated.cs&quot; /&gt;
     &lt;Compile Include=&quot;Utils\ExceptionUtils.cs&quot; /&gt;
+    &lt;Compile Include=&quot;Utils\ExpressionUtils.cs&quot; /&gt;
     &lt;Compile Include=&quot;Utils\ReadOnlyDictionary.cs&quot; /&gt;
     &lt;Compile Include=&quot;Utils\ReflectionUtils.cs&quot; /&gt;
     &lt;Compile Include=&quot;Utils\StringUtils.cs&quot; /&gt;</diff>
      <filename>Merlin/Main/Runtime/Microsoft.Scripting/Microsoft.Scripting.csproj</filename>
    </modified>
    <modified>
      <diff>@@ -166,11 +166,11 @@ namespace Microsoft.Scripting.Runtime {
         }
 
         /// &lt;summary&gt;
-        /// Gets the member name from the object obj and converts it to the type T.  Throws an exception if the
-        /// member does not exist, is write-only, or cannot be converted.
+        /// Gets the member name from the object obj and converts it to the type T. The conversion will be explicit or implicit
+        /// depending on what the langauge prefers. Throws an exception if the member does not exist, is write-only, or cannot be converted.
         /// &lt;/summary&gt;
         public T GetMember&lt;T&gt;(object obj, string name, bool ignoreCase) {
-            CallSite&lt;Func&lt;CallSite, object, T&gt;&gt; convertSite = GetOrCreateSite&lt;object, T&gt;(_lc.CreateConvertBinder(typeof(T), false));
+            CallSite&lt;Func&lt;CallSite, object, T&gt;&gt; convertSite = GetOrCreateSite&lt;object, T&gt;(_lc.CreateConvertBinder(typeof(T), null));
             CallSite&lt;Func&lt;CallSite, object, object&gt;&gt; site = GetOrCreateSite&lt;object, object&gt;(_lc.CreateGetMemberBinder(name, ignoreCase));
             return convertSite.Target(convertSite, site.Target(site, obj));
         }</diff>
      <filename>Merlin/Main/Runtime/Microsoft.Scripting/Runtime/DynamicOperations.cs</filename>
    </modified>
    <modified>
      <diff>@@ -55,6 +55,7 @@ namespace Microsoft.Scripting.Runtime {
         /// &lt;summary&gt;
         /// Creates a new scope with the provided dictionary.
         /// &lt;/summary&gt;
+        [Obsolete(&quot;IAttributesCollection is obsolete, use Scope(IDynamicMetaObjectProvider) overload instead&quot;)]
         public Scope(IAttributesCollection dictionary) {
             _extensions = ScopeExtension.EmptyArray;
             _storage = new AttributesAdapter(dictionary);
@@ -100,7 +101,7 @@ namespace Microsoft.Scripting.Runtime {
             }
         }
 
-        class MetaScope : DynamicMetaObject {
+        internal sealed class MetaScope : DynamicMetaObject {
             public MetaScope(Expression parameter, Scope scope)
                 : base(parameter, BindingRestrictions.Empty, scope) {
             }
@@ -109,6 +110,10 @@ namespace Microsoft.Scripting.Runtime {
                 return Restrict(binder.Bind(StorageMetaObject, DynamicMetaObject.EmptyMetaObjects));
             }
 
+            public override DynamicMetaObject BindInvokeMember(InvokeMemberBinder binder, DynamicMetaObject[] args) {
+                return Restrict(binder.Bind(StorageMetaObject, args));
+            }
+
             public override DynamicMetaObject BindSetMember(SetMemberBinder binder, DynamicMetaObject value) {                
                 return Restrict(binder.Bind(StorageMetaObject, new DynamicMetaObject[] { value }));
             }
@@ -161,7 +166,7 @@ namespace Microsoft.Scripting.Runtime {
 
         #endregion
 
-        class AttributesAdapter : IDynamicMetaObjectProvider {
+        internal sealed class AttributesAdapter : IDynamicMetaObjectProvider {
             private readonly IAttributesCollection _data;
 
             public AttributesAdapter(IAttributesCollection data) {
@@ -192,12 +197,26 @@ namespace Microsoft.Scripting.Runtime {
 
             #endregion
 
-            class Meta : DynamicMetaObject {
+            internal sealed class Meta : DynamicMetaObject {
                 public Meta(Expression parameter, AttributesAdapter storage)
                     : base(parameter, BindingRestrictions.Empty, storage) {
                 }
 
                 public override DynamicMetaObject BindGetMember(GetMemberBinder binder) {
+                    return DynamicTryGetMember(binder.Name,
+                        binder.FallbackGetMember(this).Expression,
+                        (tmp) =&gt; tmp
+                    );
+                }
+
+                public override DynamicMetaObject BindInvokeMember(InvokeMemberBinder binder, DynamicMetaObject[] args) {
+                    return DynamicTryGetMember(binder.Name, 
+                        binder.FallbackInvokeMember(this, args).Expression,
+                        (tmp) =&gt; binder.FallbackInvoke(new DynamicMetaObject(tmp, BindingRestrictions.Empty), args, null).Expression
+                    );
+                }
+
+                private DynamicMetaObject DynamicTryGetMember(string name, Expression fallback, Func&lt;Expression, Expression&gt; resultOp) {
                     var tmp = Expression.Parameter(typeof(object));
                     return new DynamicMetaObject(
                         Expression.Block(
@@ -209,13 +228,13 @@ namespace Microsoft.Scripting.Runtime {
                                         Expression.Invoke(
                                             Expression.Constant(new Func&lt;object, SymbolId, object&gt;(AttributesAdapter.TryGetMember)),
                                             Expression,
-                                            Expression.Constant(SymbolTable.StringToId(binder.Name))
+                                            Expression.Constant(SymbolTable.StringToId(name))
                                         )
                                     ),
                                     Expression.Constant(_getFailed)
                                 ),
-                                tmp,
-                                Expression.Convert(binder.FallbackGetMember(this).Expression, typeof(object))
+                                ExpressionUtils.Convert(resultOp(tmp), typeof(object)),
+                                ExpressionUtils.Convert(fallback, typeof(object))
                             )
                         ),
                         GetRestrictions()</diff>
      <filename>Merlin/Main/Runtime/Microsoft.Scripting/Runtime/Scope.cs</filename>
    </modified>
    <modified>
      <diff>@@ -24,6 +24,7 @@ using System;
 using System.Collections.Generic;
 using System.Threading;
 using System.Dynamic;
+using Microsoft.Scripting.Utils;
 
 namespace Microsoft.Scripting {
     /// &lt;summary&gt;
@@ -196,13 +197,22 @@ namespace Microsoft.Scripting {
             }
 
             public override DynamicMetaObject BindGetMember(GetMemberBinder binder) {
-                IScopeVariable variable = Value.GetVariable(binder.Name, binder.IgnoreCase);
+                return DynamicTryGetValue(binder.Name, binder.IgnoreCase, 
+                    binder.FallbackGetMember(this).Expression,
+                    (tmp) =&gt; tmp
+                );
+            }
+
+            public override DynamicMetaObject BindInvokeMember(InvokeMemberBinder binder, DynamicMetaObject[] args) {
+                return DynamicTryGetValue(binder.Name, binder.IgnoreCase, 
+                    binder.FallbackInvokeMember(this, args).Expression,
+                    (tmp) =&gt; binder.FallbackInvoke(new DynamicMetaObject(tmp, BindingRestrictions.Empty), args, null).Expression
+                );
+            }
+
+            private DynamicMetaObject DynamicTryGetValue(string name, bool ignoreCase, Expression fallback, Func&lt;Expression, Expression&gt; resultOp) {
+                IScopeVariable variable = Value.GetVariable(name, ignoreCase);
                 var tmp = Expression.Parameter(typeof(object));
-                var fallback = binder.FallbackGetMember(this).Expression;
-                if (fallback.Type != typeof(object)) {
-                    // both types need to be object for condition
-                    fallback = Expression.Convert(fallback, typeof(object));
-                }
                 return new DynamicMetaObject(
                     Expression.Block(
                         new[] { tmp },
@@ -212,8 +222,8 @@ namespace Microsoft.Scripting {
                                 variable.GetType().GetMethod(&quot;TryGetValue&quot;),
                                 tmp
                             ),
-                            tmp,
-                            fallback
+                            ExpressionUtils.Convert(resultOp(tmp), typeof(object)),
+                            ExpressionUtils.Convert(fallback, typeof(object))
                         )
                     ),
                     BindingRestrictions.GetInstanceRestriction(Expression, Value)
@@ -221,7 +231,6 @@ namespace Microsoft.Scripting {
             }
 
             private static Expression Variable(IScopeVariable variable) {
-                
                 return Expression.Convert(
                     Expression.Property(
                         Expression.Constant(((IWeakReferencable)variable).WeakReference),
@@ -234,7 +243,7 @@ namespace Microsoft.Scripting {
             public override DynamicMetaObject BindSetMember(SetMemberBinder binder, DynamicMetaObject value) {
                 IScopeVariable variable = Value.GetVariable(binder.Name, binder.IgnoreCase);
 
-                var objExpression = Expression.Convert(value.Expression, typeof(object));
+                var objExpression = ExpressionUtils.Convert(value.Expression, typeof(object));
                 return new DynamicMetaObject(
                     Expression.Block(
                         Expression.Call(</diff>
      <filename>Merlin/Main/Runtime/Microsoft.Scripting/Runtime/ScopeStorage.cs</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Compiler/Generation/OverriddenMembers.cs</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>abdb2564bd050a5c37bd7976ccb52e71052265a1</id>
    </parent>
  </parents>
  <author>
    <name>Jim Deville</name>
    <email>jdeville@microsoft.com</email>
  </author>
  <url>http://github.com/ironruby/ironruby/commit/6b6e2981a9037d8232663bd83063c5e68f6e0b9f</url>
  <id>6b6e2981a9037d8232663bd83063c5e68f6e0b9f</id>
  <committed-date>2009-10-29T14:01:55-07:00</committed-date>
  <authored-date>2009-10-29T14:01:55-07:00</authored-date>
  <message>Syncing to head of TFS for 0.9.2</message>
  <tree>1abf41f0405a74aad4039d3068d8a516c739694a</tree>
  <committer>
    <name>Jim Deville</name>
    <email>jdeville@microsoft.com</email>
  </committer>
</commit>
