Add more incomplete statements to AST. Fixes #4361.
[mono.git] / mcs / mcs / method.cs
index f40efb93aa04fdb2cd645fca95c652457f0c2753..b00f3f0bc070abffdff2e929894e7c3ac819c229 100644 (file)
@@ -19,6 +19,7 @@ using System.Security.Permissions;
 using System.Text;
 using System.Linq;
 using Mono.CompilerServices.SymbolWriter;
+using System.Runtime.CompilerServices;
 
 #if NET_2_1
 using XmlElement = System.Object;
@@ -533,10 +534,13 @@ namespace Mono.CSharp {
                        }
 
                        if (a.Type == pa.MethodImpl) {
-                               is_external_implementation = a.IsInternalCall ();
-                       }
+                               if ((ModFlags & Modifiers.ASYNC) != 0 && (a.GetMethodImplOptions () & MethodImplOptions.Synchronized) != 0) {
+                                       Report.Error (4015, a.Location, "`{0}': Async methods cannot use `MethodImplOptions.Synchronized'",
+                                               GetSignatureForError ());
+                               }
 
-                       if (a.Type == pa.DllImport) {
+                               is_external_implementation = a.IsInternalCall ();
+                       } else if (a.Type == pa.DllImport) {
                                const Modifiers extern_static = Modifiers.EXTERN | Modifiers.STATIC;
                                if ((ModFlags & extern_static) != extern_static) {
                                        Report.Error (601, a.Location, "The DllImport attribute must be specified on a method marked `static' and `extern'");
@@ -633,7 +637,7 @@ namespace Mono.CSharp {
                        if ((ModFlags & Modifiers.PARTIAL) != 0) {
                                for (int i = 0; i < parameters.Count; ++i) {
                                        IParameterData p = parameters.FixedParameters [i];
-                                       if (p.ModFlags == Parameter.Modifier.OUT) {
+                                       if ((p.ModFlags & Parameter.Modifier.OUT) != 0) {
                                                Report.Error (752, Location, "`{0}': A partial method parameters cannot use `out' modifier",
                                                        GetSignatureForError ());
                                        }
@@ -888,7 +892,7 @@ namespace Mono.CSharp {
 
                        var ac = parameters.Types [0] as ArrayContainer;
                        return ac != null && ac.Rank == 1 && ac.Element.BuiltinType == BuiltinTypeSpec.Type.String &&
-                                       (parameters[0].ModFlags & ~Parameter.Modifier.PARAMS) == Parameter.Modifier.NONE;
+                                       (parameters[0].ModFlags & Parameter.Modifier.RefOutMask) == 0;
                }
 
                public override FullNamedExpression LookupNamespaceOrType (string name, int arity, LookupMode mode, Location loc)
@@ -936,7 +940,7 @@ namespace Mono.CSharp {
                                }
 
                                for (int i = 0; i < parameters.Count; ++i) {
-                                       if (parameters.FixedParameters [i].ModFlags == Parameter.Modifier.OUT) {
+                                       if ((parameters.FixedParameters [i].ModFlags & Parameter.Modifier.OUT) != 0) {
                                                Report.Error (685, Location, "Conditional method `{0}' cannot have an out parameter", GetSignatureForError ());
                                                return;
                                        }
@@ -1192,7 +1196,7 @@ namespace Mono.CSharp {
                                                Report.Error (1983, Location, "The return type of an async method must be void, Task, or Task<T>");
                                        }
 
-                                       AsyncInitializer.Create (this, block, parameters, Parent.PartialContainer, ReturnType, Location);
+                                       block = (ToplevelBlock) block.ConvertToAsyncTask (this, Parent.PartialContainer, parameters, ReturnType, Location);
                                        ModFlags |= Modifiers.DEBUGGER_HIDDEN;
                                }
                        }
@@ -1699,6 +1703,11 @@ namespace Mono.CSharp {
                        return null;
                }
 
+               public override string GetCallerMemberName ()
+               {
+                       return IsStatic ? TypeConstructorName : ConstructorName;
+               }
+
                public override string GetSignatureForDocumentation ()
                {
                        return Parent.GetSignatureForDocumentation () + ".#ctor" + parameters.GetSignatureForDocumentation ();
@@ -2236,11 +2245,6 @@ namespace Mono.CSharp {
                        }
                }
 
-               public bool IsExcluded ()
-               {
-                       return false;
-               }
-
                public MemberName MethodName {
                        get {
                                return MemberName;
@@ -2347,6 +2351,11 @@ namespace Mono.CSharp {
                        return false;
                }
 
+               public override string GetCallerMemberName ()
+               {
+                       return base.GetCallerMemberName ().Substring (prefix.Length);
+               }
+
                public override string GetSignatureForDocumentation ()
                {
                        // should not be called