[mcs] Relax struct definitive assignment rules for private fields
authorMarek Safar <marek.safar@gmail.com>
Wed, 16 Apr 2014 18:04:54 +0000 (20:04 +0200)
committerMarek Safar <marek.safar@gmail.com>
Wed, 16 Apr 2014 18:05:16 +0000 (20:05 +0200)
20 files changed:
mcs/errors/CS0165-19-lib.cs
mcs/errors/cs0165-13.cs
mcs/errors/cs0165-20.cs
mcs/errors/cs0170-2.cs
mcs/errors/cs0171-2.cs
mcs/errors/cs0171-3.cs
mcs/errors/cs0171-4.cs
mcs/errors/cs0171-6.cs
mcs/errors/cs0177-8.cs [deleted file]
mcs/errors/cs0188-10.cs
mcs/errors/cs0188-3.cs
mcs/errors/cs0188-4.cs
mcs/errors/cs0188-5.cs
mcs/errors/cs0188-7.cs
mcs/errors/cs0188-8.cs
mcs/errors/cs0188-9.cs
mcs/errors/cs0188.cs
mcs/mcs/membercache.cs
mcs/tests/test-888.cs [new file with mode: 0644]
mcs/tests/ver-il-net_4_5.xml

index bc0c0f6b79ec7d942961e8ea1f1a4dec785be88d..1d9accff99696599cfc79fbb804bb7bba809863d 100644 (file)
@@ -1,6 +1,6 @@
 public struct S
 {
-       int private_value;
+       internal int private_value;
        
        public void Test ()
        {
index 714080b2274f0ab982c474ec1a19e88eb769902b..fa3d6b5e92ba8ddc1539d02a37330b0c108434ab 100644 (file)
@@ -3,7 +3,7 @@
 
 struct Rectangle
 {
-       int x;
+       internal int x;
        public int X {
                set { }
        }
index 0b52c6aa8f0408a3b32c262b6f233c4d0ae17eec..3da7f6e69b388c034e4c7cbbb5386cced1620abd 100644 (file)
@@ -12,7 +12,7 @@ class Program
 
 struct S
 {
-       string pp;
+       public string pp;
        
        public void Test ()
        {
index 911ebee02167770500290c50d38f25da55e6841e..b60f3d97ac9d56b25d36e19c0bfc7ee8fce191ed 100644 (file)
@@ -3,8 +3,8 @@
 
 struct A
 {
-       private long b;
-       private float c;
+       public long b;
+       public float c;
 
        public A (int foo)
        {
index a1c0b11e8e86908fe0749e08a11c71fd273023c5..47efea0acb669c38a3cf18ec8c042e320f6b150d 100755 (executable)
@@ -5,7 +5,7 @@ using System;
 
 struct S
 {
-       event EventHandler ev;
+       public event EventHandler ev;
        
        public S (int i)
        {
index 2ee65200ff4911197cd3240fd84c3f9cf2cb141e..ee995fc31d98a3288ec4d10889d7e3ba8eefbd22 100644 (file)
@@ -3,7 +3,7 @@
 
 public struct Test
 {
-       private int x;
+       internal int x;
 
        public Test (int x)
        {
index f6127ab5067ab3fd8d9ed5f98a1fb22f9d1696f3..8f909cedfb6ed6b73c2522e2d1786b66016bc8ec 100644 (file)
@@ -2,7 +2,7 @@
 // Line: 13
 
 public struct S<TKey> {
-       private TKey key;
+       internal TKey key;
 
        public TKey Key {
                get { return key; }
index e968f1ae323300395d94ae88534a7976673c9b50..31730076f09832fcdd7c6d8bdf2006f6704974e3 100644 (file)
@@ -5,7 +5,7 @@ using System;
 
 struct S
 {
-       string value;
+       internal string value;
 
        public S (int arg)
        {
diff --git a/mcs/errors/cs0177-8.cs b/mcs/errors/cs0177-8.cs
deleted file mode 100644 (file)
index c94b15a..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-// CS0177: The out parameter `parameterModifiers' must be assigned to before control leaves the current method
-// Line: 13
-
-using System;
-using System.Reflection;
-
-class Program
-{
-       bool GetArgsForCall (object [] originalArgs, out ParameterModifier parameterModifiers)
-       {
-               int countOfArgs = originalArgs.Length;
-               if (countOfArgs == 0)
-                       return false;
-
-               parameterModifiers = new ParameterModifier (countOfArgs);
-               return true;
-       }
-}
index 46ac0ca26293a2f3971886689ac9efe8de014e8e..eadb0a8776014d50c89234ff124abd9ba5c21ca3 100644 (file)
@@ -3,7 +3,7 @@
 
 struct S
 {
-       int x;
+       public int x;
        
        S (dynamic d)
        {
index 214a43f2226d20e6cf6c5497ea14ed603b01f772..b6482aff78a82bd4339928c3db95ed5ec1a6b138 100644 (file)
@@ -3,8 +3,8 @@
 
 struct Foo
 {
-       int bar;
-       int baz;
+       public int bar;
+       public int baz;
 
        public int Bar {
                get { return bar; }
index 93b0cfc87f85707ddd2658c0bb76aed1e5f0c87c..6ead083a7a5e67410835b1e44d6c2ca7714e9117 100644 (file)
@@ -3,8 +3,8 @@
 
 struct Foo
 {
-       int bar;
-       int baz;
+       public int bar;
+       public int baz;
 
        public int this [int i] {
                get { return bar; }
index 08923ca5f20124876ab8abc513964b6e94757cb1..d39ae91d46b6c1b6dec1ac6e6eb0f972b0415923 100644 (file)
@@ -8,5 +8,5 @@ struct Sample
                text = base.ToString ();
        }
 
-       string text;
+       internal string text;
 }
\ No newline at end of file
index 792649b0d73bd33bb0c2256720f700ea8757148e..1104a386705ceead2081cd8ba4ec83771554e8b7 100644 (file)
@@ -3,7 +3,7 @@
 
 public struct Test
 {
-       private int x;
+       internal int x;
 
        public Test (int x)
        {
index d5e617998962a2bbbf811dfa36c03188fda5bc6e..57dd731ebca3e34379a6940aeb59c456dc9c8c1f 100644 (file)
@@ -10,5 +10,5 @@ struct Sample
        
        int Prop { get { return 1; } }
 
-       int text;
+       public int text;
 }
\ No newline at end of file
index 62edf231f069e8cce0c97245dc38cbf98ef0ec7e..fc0d3adb461f159e817714ecf298870a34457e43 100644 (file)
@@ -6,7 +6,7 @@ using System;
 public struct S
 {
        public int A { get; private set;}
-       event EventHandler eh;
+       public event EventHandler eh;
 
        public S (int a)
        {
index 172f8f025efd15b39826d50c0797272ccd81824d..2a8c46966ac66ee2357284fedec5e9c28b8f7e91 100644 (file)
@@ -10,5 +10,5 @@ struct Sample {
         void Initialize() {
         }
         
-        string text;
+        public string text;
 }
\ No newline at end of file
index 5b9d6e647917f0b523ba5af10171a49c7a928f9c..6a5182da29bcc92e1f42189c4f92e92e7a5dff6c 100644 (file)
@@ -701,6 +701,14 @@ namespace Mono.CSharp {
                                        if ((name_entry.Modifiers & Modifiers.STATIC) != 0)
                                                continue;
 
+                                       //
+                                       // Ignore user private fields for definite assignment. This is sort of unexpected but
+                                       // rationale is to have consistent results when using reference assemblies which don't
+                                       // include any private fields and full assemblies
+                                       //
+                                       if ((name_entry.Modifiers & (Modifiers.PRIVATE | Modifiers.BACKING_FIELD)) == Modifiers.PRIVATE)
+                                               continue;
+
                                        //
                                        // Fixed size buffers are not subject to definite assignment checking
                                        //
diff --git a/mcs/tests/test-888.cs b/mcs/tests/test-888.cs
new file mode 100644 (file)
index 0000000..6cf0d50
--- /dev/null
@@ -0,0 +1,24 @@
+using System;
+
+// C#6 change
+
+struct S1
+{
+       S2 s2;
+
+       public S1 (int arg)
+       {
+       }
+}
+
+struct S2
+{
+       int field;
+}
+
+class X
+{
+       public static void Main ()
+       {
+       }
+}
\ No newline at end of file
index 4de0d493e7bed2099e1663e55fa85e20c904b6d2..3b991377ea17b1478e0ab92695d18b1d29086d4d 100644 (file)
       </method>\r
     </type>\r
   </test>\r
+  <test name="test-888.cs">\r
+    <type name="S1">\r
+      <method name="Void .ctor(Int32)" attrs="6278">\r
+        <size>2</size>\r
+      </method>\r
+    </type>\r
+    <type name="X">\r
+      <method name="Void Main()" attrs="150">\r
+        <size>2</size>\r
+      </method>\r
+      <method name="Void .ctor()" attrs="6278">\r
+        <size>7</size>\r
+      </method>\r
+    </type>\r
+  </test>\r
   <test name="test-89.cs">\r
     <type name="X">\r
       <method name="X F(Int32)" attrs="145">\r