Implemented PipeSecurity. GetAccessControl, SetAccessControl, and ACL-containing...
[mono.git] / mcs / mcs / method.cs
index b00f3f0bc070abffdff2e929894e7c3ac819c229..8c96171696e8442fb5c800b8b729527b7edff5a2 100644 (file)
@@ -496,6 +496,20 @@ namespace Mono.CSharp {
                                missing.AddRange (m);
                        }
 
+                       if (Arity > 0) {
+                               foreach (var tp in GenericDefinition.TypeParameters) {
+                                       var m = tp.GetMissingDependencies ();
+
+                                       if (m == null)
+                                               continue;
+
+                                       if (missing == null)
+                                               missing = new List<TypeSpec> ();
+
+                                       missing.AddRange (m);
+                               }
+                       }
+
                        return missing;                 
                }
 
@@ -1199,6 +1213,9 @@ namespace Mono.CSharp {
                                        block = (ToplevelBlock) block.ConvertToAsyncTask (this, Parent.PartialContainer, parameters, ReturnType, Location);
                                        ModFlags |= Modifiers.DEBUGGER_HIDDEN;
                                }
+
+                               if (Compiler.Settings.WriteMetadataOnly)
+                                       block = null;
                        }
 
                        if ((ModFlags & Modifiers.STATIC) == 0)
@@ -1287,10 +1304,18 @@ namespace Mono.CSharp {
                                        }
                                }
 
-                               base.Emit ();
-                               
+                               if (block != null && block.StateMachine != null) {
+                                       var psm = block.StateMachine is IteratorStorey ?
+                                               Module.PredefinedAttributes.IteratorStateMachine :
+                                               Module.PredefinedAttributes.AsyncStateMachine;
+                                       
+                                       psm.EmitAttribute (MethodBuilder, block.StateMachine);
+                               }
+
                                if ((ModFlags & Modifiers.METHOD_EXTENSION) != 0)
                                        Module.PredefinedAttributes.Extension.EmitAttribute (MethodBuilder);
+
+                               base.Emit ();
                        } catch {
                                Console.WriteLine ("Internal compiler error at {0}: exception caught while emitting {1}",
                                                   Location, MethodBuilder);
@@ -1418,8 +1443,7 @@ namespace Mono.CSharp {
                                base_ctor = ConstructorLookup (ec, type, ref argument_list, loc);
                        }
        
-                       // TODO MemberCache: Does it work for inflated types ?
-                       if (base_ctor == caller_builder.Spec){
+                       if (base_ctor != null && base_ctor.MemberDefinition == caller_builder.Spec.MemberDefinition) {
                                ec.Report.Error (516, loc, "Constructor `{0}' cannot call itself",
                                        caller_builder.GetSignatureForError ());
                        }
@@ -1604,10 +1628,15 @@ namespace Mono.CSharp {
                        
                        Parent.MemberCache.AddMember (spec);
                        
-                       // It's here only to report an error
-                       if (block != null && block.IsIterator) {
-                               member_type = Compiler.BuiltinTypes.Void;
-                               Iterator.CreateIterator (this, Parent.PartialContainer, ModFlags);
+                       if (block != null) {
+                               // It's here only to report an error
+                               if (block.IsIterator) {
+                                       member_type = Compiler.BuiltinTypes.Void;
+                                       Iterator.CreateIterator (this, Parent.PartialContainer, ModFlags);
+                               }
+
+                               if (Compiler.Settings.WriteMetadataOnly)
+                                       block = null;
                        }
 
                        return true;
@@ -1643,14 +1672,14 @@ namespace Mono.CSharp {
                        BlockContext bc = new BlockContext (this, block, Compiler.BuiltinTypes.Void);
                        bc.Set (ResolveContext.Options.ConstructorScope);
 
-                       //
-                       // If we use a "this (...)" constructor initializer, then
-                       // do not emit field initializers, they are initialized in the other constructor
-                       //
-                       if (!(Initializer is ConstructorThisInitializer))
-                               Parent.PartialContainer.ResolveFieldInitializers (bc);
-
                        if (block != null) {
+                               //
+                               // If we use a "this (...)" constructor initializer, then
+                               // do not emit field initializers, they are initialized in the other constructor
+                               //
+                               if (!(Initializer is ConstructorThisInitializer))
+                                       Parent.PartialContainer.ResolveFieldInitializers (bc);
+
                                if (!IsStatic) {
                                        if (Initializer == null) {
                                                if (Parent.PartialContainer.Kind == MemberKind.Struct) {
@@ -1951,7 +1980,7 @@ namespace Mono.CSharp {
                                                //
                                                if ((flags & MethodAttributes.MemberAccessMask) != MethodAttributes.Public) {
                                                        implementing = null;
-                                               } else if (optional && (container.Interfaces == null || Array.IndexOf (container.Interfaces, implementing.DeclaringType) < 0)) {
+                                               } else if (optional && (container.Interfaces == null || !container.Definition.Interfaces.Contains (implementing.DeclaringType))) {
                                                        //
                                                        // We are not implementing interface when base class already implemented it
                                                        //
@@ -2137,6 +2166,16 @@ namespace Mono.CSharp {
                        return true;
                }
 
+               public override bool Define ()
+               {
+                       base.Define ();
+
+                       if (Compiler.Settings.WriteMetadataOnly)
+                               block = null;
+
+                       return true;
+               }
+
                public override void Emit()
                {
                        var base_type = Parent.PartialContainer.BaseType;
@@ -2500,13 +2539,18 @@ namespace Mono.CSharp {
                        if (!base.Define ())
                                return false;
 
-                       if (block != null && block.IsIterator) {
-                               //
-                               // Current method is turned into automatically generated
-                               // wrapper which creates an instance of iterator
-                               //
-                               Iterator.CreateIterator (this, Parent.PartialContainer, ModFlags);
-                               ModFlags |= Modifiers.DEBUGGER_HIDDEN;
+                       if (block != null) {
+                               if (block.IsIterator) {
+                                       //
+                                       // Current method is turned into automatically generated
+                                       // wrapper which creates an instance of iterator
+                                       //
+                                       Iterator.CreateIterator (this, Parent.PartialContainer, ModFlags);
+                                       ModFlags |= Modifiers.DEBUGGER_HIDDEN;
+                               }
+
+                               if (Compiler.Settings.WriteMetadataOnly)
+                                       block = null;
                        }
 
                        // imlicit and explicit operator of same types are not allowed