Fully resolve extension method argument. Fixes #11213
authorMarek Safar <marek.safar@gmail.com>
Mon, 18 Mar 2013 09:57:04 +0000 (10:57 +0100)
committerMarek Safar <marek.safar@gmail.com>
Mon, 18 Mar 2013 09:57:04 +0000 (10:57 +0100)
mcs/errors/cs0154-5.cs [new file with mode: 0644]
mcs/mcs/ecore.cs

diff --git a/mcs/errors/cs0154-5.cs b/mcs/errors/cs0154-5.cs
new file mode 100644 (file)
index 0000000..21f55ce
--- /dev/null
@@ -0,0 +1,19 @@
+// CS0154: The property or indexer `BugReport.MyProperty' cannot be used in this context because it lacks the `get' accessor
+// Line: 16
+
+static class BugReport
+{
+       static float MyProperty {
+               set { }
+       }
+
+       static void MyExtension (this float val)
+       {
+       }
+
+       public static void Main ()
+       {
+               MyProperty.MyExtension ();
+       }
+}
+
index ee025092c4411518faece3de3eb6a921000ffa94..e8bd8554dcd23882a08ba5ec0c7a8547a430aa7d 100644 (file)
@@ -3244,7 +3244,7 @@ namespace Mono.CSharp {
        class ExtensionMethodGroupExpr : MethodGroupExpr, OverloadResolver.IErrorHandler
        {
                ExtensionMethodCandidates candidates;
-               public readonly Expression ExtensionExpression;
+               public Expression ExtensionExpression;
 
                public ExtensionMethodGroupExpr (ExtensionMethodCandidates candidates, Expression extensionExpr, Location loc)
                        : base (candidates.Methods.Cast<MemberSpec>().ToList (), extensionExpr.Type, loc)
@@ -3288,6 +3288,10 @@ namespace Mono.CSharp {
                        if (arguments == null)
                                arguments = new Arguments (1);
 
+                       ExtensionExpression = ExtensionExpression.Resolve (ec);
+                       if (ExtensionExpression == null)
+                               return null;
+
                        arguments.Insert (0, new Argument (ExtensionExpression, Argument.AType.ExtensionType));
                        var res = base.OverloadResolve (ec, ref arguments, ehandler ?? this, restr);