Skip inaccessible nested types for member access expressions.
authorMarek Safar <marek.safar@gmail.com>
Wed, 29 Sep 2010 07:39:02 +0000 (08:39 +0100)
committerMarek Safar <marek.safar@gmail.com>
Wed, 29 Sep 2010 08:12:51 +0000 (09:12 +0100)
mcs/errors/cs1750-2.cs
mcs/errors/gcs0060-3.cs
mcs/mcs/const.cs
mcs/mcs/expression.cs
mcs/mcs/parameter.cs
mcs/tests/ver-il-dmcs.xml

index bd22ecfc49e54e0f874e7f08c05bc15562c15d20..414a08628f86e0a2cedfd5c15de89181f9611c49 100644 (file)
@@ -1,4 +1,4 @@
-// CS1763: The expression being assigned to optional parameter `c' must be a constant or default value
+// CS1750: Optional parameter expression of type `S' cannot be converted to parameter type `C'
 // Line: 10
 
 struct S
index 76435ab051eee6397dbf3e2d55fc85ba0dc0bc74..bf9f047da3728239308ff1037cc67e044023d4d2 100644 (file)
@@ -1,4 +1,4 @@
-// CS0122: `Bar.Baz' is inaccessible due to its protection level
+// CS0060: Inconsistent accessibility: base class `Foo<Bar.Baz>' is less accessible than class `Bar'
 // Line: 7
 
 public class Foo<K> {
index 8b0f31b8989ceae7d2c9e10e85eec7838501bfcd..ec4634a0fe6b2e52ebb62e9fa8e7ca0d9690244d 100644 (file)
@@ -224,7 +224,7 @@ namespace Mono.CSharp {
                        }
 
                        if (expr == null) {
-                               expr = New.Constantify (field.MemberType, expr.Location);
+                               expr = New.Constantify (field.MemberType, Location);
                                if (expr == null)
                                        expr = Constant.CreateConstantFromValue (field.MemberType, null, Location);
                                expr = expr.Resolve (rc);
index ccfb19e030fbbe7eff683e228474a8a2acd59ed0..3668b2c1ce5e759b337a17439086bccc23c0647a 100644 (file)
@@ -7599,17 +7599,29 @@ namespace Mono.CSharp {
                                return null;
                        }
 
-                       var nested = MemberCache.FindNestedType (expr_type, Name, Arity);
-                       if (nested == null) {
-                               if (silent)
-                                       return null;
+                       TypeSpec nested = null;
+                       while (expr_type != null) {
+                               nested = MemberCache.FindNestedType (expr_type, Name, Arity);
+                               if (nested == null) {
+                                       if (silent)
+                                               return null;
 
-                               Error_IdentifierNotFound (rc, expr_type, Name);
-                               return null;
-                       }
+                                       if (expr_type == tnew_expr.Type) {
+                                               Error_IdentifierNotFound (rc, expr_type, Name);
+                                               return null;
+                                       }
+
+                                       expr_type = tnew_expr.Type;
+                                       nested = MemberCache.FindNestedType (expr_type, Name, Arity);
+                                       ErrorIsInaccesible (rc, nested.GetSignatureForError (), loc);
+                                       break;
+                               }
+
+                               if (nested.IsAccessible (rc.CurrentType ?? InternalType.FakeInternalType))
+                                       break;
 
-                       if (!nested.IsAccessible (rc.CurrentType ?? InternalType.FakeInternalType)) {
-                               ErrorIsInaccesible (rc, nested.GetSignatureForError (), loc);
+                               // Keep looking after inaccessible candidate
+                               expr_type = nested.DeclaringType.BaseType;
                        }
                        
                        TypeExpr texpr;
index b8d4a99f90d60419a2df6281e084f69450d36d3f..14294bce71ed4f7cab1f0d0eb781a8f380f2775a 100644 (file)
@@ -476,12 +476,21 @@ namespace Mono.CSharp {
                                return default_expr;
 
                        if (TypeManager.IsNullableType (parameter_type)) {
-                               if (default_expr.Type != InternalType.Null && New.Constantify (Nullable.NullableInfo.GetUnderlyingType (parameter_type), Location.Null) == null)
+                               if (default_expr.Type == InternalType.Null)
+                                       return default_expr;
+
+                               var underlying = Nullable.NullableInfo.GetUnderlyingType (parameter_type);
+                               var c = New.Constantify (underlying, Location.Null);
+                               if (c == null) {
                                        rc.Compiler.Report.Error (1770, default_expr.Location,
                                                "The expression being assigned to nullable optional parameter `{0}' must be default value",
                                                Name);
+                                       return null;
+                               }
 
-                               return default_expr;
+                               c = c.Resolve (rc);
+                               if (c.Type == default_expr.Type)
+                                       return default_expr;
                        } else {
                                var res = Convert.ImplicitConversionStandard (rc, default_expr, parameter_type, default_expr.Location);
                                if (res != null) {
index c2db5c4ce367f199e3c91330274c625ba0b02e24..746c7a20d78fe0ec43279f1a69d8805746dc553f 100644 (file)
       </method>
     </type>
   </test>
+  <test name="dtest-031.cs">
+    <type name="A`1[T]">
+      <method name="U CustomDelegate[U](U ByRef)">
+        <size>25</size>
+      </method>
+      <method name="Void .ctor()">
+        <size>7</size>
+      </method>
+    </type>
+    <type name="Test">
+      <method name="Int32 Main()">
+        <size>7</size>
+      </method>
+      <method name="Void Foo[Z]()">
+        <size>103</size>
+      </method>
+      <method name="Void .ctor()">
+        <size>7</size>
+      </method>
+    </type>
+    <type name="Test+&lt;Foo&gt;c__DynamicSite0`1+Container0[Z]">
+      <method name="Void Invoke(System.Runtime.CompilerServices.CallSite, System.Object, Z ByRef)">
+        <size>0</size>
+      </method>
+      <method name="Void .ctor(Object, IntPtr)">
+        <size>0</size>
+      </method>
+    </type>
+  </test>
   <test name="dtest-collectioninit-01.cs">
     <type name="Test">
       <method name="Int32 Main()">
         <size>7</size>
       </method>
       <method name="Int32 Main()">
-        <size>94</size>
+        <size>74</size>
       </method>
     </type>
     <type name="D">
         <size>26</size>
       </method>
       <method name="Void Main()">
-        <size>98</size>
+        <size>88</size>
       </method>
     </type>
   </test>
       </method>
     </type>
   </test>
+  <test name="gtest-540.cs">
+    <type name="C">
+      <method name="Int32 Main()">
+        <size>809</size>
+      </method>
+      <method name="Void .ctor()">
+        <size>7</size>
+      </method>
+    </type>
+  </test>
   <test name="gtest-anon-1.cs">
     <type name="X">
       <method name="Void .ctor()">
       </method>
     </type>
   </test>
+  <test name="gtest-iter-16.cs">
+    <type name="Test.Base">
+      <method name="IEnumerable`1 GetStuff(Int32)">
+        <size>23</size>
+      </method>
+      <method name="Void .ctor()">
+        <size>7</size>
+      </method>
+    </type>
+    <type name="Test.Derived">
+      <method name="IEnumerable`1 GetStuff(Int32)">
+        <size>37</size>
+      </method>
+      <method name="IEnumerable`1 &lt;GetStuff&gt;__BaseCallProxy0(Int32)">
+        <size>8</size>
+      </method>
+      <method name="Void .ctor()">
+        <size>7</size>
+      </method>
+    </type>
+    <type name="Test.SpecialDerived">
+      <method name="IEnumerable`1 GetStuff(Int32)">
+        <size>37</size>
+      </method>
+      <method name="Void Main()">
+        <size>61</size>
+      </method>
+      <method name="IEnumerable`1 &lt;GetStuff&gt;__BaseCallProxy0(Int32)">
+        <size>8</size>
+      </method>
+      <method name="Void .ctor()">
+        <size>7</size>
+      </method>
+    </type>
+    <type name="Test.Base+&lt;GetStuff&gt;c__Iterator0">
+      <method name="Test.Base System.Collections.Generic.IEnumerator&lt;Test.Base&gt;.get_Current()">
+        <size>7</size>
+      </method>
+      <method name="System.Object System.Collections.IEnumerator.get_Current()">
+        <size>7</size>
+      </method>
+      <method name="IEnumerator System.Collections.IEnumerable.GetEnumerator()">
+        <size>7</size>
+      </method>
+      <method name="IEnumerator`1 System.Collections.Generic.IEnumerable&lt;Test.Base&gt;.GetEnumerator()">
+        <size>40</size>
+      </method>
+      <method name="Boolean MoveNext()">
+        <size>68</size>
+      </method>
+      <method name="Void Dispose()">
+        <size>8</size>
+      </method>
+      <method name="Void Reset()">
+        <size>6</size>
+      </method>
+      <method name="Void .ctor()">
+        <size>7</size>
+      </method>
+    </type>
+    <type name="Test.Derived+&lt;GetStuff&gt;c__Iterator1">
+      <method name="Test.Base System.Collections.Generic.IEnumerator&lt;Test.Base&gt;.get_Current()">
+        <size>7</size>
+      </method>
+      <method name="System.Object System.Collections.IEnumerator.get_Current()">
+        <size>7</size>
+      </method>
+      <method name="IEnumerator System.Collections.IEnumerable.GetEnumerator()">
+        <size>7</size>
+      </method>
+      <method name="IEnumerator`1 System.Collections.Generic.IEnumerable&lt;Test.Base&gt;.GetEnumerator()">
+        <size>52</size>
+      </method>
+      <method name="Boolean MoveNext()">
+        <size>185</size>
+      </method>
+      <method name="Void Dispose()">
+        <size>62</size>
+      </method>
+      <method name="Void Reset()">
+        <size>6</size>
+      </method>
+      <method name="Void .ctor()">
+        <size>7</size>
+      </method>
+    </type>
+    <type name="Test.SpecialDerived+&lt;GetStuff&gt;c__Iterator2">
+      <method name="Test.Base System.Collections.Generic.IEnumerator&lt;Test.Base&gt;.get_Current()">
+        <size>7</size>
+      </method>
+      <method name="System.Object System.Collections.IEnumerator.get_Current()">
+        <size>7</size>
+      </method>
+      <method name="IEnumerator System.Collections.IEnumerable.GetEnumerator()">
+        <size>7</size>
+      </method>
+      <method name="IEnumerator`1 System.Collections.Generic.IEnumerable&lt;Test.Base&gt;.GetEnumerator()">
+        <size>52</size>
+      </method>
+      <method name="Boolean MoveNext()">
+        <size>185</size>
+      </method>
+      <method name="Void Dispose()">
+        <size>62</size>
+      </method>
+      <method name="Void Reset()">
+        <size>6</size>
+      </method>
+      <method name="Void .ctor()">
+        <size>7</size>
+      </method>
+    </type>
+  </test>
   <test name="gtest-lambda-01.cs">
     <type name="X">
       <method name="Int32 Main()">
         <size>1</size>
       </method>
       <method name="Void TestStruct(Nullable`1)">
-        <size>1</size>
+        <size>24</size>
       </method>
       <method name="System.String get_Item(Int32, System.String)">
         <size>2</size>
         <size>4</size>
       </method>
       <method name="Int32 Main()">
-        <size>120</size>
+        <size>134</size>
       </method>
       <method name="Void .ctor()">
         <size>7</size>
       </method>
+      <method name="Void TestStruct2(Nullable`1)">
+        <size>1</size>
+      </method>
     </type>
   </test>
   <test name="gtest-optional-05.cs">
       </method>
     </type>
   </test>
+  <test name="test-450.cs">
+    <type name="A">
+      <method name="Int32 Main()">
+        <size>53</size>
+      </method>
+      <method name="Byte op_Implicit(A)">
+        <size>2</size>
+      </method>
+      <method name="A op_Implicit(Int32)">
+        <size>7</size>
+      </method>
+      <method name="Void .ctor(Int32)">
+        <size>14</size>
+      </method>
+    </type>
+  </test>
   <test name="test-451.cs">
     <type name="Test">
       <method name="Void .ctor()">
       </method>
     </type>
   </test>
+  <test name="test-466.cs">
+    <type name="A.X.Test">
+      <method name="Void Main()">
+        <size>13</size>
+      </method>
+      <method name="Void .ctor()">
+        <size>7</size>
+      </method>
+    </type>
+  </test>
+  <test name="test-467.cs">
+    <type name="A">
+      <method name="Void .ctor()">
+        <size>7</size>
+      </method>
+    </type>
+    <type name="A+D">
+      <method name="Int32 Invoke()">
+        <size>0</size>
+      </method>
+      <method name="IAsyncResult BeginInvoke(System.AsyncCallback, System.Object)">
+        <size>0</size>
+      </method>
+      <method name="Int32 EndInvoke(IAsyncResult)">
+        <size>0</size>
+      </method>
+      <method name="Void .ctor(Object, IntPtr)">
+        <size>0</size>
+      </method>
+    </type>
+    <type name="B">
+      <method name="Void .ctor()">
+        <size>7</size>
+      </method>
+    </type>
+    <type name="B+D">
+      <method name="Void Invoke()">
+        <size>0</size>
+      </method>
+      <method name="IAsyncResult BeginInvoke(System.AsyncCallback, System.Object)">
+        <size>0</size>
+      </method>
+      <method name="Void EndInvoke(IAsyncResult)">
+        <size>0</size>
+      </method>
+      <method name="Void .ctor(Object, IntPtr)">
+        <size>0</size>
+      </method>
+    </type>
+    <type name="C">
+      <method name="Int32 Foo()">
+        <size>2</size>
+      </method>
+      <method name="Int32 Main()">
+        <size>29</size>
+      </method>
+      <method name="Void .ctor()">
+        <size>7</size>
+      </method>
+    </type>
+  </test>
   <test name="test-468.cs">
     <type name="CorMetaDataDispenserExClass">
       <method name="Void .ctor()">
         <size>7</size>
       </method>
       <method name="Void ZeroBasedReductions()">
-        <size>18</size>
+        <size>17</size>
       </method>
       <method name="Void Main()">
-        <size>6</size>
+        <size>11</size>
+      </method>
+      <method name="Void ZeroBasedReductionsWithConversion()">
+        <size>15</size>
       </method>
     </type>
   </test>