From 25497f5308b801d72fd1e1ed090bf08c42456fb5 Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Fri, 18 Dec 2015 21:12:34 +0100 Subject: [PATCH] [mcs] Propagate null operator flag during standalone to extension methods promotion. Fixes #37080 --- mcs/mcs/ecore.cs | 1 + mcs/tests/test-null-operator-22.cs | 33 ++++++++++++++++++++++++++++++ mcs/tests/ver-il-net_4_x.xml | 29 ++++++++++++++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 mcs/tests/test-null-operator-22.cs diff --git a/mcs/mcs/ecore.cs b/mcs/mcs/ecore.cs index 08bce8a9d70..b74da01e65c 100644 --- a/mcs/mcs/ecore.cs +++ b/mcs/mcs/ecore.cs @@ -4255,6 +4255,7 @@ namespace Mono.CSharp { var emg = new ExtensionMethodGroupExpr (methods, InstanceExpression, loc); emg.SetTypeArguments (rc, type_arguments); + emg.ConditionalAccess = ConditionalAccess; return emg; } diff --git a/mcs/tests/test-null-operator-22.cs b/mcs/tests/test-null-operator-22.cs new file mode 100644 index 00000000000..04115f9385e --- /dev/null +++ b/mcs/tests/test-null-operator-22.cs @@ -0,0 +1,33 @@ +class A +{ + public A this [string arg] { + get { + return new A (); + } + set { + } + } + + public int Count (string a) + { + return 1; + } +} + +static class B +{ + public static string Count (this A arg) + { + return "x"; + } +} + +class X +{ + public static void Main () + { + var a = new A (); + var b = a ["b"]?.Count (); + System.Console.WriteLine (b); + } +} \ 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 d543f197bd7..b2352089203 100644 --- a/mcs/tests/ver-il-net_4_x.xml +++ b/mcs/tests/ver-il-net_4_x.xml @@ -69665,6 +69665,35 @@ + + + + 14 + + + 2 + + + 10 + + + 7 + + + + + 14 + + + + + 41 + + + 7 + + + -- 2.25.1