Keep imported indexer parameters (they can contain non-inflated type parameters)
authorMarek Safar <marek.safar@gmail.com>
Fri, 1 Oct 2010 17:28:32 +0000 (18:28 +0100)
committerMarek Safar <marek.safar@gmail.com>
Fri, 1 Oct 2010 18:39:02 +0000 (19:39 +0100)
mcs/mcs/import.cs
mcs/tests/gtest-165-lib.cs [new file with mode: 0644]
mcs/tests/gtest-165.cs [new file with mode: 0644]
mcs/tests/ver-il-gmcs.xml

index 8c4cfa0f780b4de995a5ad71aa35865c705c02dd..31538e0609c0972156c76bf1e8a00c72fe8f1003 100644 (file)
@@ -377,8 +377,6 @@ namespace Mono.CSharp
                //
                public PropertySpec CreateProperty (PropertyInfo pi, TypeSpec declaringType, MethodSpec get, MethodSpec set)
                {
-                       var definition = new ImportedMemberDefinition (pi);
-
                        Modifiers mod = 0;
                        AParametersCollection param = null;
                        TypeSpec type = null;
@@ -472,11 +470,11 @@ namespace Mono.CSharp
                                }
 
                                if (is_valid_property)
-                                       spec = new IndexerSpec (declaringType, definition, type, param, pi, mod);
+                                       spec = new IndexerSpec (declaringType, new ImportedIndexerDefinition (pi, param), type, param, pi, mod);
                        }
 
                        if (spec == null)
-                               spec = new PropertySpec (MemberKind.Property, declaringType, definition, type, pi, mod);
+                               spec = new PropertySpec (MemberKind.Property, declaringType, new ImportedMemberDefinition (pi), type, pi, mod);
 
                        if (!is_valid_property) {
                                spec.IsNotRealProperty = true;
@@ -1042,6 +1040,33 @@ namespace Mono.CSharp
                #endregion
        }
 
+       class ImportedIndexerDefinition : ImportedMemberDefinition, IParametersMember
+       {
+               readonly AParametersCollection parameters;
+
+               public ImportedIndexerDefinition (PropertyInfo provider, AParametersCollection parameters)
+                       : base (provider)
+               {
+                       this.parameters = parameters;
+               }
+
+               #region Properties
+
+               public AParametersCollection Parameters {
+                       get {
+                               return parameters;
+                       }
+               }
+
+               public TypeSpec MemberType {
+                       get {
+                               throw new NotImplementedException ();
+                       }
+               }
+
+               #endregion
+       }
+
        class ImportedGenericMethodDefinition : ImportedMethodDefinition, IGenericMethodDefinition
        {
                TypeParameterSpec[] tparams;
diff --git a/mcs/tests/gtest-165-lib.cs b/mcs/tests/gtest-165-lib.cs
new file mode 100644 (file)
index 0000000..599ad27
--- /dev/null
@@ -0,0 +1,16 @@
+// Compiler options: -t:library
+
+public class A<T>
+{
+       public int this [T arg] {
+               get {
+                       return 1;
+               }
+       }
+       
+       public int this [string arg] {
+               get {
+                       return 2;
+               }
+       }
+}
diff --git a/mcs/tests/gtest-165.cs b/mcs/tests/gtest-165.cs
new file mode 100644 (file)
index 0000000..1d79d25
--- /dev/null
@@ -0,0 +1,13 @@
+// Compiler options: -r:gtest-165-lib.dll
+
+class C
+{
+       public static int Main ()
+       {
+               var a = new A<string>();
+               if (a ["s"] != 2)
+                       return 1;
+               
+               return 0;
+       }
+}
\ No newline at end of file
index d796fb521a4336445ad0e0290a559a73491ae52c..91479a739f5633003a6ef712730ee2c09b329545 100644 (file)
       </method>
     </type>
   </test>
+  <test name="gtest-165.cs">
+    <type name="C">
+      <method name="Int32 Main()">
+        <size>27</size>
+      </method>
+      <method name="Void .ctor()">
+        <size>7</size>
+      </method>
+    </type>
+  </test>
   <test name="gtest-166.cs">
     <type name="C">
       <method name="Void .ctor()">
   <test name="test-789.cs">
     <type name="Program">
       <method name="Void Main()">
-        <size>50</size>
+        <size>76</size>
       </method>
       <method name="Void &lt;Main&gt;m__0()">
         <size>7</size>