diff options
author | Marek Safar <marek.safar@gmail.com> | 2017-08-04 01:24:38 +0300 |
---|---|---|
committer | Marek Safar <marek.safar@gmail.com> | 2017-08-04 16:18:49 +0300 |
commit | c97a3fcfd26e9aecac9f695e993064b213080f62 (patch) | |
tree | 93f0a4a558060ef02c9f5f5c2209dbaa887f8c30 /mcs | |
parent | 3acee7af00ae05348ab663e6702d298bd071ce55 (diff) |
[mcs] Pending implementation of accessors cannot hide base implementation with different member type
Diffstat (limited to 'mcs')
-rw-r--r-- | mcs/mcs/pending.cs | 11 | ||||
-rw-r--r-- | mcs/tests/test-947.cs | 29 | ||||
-rw-r--r-- | mcs/tests/ver-il-net_4_x.xml | 33 |
3 files changed, 69 insertions, 4 deletions
diff --git a/mcs/mcs/pending.cs b/mcs/mcs/pending.cs index 507b937e2c9..1de765fb4ac 100644 --- a/mcs/mcs/pending.cs +++ b/mcs/mcs/pending.cs @@ -545,12 +545,15 @@ namespace Mono.CSharp { if (new_implementation) { MemberFilter filter; - if (mi.Parameters.Count > 1) { - var indexer_params = mi.Name [0] == 'g' ? mi.Parameters : IndexerSpec.CreateParametersFromSetter (mi, mi.Parameters.Count - 1); - filter = new MemberFilter (MemberCache.IndexerNameAlias, 0, MemberKind.Indexer, indexer_params, null); + bool getter = mi.Name [0] == 'g'; + if (mi.Parameters.Count > (getter ? 0 : 1)) { + var indexer_params = getter ? mi.Parameters : IndexerSpec.CreateParametersFromSetter (mi, mi.Parameters.Count - 1); + var ptype = getter ? mi.ReturnType : mi.Parameters.Types [mi.Parameters.Count - 1]; + filter = new MemberFilter (MemberCache.IndexerNameAlias, 0, MemberKind.Indexer, indexer_params, ptype); } else { var pname = mi.Name.Substring (4); - filter = MemberFilter.Property (pname, null); + var ptype = getter ? mi.ReturnType : mi.Parameters.Types [0]; + filter = MemberFilter.Property (pname, ptype); } var prop = MemberCache.FindMember (container.CurrentType, filter, BindingRestriction.DeclaredOnly | BindingRestriction.InstanceOnly); diff --git a/mcs/tests/test-947.cs b/mcs/tests/test-947.cs new file mode 100644 index 00000000000..f2f8cbb8628 --- /dev/null +++ b/mcs/tests/test-947.cs @@ -0,0 +1,29 @@ +interface IA +{ + int Prop { get; } + int this [int arg] { get; } +} + +abstract class B : IA +{ + public long Prop => 4; + + int IA.Prop => 1; + + public long this [int arg] => 2; + + int IA.this [int arg] => 4; +} + +class C : B, IA +{ + public static void Main () + { + } + + public new string Prop { + get { return ""; } + } + + public new string this [int arg] => "2"; +}
\ No newline at end of file diff --git a/mcs/tests/ver-il-net_4_x.xml b/mcs/tests/ver-il-net_4_x.xml index 460fe02f0e1..c0c676d6cde 100644 --- a/mcs/tests/ver-il-net_4_x.xml +++ b/mcs/tests/ver-il-net_4_x.xml @@ -52770,6 +52770,39 @@ </method> </type> </test> + <test name="test-947.cs"> + <type name="B"> + <method name="Int64 get_Prop()" attrs="2182"> + <size>10</size> + </method> + <method name="Int32 IA.get_Prop()" attrs="2529"> + <size>9</size> + </method> + <method name="Int64 get_Item(Int32)" attrs="2182"> + <size>10</size> + </method> + <method name="Int32 IA.get_Item(Int32)" attrs="2529"> + <size>9</size> + </method> + <method name="Void .ctor()" attrs="6276"> + <size>7</size> + </method> + </type> + <type name="C"> + <method name="Void Main()" attrs="150"> + <size>2</size> + </method> + <method name="System.String get_Prop()" attrs="2182"> + <size>14</size> + </method> + <method name="System.String get_Item(Int32)" attrs="2182"> + <size>13</size> + </method> + <method name="Void .ctor()" attrs="6278"> + <size>7</size> + </method> + </type> + </test> <test name="test-95.cs"> <type name="X"> <method name="Int32 Main()" attrs="150"> |