diff options
author | Marek Safar <marek.safar@gmail.com> | 2015-06-19 12:43:16 +0300 |
---|---|---|
committer | Marek Safar <marek.safar@gmail.com> | 2015-06-19 12:46:55 +0300 |
commit | 106e71e2c8902449bcf6657776523c6c4644519d (patch) | |
tree | 34f1e2a5beef62a4dfc48f7a0e7446c1fd0414e0 /mcs | |
parent | acd63c6a96af8d73c141060e8f0feaa8f7c5d6dc (diff) |
[mcs] Implements virtual read-only auto-property assignment via derived private field
Diffstat (limited to 'mcs')
-rw-r--r-- | mcs/mcs/ecore.cs | 8 | ||||
-rw-r--r-- | mcs/tests/gtest-autoproperty-19.cs | 23 | ||||
-rw-r--r-- | mcs/tests/ver-il-net_4_5.xml | 21 |
3 files changed, 52 insertions, 0 deletions
diff --git a/mcs/mcs/ecore.cs b/mcs/mcs/ecore.cs index 74501e89b15..f34ba17146d 100644 --- a/mcs/mcs/ecore.cs +++ b/mcs/mcs/ecore.cs @@ -7036,6 +7036,14 @@ namespace Mono.CSharp { if (!rc.HasSet (ResolveContext.Options.ConstructorScope)) return false; + if (prop.Parent.PartialContainer != rc.CurrentMemberDefinition.Parent.PartialContainer) { + var ps = MemberCache.FindMember (rc.CurrentType, MemberFilter.Property (prop.ShortName, prop.MemberType), BindingRestriction.DeclaredOnly) as PropertySpec; + if (ps == null) + return false; + + prop = (Property) ps.MemberDefinition; + } + var spec = prop.BackingField; if (spec == null) return false; diff --git a/mcs/tests/gtest-autoproperty-19.cs b/mcs/tests/gtest-autoproperty-19.cs new file mode 100644 index 00000000000..58f9d0f037b --- /dev/null +++ b/mcs/tests/gtest-autoproperty-19.cs @@ -0,0 +1,23 @@ +abstract class Node +{ + public virtual int Next { get; } +} + +class NodeLinked : Node +{ + public NodeLinked (int next) + { + this.Next = next; + } + + public override int Next { get; } + + public static int Main () + { + var nl = new NodeLinked (5); + if (nl.Next != 5) + return 1; + + return 0; + } +} diff --git a/mcs/tests/ver-il-net_4_5.xml b/mcs/tests/ver-il-net_4_5.xml index f14709cfc33..7bc1d30af96 100644 --- a/mcs/tests/ver-il-net_4_5.xml +++ b/mcs/tests/ver-il-net_4_5.xml @@ -20689,6 +20689,27 @@ </method> </type> </test> + <test name="gtest-autoproperty-19.cs"> + <type name="Node"> + <method name="Int32 get_Next()" attrs="2502"> + <size>14</size> + </method> + <method name="Void .ctor()" attrs="6276"> + <size>7</size> + </method> + </type> + <type name="NodeLinked"> + <method name="Int32 get_Next()" attrs="2246"> + <size>14</size> + </method> + <method name="Int32 Main()" attrs="150"> + <size>36</size> + </method> + <method name="Void .ctor(Int32)" attrs="6278"> + <size>15</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"> |