In mcs:
[mono.git] / mcs / mcs / anonymous.cs
index 74c4c76f4dbc8e9fd39977310544f15b522aec84..7aead944f6c58c8c825f81972ce96f4985184b3e 100644 (file)
@@ -77,22 +77,18 @@ namespace Mono.CSharp {
                        //
                        // The order is important: this setups the CaptureContext tree hierarchy.
                        //
+                       if (container == null) {
+                               Report.Error (1706, l, "Anonymous methods are not allowed in attribute declaration");
+                               return;
+                       }
                        container.SetHaveAnonymousMethods (l, this);
                        block.SetHaveAnonymousMethods (l, this);
                }
 
                protected AnonymousContainer (Parameters parameters, ToplevelBlock container,
-                                             Location l)
+                                             Location l):
+                       this (parameters, container, new ToplevelBlock (container, parameters, l), l)
                {
-                       Parameters = parameters;
-                       Block = new ToplevelBlock (container, Parameters, l);
-                       loc = l;
-
-                       //
-                       // The order is important: this setups the CaptureContext tree hierarchy.
-                       //
-                       container.SetHaveAnonymousMethods (loc, this);
-                       Block.SetHaveAnonymousMethods (loc, this);
                }
 
                public override Expression DoResolve (EmitContext ec)