[mcs] Codegen for auto-property backing field initialization used as assignment....
authorMarek Safar <marek.safar@gmail.com>
Thu, 9 Mar 2017 14:05:25 +0000 (15:05 +0100)
committerMarek Safar <marek.safar@gmail.com>
Thu, 9 Mar 2017 14:06:49 +0000 (15:06 +0100)
mcs/mcs/ecore.cs
mcs/tests/gtest-autoproperty-22.cs [new file with mode: 0644]
mcs/tests/ver-il-net_4_x.xml

index 5dff5e73d79361861f97b7d05bbd45432db84ac4..d2a1b7e95dad11d133df17ce8bafb86896bc3567 100644 (file)
@@ -7005,7 +7005,7 @@ namespace Mono.CSharp {
                public override void EmitAssign (EmitContext ec, Expression source, bool leave_copy, bool isCompound)
                {
                        if (backing_field != null) {
-                               backing_field.EmitAssign (ec, source, false, false);
+                               backing_field.EmitAssign (ec, source, leave_copy, false);
                                return;
                        }
 
diff --git a/mcs/tests/gtest-autoproperty-22.cs b/mcs/tests/gtest-autoproperty-22.cs
new file mode 100644 (file)
index 0000000..7be1a8a
--- /dev/null
@@ -0,0 +1,30 @@
+using System;
+
+class MainClass
+{
+       public static void Main()
+       {
+               Child test = new Child();
+       }
+}
+
+class Parent 
+{
+       protected virtual string Property { get; }
+}
+
+class Child : Parent
+{
+       protected override string Property { get; }
+
+       public Child () 
+       {
+               new AnotherClass{ field = Property = "success" };
+               Console.WriteLine(Property);
+       }
+}
+
+class AnotherClass 
+{
+       public string field;
+}
\ No newline at end of file
index 661f426ec6adcfa6daa8dc88c1f6c96edbb2f634..9ff491a9ee8f90f6e6bae49eff8c580d70c5741e 100644 (file)
       </method>
     </type>
   </test>
+  <test name="gtest-autoproperty-22.cs">
+    <type name="MainClass">
+      <method name="Void Main()" attrs="150">
+        <size>8</size>
+      </method>
+      <method name="Void .ctor()" attrs="6278">
+        <size>7</size>
+      </method>
+    </type>
+    <type name="Parent">
+      <method name="System.String get_Property()" attrs="2500">
+        <size>14</size>
+      </method>
+      <method name="Void .ctor()" attrs="6278">
+        <size>7</size>
+      </method>
+    </type>
+    <type name="Child">
+      <method name="System.String get_Property()" attrs="2244">
+        <size>14</size>
+      </method>
+      <method name="Void .ctor()" attrs="6278">
+        <size>47</size>
+      </method>
+    </type>
+    <type name="AnotherClass">
+      <method name="Void .ctor()" attrs="6278">
+        <size>7</size>
+      </method>
+    </type>
+  </test>
   <test name="gtest-collectioninit-01.cs">
     <type name="Test">
       <method name="Void TestList(System.Collections.Generic.List`1[System.Int32], Int32)" attrs="145">