Merge to GMCS: 40534
authorJambunathan K <jambunathan@mono-cvs.ximian.com>
Sat, 12 Feb 2005 20:23:29 +0000 (20:23 -0000)
committerJambunathan K <jambunathan@mono-cvs.ximian.com>
Sat, 12 Feb 2005 20:23:29 +0000 (20:23 -0000)
svn path=/trunk/mcs/; revision=40556

29 files changed:
mcs/bmcs/AssemblyInfo.cs
mcs/bmcs/ChangeLog
mcs/bmcs/CryptoConvert.cs
mcs/bmcs/README
mcs/bmcs/anonymous.cs
mcs/bmcs/assign.cs
mcs/bmcs/attribute.cs
mcs/bmcs/class.cs
mcs/bmcs/codegen.cs
mcs/bmcs/convert.cs
mcs/bmcs/decl.cs
mcs/bmcs/delegate.cs
mcs/bmcs/doc.cs
mcs/bmcs/driver.cs
mcs/bmcs/ecore.cs
mcs/bmcs/enum.cs
mcs/bmcs/expression.cs
mcs/bmcs/flowanalysis.cs
mcs/bmcs/generic.cs
mcs/bmcs/iterators.cs
mcs/bmcs/location.cs
mcs/bmcs/namespace.cs
mcs/bmcs/parameter.cs
mcs/bmcs/pending.cs
mcs/bmcs/rootcontext.cs
mcs/bmcs/statement.cs
mcs/bmcs/support.cs
mcs/bmcs/tree.cs
mcs/bmcs/typemanager.cs

index c442f03ee4ed364e3a92884c1c511eef4e3d6ee5..3c319bff7aa621ec4a4e09c97dc21251755a25ed 100644 (file)
@@ -1,8 +1,8 @@
 using System.Reflection;
 using System.Runtime.CompilerServices;
 
-[assembly: AssemblyVersion("1.1.2")]
-[assembly: AssemblyTitle ("Mono C# Compiler")]
-[assembly: AssemblyDescription ("Mono C# Compiler with Generics")]
+[assembly: AssemblyVersion("1.1.3")]
+[assembly: AssemblyTitle ("Mono VB.NET Compiler")]
+[assembly: AssemblyDescription ("Mono VB.NET Compiler with Generics")]
 [assembly: AssemblyCopyright ("2001, 2002, 2003 Ximian, Inc.")]
 [assembly: AssemblyCompany ("Ximian, Inc.")]
index 52186c64458c59ae368fc83268ea0da8864089d2..edfa01b5064589ba27e32b4dd091e8ea25a4741f 100644 (file)
@@ -1,3 +1,504 @@
+2005-02-02  Martin Baulig  <martin@ximian.com>
+
+       * delegate.cs (Delegate.DefineType): Report an internal error if
+       TypeManager.multicast_delegate_type is null.  See bug #72015 for
+       details.        
+
+2005-01-29  Miguel de Icaza  <miguel@novell.com>
+
+       * pending.cs: Produce better code (no nops produced by using Ldarg
+       + value).
+       
+       * pending.cs (PendingImplementation.DefineProxy): It was not `arg
+       i - 1' it should be arg + 1.
+
+       Fixes bug #71819.
+       
+2005-01-26  Martin Baulig  <martin@ximian.com>
+
+       * cs-parser.jay (indexer_declarator): Don't report an error if we
+       have type parameters since we can be an explicit interface
+       implementation; fixes #71449.
+
+2005-01-26  Martin Baulig  <martin@ximian.com>
+
+       * class.cs (TypeContainer.AttributeTargets): Return the correct
+       AttributeTargets depending on our `Kind' instead of throwing an
+       exception; fixes #71632.
+
+2005-01-26  Martin Baulig  <martin@ximian.com>
+
+       * delegate.cs (Delegate.DefineType): Correctly define our type
+       parameters.  Fixes #71483.
+
+2005-01-25  Raja R Harinath  <rharinath@novell.com>
+
+       Fix #71602.
+       * expression.cs (MemberAccess.DoResolve): Don't complain with
+       cs0572 when the LHS of a member access has identical name and type
+       name.
+
+2005-01-25  Marek Safar  <marek.safar@seznam.cz>
+
+       Fix #71651, #71675
+       * attribute.cs (ExtractSecurityPermissionSet): Catch exceptions from
+       CreatePermission.
+       Create custom PermissionSet only for PermissionSetAttribute.
+
+2005-01-24  Marek Safar  <marek.safar@seznam.cz>
+
+       Fix #71649
+       * class.cs (StaticClass.DefineContainerMembers): Enable enums and
+       delegates in static class.
+
+2005-01-24  Martin Baulig  <martin@ximian.com>
+
+       * flowanalysis.cs (FlowBranching.UsageVector.MergeChild): If we're
+       merging an implicit block, just use its reachability.
+
+       * statement.cs (Block.Resolve): Make the unreachable code check
+       work wrt. implicit blocks; see test-337 from #63842.
+
+2005-01-21  Alp Toker  <alp@atoker.com>
+       * cs-parser.jay: destructor_declaration's container is PartialContainer
+       not Class when partial types are used, so use Kind prop instead of
+       'is'.
+       
+2005-01-22  Miguel de Icaza  <miguel@ximian.com>
+
+       * cs-parser.jay: Improve error reporting when an interface
+       declares new types.
+
+2005-01-20  Dick Porter  <dick@ximian.com>
+
+       * support.cs: SeekableStreamReader fix from Sandor Dobos
+       (dobos_s@ibcnet.hu) to cope with Position setting when multibyte
+       chars are read.  Fixes bug 70369.
+
+2005-01-20  Raja R Harinath  <rharinath@novell.com>
+
+       * cs-parser.jay (catch_clause): Simplify current_block handling
+       somewhat.
+
+2005-01-17  Miguel de Icaza  <miguel@ximian.com>
+
+       * convert.cs (ImplicitStandardConversionExists): Synchronize the
+       code with ImplicitStandardConversion to handle the implicit
+       conversion of method groups into valid delegate invocations. 
+
+       The problem is that in parameter handling we were using this code
+       path.  Fixes bug #64698
+
+2005-01-19  Raja R Harinath  <rharinath@novell.com>
+
+       * cs-parser.jay: Fix several infelicities.
+       - Avoid assigning to the parser value stack.  Code like 
+         '$3 = null' is unclean.  Synthesize a value for the code block
+         instead. 
+       - Avoid using oob_stack for storing location information.  Use ...
+       (_mark_): ... this.  New (empty) rule.  Saves the current location
+       in $$.
+       (foreach_statement): Avoid using oob_stack for current_block
+       handling.  Use technique used in for_statement and
+       using_statement.  Synthesize a value for the code block to store
+       additional intermediate information.
+
+2005-01-13  Miguel de Icaza  <miguel@ximian.com>
+
+       * ecore.cs (IsAccessorAccessible): Accessibility to private fields
+       of a different type is only allowed to private fields of a
+       containing type, not on fields of a base class.
+
+       See test-174.cs and error cs0122-9.cs
+
+2005-01-13  Raja R Harinath  <rharinath@novell.com>
+
+       Fix test-335.cs (bug #58126).
+       * cs-parser.jay (argument): Split out non-expression parts of the
+       rule into 'non_simple_argument'.
+       (invocation_expression): Support parenthesized invocations with
+       multiple arguments, and with single non-simple arguments.
+
+2005-01-13  Raja R Harinath  <rharinath@novell.com>
+
+       * cs-tokenizer.cs (xtoken): Reset 'comments_seen' in a couple more
+       places.
+
+2005-01-12  Raja R Harinath  <rharinath@novell.com>
+
+       Fix cs0038-1.cs, cs1640-6.cs.
+       * ecore.cs (Expression.Resolve): Remove special-case for
+       SimpleName in error-handling.
+       (Expression.almostMatchedMembers): Relax access permission to
+       protected.
+       (Expression.MemberLookupFailed): Handle duplicates in
+       almostMatchedMembers list.
+       (SimpleName.DoSimpleNameResolve): Catch CS0038 errors earlier.
+       * expression.cs (New.DoResolve): Report CS1540 for more cases.
+       * typemanager.cs (GetFullNameSignature): Use the MethodBase
+       overload if the passed in MemberInfo is a MethodBase.
+
+2005-01-25  Martin Baulig  <martin@ximian.com>
+
+       * doc.cs
+       (DocUtil.emptyParamList): Removed; use `Type.EmptyTypes' instead.
+
+2005-01-12  Marek Safar  <marek.safar@seznam.cz>
+
+       Fix #70749
+       * attribute.cs (ExtractSecurityPermissionSet): Don't report error
+       for non-CAS & merge permission sets properly.
+
+2005-01-11  Raja R Harinath  <rharinath@novell.com>
+
+       Improve standard-compliance of simple name and member access 
+       resolution.  Fixes bugs #52697, #57200, #67520, #69519.
+       * ecore.cs (FullNamedExpression): New abstract base class 
+       for Namespaces and TypeExpressions.
+       (ResolveFlags.SimpleName): Remove.
+       (SimpleName): Remove support for dotted names.
+       (SimpleName.ResolveAsTypeStep): Simplify.  Now just a wrapper to 
+       DeclSpace.FindType and DeclSpace.LookupType.
+       (SimpleName.DoSimpleNameResolve): Remove support for dotted names.
+       (Expression.ExprClassName): Make member function.
+       * expression.cs (MemberAccess.ResolveAsTypeStep): Support LHS being
+       a namespace.  Remove creation of dotted "SimpleName"s.
+       (MemberAccess.DoResolve): Likewise.
+       * decl.cs (DeclSpace.Cache): Make private.
+       (DeclSpace.LookupInterfaceOrClass): Return a FullNamedExpression.
+       (DeclSpace.FindType): Update.
+       (DeclSpace.LookupType): Move here from RootContext.  Return a 
+       FullNamedExpression.
+       * namespace.cs (Namespace): Derive from FullNamedExpression
+       so that it can be part of expression resolution.
+       (Namespace.Lookup): Return an FullNamedExpression.
+       (NamespaceEntry.LookupAlias): Lookup aliases only in current
+       namespace.
+       * rootcontext.cs (NamespaceLookup): Remove.
+       (LookupType): Move to DeclSpace.
+       * attribute.cs (CheckAttributeType): Update.
+       * doc.cs (FindDocumentedType): Remove allowAlias argument.
+       (FindDocumentedTypeNonArray): Likewise.
+
+2005-01-11  Raja R Harinath  <rharinath@novell.com>
+
+       Fix cs0509.cs, cs1632.cs.
+       * class.cs (TypeContainer.GetNormalBases): Don't assume !IsClass
+       is the same as IsInterface.
+       (TypeContainer.GetClassBases): Likewise.
+       * statement.cs (LabeledStatement.ig): New field.
+       (LabeledStatement.LabelTarget): Save ILGenerator which created the
+       label.
+       (LabeledStatement.DoEmit): Check that the label was created with
+       the same ILGenerator.
+
+2005-01-10  Marek Safar  <marek.safar@seznam.cz>
+
+       Fix #71058
+       * attribute.cs (GetMethodObsoleteAttribute): Need to transform
+       accessors to its properties.
+
+       * ecore.cs (PropertyExpr): Add AccessorTable to help track back
+       from accessors to property.
+       
+2005-01-10  Marek Safar  <marek.safar@seznam.cz>
+
+       Fix #70722
+       * class.cs (MethodCore.CheckBase): Test base method obsoleteness
+       only for overrides.
+       
+2005-01-08  Miguel de Icaza  <miguel@ximian.com>
+
+       * attribute.cs: Check for null and empty strings.  
+
+       I have lost another battle to Paolo.
+
+2005-01-07  Marek Safar  <marek.safar@seznam.cz>
+
+       Fix #70942
+       * class.cs (PropertyMethod): Set Parent field in ctors.
+       (SetMethod.InternalParameters): Add unsafe switch hack.
+       Override MarkForDuplicationCheck where it is appropriate.
+
+       * decl.cs (MemberCore.MarkForDuplicationCheck): New method.
+       It says whether container allows members with the same name.
+       Base default is no.
+       (DeclSpace.AddToContainer): Use MarkForDuplicationCheck.
+       Removed is_method parameter.
+
+2005-01-06  Duncan Mak  <duncan@ximian.com>
+
+       * cs-tokenizer.cs (xtoken): Redo the work for signaling CS1040
+       because the previous change led to incorrect reporting of CS1032
+       ("Cannot define/undefine preprocessor symbols after first token in
+       file"). Instead of using `tokens_seen' as the only flag that
+       triggers CS1040, introduce `comments_seen'. This new flag is used
+       to signify having seen comments on the current line, so it is
+       unset after a newline.
+
+2005-01-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * doc.cs : When searching for a type, find nested type too.
+         This fixes bug #71040.
+
+2005-01-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * doc.cs :
+         - Warn missing member comment on those classes which also does not
+           have doc comments. Fixed bug #71041.
+         - Don't warn missing doc comment on default constructor.
+           Fixed bug #71042.
+
+2005-01-06  Duncan Mak  <duncan@ximian.com>
+
+       * cs-tokenizer.cs (xtoken): After handling traditional C-style
+       comments, set `tokens_seen' to true. This allows us to detect
+       misplaced preprocessor directives (i.e. not at the beginning of
+       the a line, nor after whitespaces). In that case, report error
+       CS1040. This fixes bug #56460.
+
+       * cs-parser.jay (interface_member_declaration): Add checks for
+       IsExplicitImpl, and report CS0541 error if an interface member is
+       defined as an explicit interface declaration.
+
+2005-01-06  Marek Safar  <marek.safar@seznam.cz>
+
+       Fix #70817
+       * class.cs (PropertyMethod): Set Parent field in ctors.
+       (SetMethod.InternalParameters): Add unsafe switch hack.
+       
+       * decl.cs (MemberCore.Parent): Cannot be readonly.
+
+2005-01-06  Raja R Harinath  <rharinath@novell.com>
+
+       * decl.cs (DeclSpace.ResolveType): Remove.
+       (DeclSpace.ResolveBaseTypeExpr): Rename from ResolveTypeExpr.
+       Merge in code from ...
+       (DeclSpace.GetTypeResolvingEmitContext): ... here.  Remove.
+       * class.cs, enum.cs: Update to changes.
+
+2005-01-06  Miguel de Icaza  <miguel@ximian.com>
+
+       * anonymous.cs: Ensure that we init the scope of our parent if it
+       has not been initialized yet.
+
+2004-12-30  Duncan Mak  <duncan@ximian.com>
+
+       * typemanager.cs (TypeManager.CheckStructCycles): Don't crash here
+       if field.FieldBuilder is null. Fixes #70758.
+
+       * convert.cs: Fixed some typos and updated some of the comments.
+       (ImplicitStandardConversionExists):
+       (TryImplicitIntConversion): If `target_type' is an interface and
+       the type of `ic' implements this interface, return true or a new
+       BoxedCast instead of null. This fixes #70468.
+
+2004-12-29  Duncan Mak  <duncan@ximian.com>
+
+       * expression.cs (Argument.Emit): Check that Expr is
+       IMemoryLocation before casting to it, and report CS1510 otherwise.
+
+       This fixes #70402.
+
+2004-12-21  Ben Maurer  <bmaurer@ximian.com>
+
+       * statement.cs (Block.ThisVariable): remove the recursion here, to
+       make the --profile more sane.
+
+2004-12-17  Carlos Cortez <calberto.cortez@gmail.com>
+
+       * driver.cs: Patch to handle a xsp bug that prevents to reference an .exe
+       assembly, by JB Evain.
+
+2004-12-17  Raja R Harinath  <rharinath@novell.com>
+
+       * class.cs, decl.cs, ecore.cs, iterators.cs, pending.cs, 
+         rootcontext.cs, typemanager.cs: Make nomenclature consistent.
+       "parent" refers to enclosing type/class.  "base" refers to superclass.
+
+2004-12-17  Raja R Harinath  <rharinath@novell.com>
+
+       * codegen.cs (CommonAssemblyModulClass.GetClsCompliantAttribute):
+       Ensure that we only have GlobalAttributes.
+       * attribute.cs (Attribute.Emit): Make non-virtual.
+       (GlobalAttribute.Emit): Remove.
+       (Attribute.Resolve): Make virtual.
+       (GlobalAttribute.Resolve): New.  Set Rootcontext.Tree.Types.NamespaceEntry.
+       (Attribute.GetConditionalAttributeValue): Take an EmitContext as
+       the argument. Don't create one.
+       (Attribute.GetObsoleteAttribute): Likewise.
+       (Attribute.GetClsCompliantAttributeValue): Likewise.
+       * class.cs, decl.cs: Update to changes.
+
+2004-12-17  Marek Safar  <marek.safar@seznam.cz>
+
+       * delegate.cs (NewDelegate.DoResolve): Add error 149 report.
+       
+       * ecore.cs (Expression.MemberLookupFailed): Fixed error 143.
+       
+       * statement.cs (Foreach.Resolve): Add error 186 report.
+
+2004-12-16  Marek Safar  <marek.safar@seznam.cz>
+
+       * expression.cs (Conditional.DoResolve): Add warning 429.
+       
+       * statement.cs (If.Resolve): Add warning 665.
+
+2004-12-16  Raja R Harinath  <rharinath@novell.com>
+
+       New invariant: RootContext.Tree.Types.NamespaceEntry == null
+       except when in the parser, and in GlobalAttribute.
+       * driver.cs (MainDriver): Reset RootContext.Tree.Types.NamespaceEntry.
+       * attribute.cs (GlobalAttribute.CheckAttributeType): Reset
+       RootContext.Tree.Types.NamespaceEntry once work is done.
+       (GlobalAttribute.Emit): New.  Wrapper for Attribute.Emit, but sets
+       and resets RootContext.Tree.Types.NamespaceEntry.
+
+2004-12-15  Marek Safar  <marek.safar@seznam.cz>
+
+       * cs-parser.jay: Don't create a block for every variable.
+
+2004-12-14  Miguel de Icaza  <miguel@ximian.com>
+
+       * location.cs: Provide extra information.
+
+       * statement.cs: The instance is not `ldarg_0.THIS' when accessing
+       variables from the captured environment, it is the ldarg_0.
+
+2004-12-14  Marek Safar  <marek.safar@seznam.cz>
+
+       * cs-parser.jay: Changed warning level for 642 to 4 until Miguel
+       find a conclusion.
+       
+       * class.cs: Changed warning level for 169 to avoid developer
+       displeasure from warning flooding. It will be changed back when they
+       fix most of current BCL warnings.
+       
+       * RootContext.cs: Pushed default WarningLevel to 3.
+       
+       * statement.cs: Removed unused variable.
+
+2004-12-14  Marek Safar  <marek.safar@seznam.cz>
+
+       * class.cs (TypeContainer.GetClassBases): Add error 1521 report.
+       (TypeContainer.MethodModifiersValid): Refactored to use MemberCore.
+       Add error 502 report.
+       (StaticClass.DefineType): Add error 441 report.
+       (Class.AllowedModifiersProp): New virtual property as temporary
+       extension to AllowedModifiers.
+       (Class.DefineType): Add error 418 report. Moved ModFlags check here
+       to share implementation with StaticClass and don't call virtual
+       methods from ctor.
+       
+       * driver.cs (MainDriver): Add error 1558 test.
+
+       * parameter.cs (Parameter.ApplyAttributeBuilder): Add error 662
+       report. Moved error 36 test here.
+
+       * statement.cs (Throw.Resolve): Add error 724 report.
+
+       * typemanager.cs: Add out_attribute_type core type.
+       
+2004-12-13  Marek Safar  <marek.safar@seznam.cz>
+
+       * class.cs (TypeContainer.VerifyClsCompliance): Add error
+       3018 report.
+       (PropertyBase.VerifyClsCompliance): Add errror 3025 report.
+
+       * codegen.cs (ModuleClass.ApplyAttributeBuilder): Add error
+       3017 report.
+       
+       * decl.cs (MemberCore.VerifyClsCompliance): Add warning 3021.
+
+       * parameter.cs (ReturnParameter.ApplyAttributeBuilder): 
+       Add error 3023 report.
+       (Parameter.ApplyAttributeBuilder): Add error 3022 report.
+
+       * tree.cs (RootTypes.IsClsCompliaceRequired): Add fake
+       implementation.
+
+2004-12-12  John Luke  <john.luke@gmail.com>
+
+       * driver.cs (AddArgs): take -- into account when
+       adding arguments, fixes bug 65710 
+
+2004-12-12  Martin Baulig  <martin@ximian.com>
+
+       * expression.cs (Unary.TryReduceNegative): Added support for
+       SByteConstant and ByteConstant.
+       (Unary.Reduce): Check error values from TryReduceNegative().
+
+2004-12-10  Marek Safar  <marek.safar@seznam.cz>
+
+       * attributes.cs (Attribute.Resolve): Avoid multiple error report
+       and report exception as error 182.
+
+2004-12-10  Raja R Harinath  <rharinath@novell.com>
+
+       * driver.cs (Main): Fix message when there are warnings.
+
+2004-12-09  Miguel de Icaza  <miguel@ximian.com>
+
+       * delegate.cs: Fixed my fix from yesterday, sorry about that.
+
+2004-12-09  Marek Safar  <marek.safar@seznam.cz>
+
+       * anonymous.cs, class.cs, convert.cs, doc.cs, support.cs: 
+       Reduced number of warnings.
+       
+       * class.cs (TypeContainer.VerifyClsCompliance): One if is enough.
+
+2004-12-08  Miguel de Icaza  <miguel@ximian.com>
+
+       * driver.cs: Removed message.
+
+       * delegate.cs: Fix bug introduced in 1.1.x: 70219.
+
+2004-12-08    <vargaz@freemail.hu>
+
+       * cs-tokenizer.cs: Add workaround for NET 2.0 beta 1 csc bug.
+
+2004-12-08  Martin Baulig  <martin@ximian.com>
+
+       * class.cs (TypeContainer.VerifyClsCompliance): Report a CS3003
+       instead of a CS3002 for properties and indexer.
+
+2004-12-08  Martin Baulig  <martin@ximian.com>
+
+       * decl.cs (MemberName.ToString): Make this work again.
+
+2004-12-08  Marek Safar  <marek.safar@seznam.cz>
+
+       * attribute.cs (Resolve): Add error 591 detection.
+
+       * class.cs (FieldMember.Define): Add error 1547 detection.
+       (Indexer.Define): Add error 620 detection.
+       (Operator.Define): Add error 590 detection.
+
+       * ecore.cs: Missing argument for error 79.
+
+       * expression.cs (ComposedCast.DoResolveAsTypeStep): Add error 611
+       detection.
+
+2004-12-07  Marek Safar  <marek.safar@seznam.cz>
+
+       Fix #70106
+       * assign.cs.cs (Assign.DoResolve): Reports error 1648 for value types
+       only.
+
+2004-12-07  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * cs-parser.jay : handle doc comments on implicit/explicit operators.
+         Some operator comments were suppressed.
+       * doc.cs : Implicit/explicit operator name in doc comments are like
+         "op_Explicit(type)~returnType", so added suffix handling.
+
+2005-01-21  Alp Toker  <alp@atoker.com>
+
+       * cs-parser.jay: destructor_declaration's container is PartialContainer
+       not Class when partial types are used, so use Kind prop instead of 'is'.
+
 2004-12-12  Martin Baulig  <martin@ximian.com>
 
        * expression.cs (Unary.TryReduceNegative): Added support for
index 058fe0917304ca04d17f8e20d35e8c2add3270a4..a0becc12bbb73227429334e3dde378a4378dab9e 100644 (file)
@@ -82,7 +82,7 @@ namespace Mono.Security.Cryptography {
                                        throw new CryptographicException ("Invalid blob header");
                                
                                // ALGID (CALG_RSA_SIGN, CALG_RSA_KEYX, ...)
-                               int algId = ToInt32LE (blob, offset+4);
+                               // int algId = ToInt32LE (blob, offset+4);
 
                                // DWORD bitlen
                                int bitLen = ToInt32LE (blob, offset+12);
@@ -245,7 +245,7 @@ namespace Mono.Security.Cryptography {
                                        throw new CryptographicException ("Invalid blob header");
 
                                // ALGID (CALG_RSA_SIGN, CALG_RSA_KEYX, ...)
-                               int algId = ToInt32LE (blob, offset+4);
+                               // int algId = ToInt32LE (blob, offset+4);
 
                                // DWORD bitlen
                                int bitLen = ToInt32LE (blob, offset+12);
@@ -356,7 +356,7 @@ namespace Mono.Security.Cryptography {
                        if (rsa == null)
                                throw new ArgumentNullException ("rsa");
 
-                       RSAParameters p = rsa.ExportParameters (includePrivateKey);
+                       rsa.ExportParameters (includePrivateKey);
                        if (includePrivateKey)
                                return ToCapiPrivateKeyBlob (rsa);
                        else
index 0b2ee6af3f0a682426ce27d872e50d3557646301..cc9da5dc0dd4196555de92428bbde2f87aae5eca 100644 (file)
@@ -1,6 +1,6 @@
 * This is BMCS
 
-       Last merge to GMCS: 38733
+       Last merge to GMCS: 40534
 
        BMCS is a new fork of the generics compiler from revision
        38733 (11th of January 2005).  
index d0fa55e555d3de659e730d9e56f16e73ba4c43a8..27427df4645c76063b751132693208e646d8110c 100644 (file)
@@ -510,7 +510,6 @@ namespace Mono.CSharp {
                        if (ScopeTypeBuilder != null)
                                return;
                        
-                       ILGenerator ig = ec.ig;
                        TypeBuilder container = ec.TypeContainer.TypeBuilder;
 
                        ScopeTypeBuilder = container.DefineNestedType (
@@ -591,7 +590,6 @@ namespace Mono.CSharp {
                                Hashtable captured_parameters = CaptureContext.captured_parameters;
                                
                                foreach (DictionaryEntry de in captured_parameters){
-                                       string name = (string) de.Key;
                                        CapturedParameter cp = (CapturedParameter) de.Value;
 
                                        ig.Emit (OpCodes.Ldloc, ScopeInstance);
@@ -601,6 +599,9 @@ namespace Mono.CSharp {
                        }
                        
                        if (ParentScope != null){
+                               if (!ParentScope.inited)
+                                       ParentScope.EmitInitScope (ec);
+                               
                                //
                                // Only emit initialization in our capturecontext world
                                //
@@ -692,9 +693,7 @@ namespace Mono.CSharp {
                
                public override string ToString ()
                {
-                       ToplevelBlock parent = ParentToplevel;
                        StringBuilder sb = new StringBuilder ();
-
                        sb.Append ("[");
                        DoPath (sb, this);
                        sb.Append ("]");
@@ -1012,8 +1011,13 @@ namespace Mono.CSharp {
                                cc.EmitParameterInstance (ec, name);
                                return;
                        }
-                       Block invocation_block = ec.CurrentBlock;
+                       
                        CapturedParameter par_info = (CapturedParameter) captured_parameters [name];
+                       if (par_info != null){
+                               // 
+                               // FIXME: implementing this.
+                               //
+                       }
                        ILGenerator ig = ec.ig;
 
                        ScopeInfo si;
@@ -1046,6 +1050,11 @@ namespace Mono.CSharp {
                        }
                        EmitParameterInstance (ec, name);
                        CapturedParameter par_info = (CapturedParameter) captured_parameters [name];
+                       if (par_info != null){
+                               // 
+                               // FIXME: implementing this.
+                               //
+                       }
                        ec.ig.Emit (OpCodes.Ldfld, par_info.FieldBuilder);
                }
 
index 6c5c87d56eaf29f739501bbd4e7ddb50550d745c..3c009e625f8c9561e313082b39f64cdeae7d84f5 100644 (file)
@@ -388,7 +388,7 @@ namespace Mono.CSharp {
                        }
 
                        FieldExpr field_exp = target as FieldExpr;
-                       if (field_exp != null && !ec.IsConstructor && !ec.IsFieldInitializer) {
+                       if (field_exp != null && field_exp.DeclaringType.IsValueType && !ec.IsConstructor && !ec.IsFieldInitializer) {
                                field_exp = field_exp.InstanceExpression as FieldExpr;
                                if (field_exp != null && field_exp.FieldInfo.IsInitOnly) {
                                        if (field_exp.IsStatic) {
index 7c6824408737cb51cdaf9583f0c61cc68d2fca57..e8647f079cfec0e0ab27273549c38d2136304be6 100644 (file)
@@ -78,6 +78,8 @@ namespace Mono.CSharp {
 
                public Type Type;
                
+               bool resolve_error;
+
                // Is non-null if type is AttributeUsageAttribute
                AttributeUsageAttribute usage_attribute;
 
@@ -115,13 +117,18 @@ namespace Mono.CSharp {
                                      Name);
                }
 
-               static void Error_AttributeArgumentNotValid (Location loc)
+               static void Error_AttributeArgumentNotValid (string extra, Location loc)
                {
                        Report.Error (182, loc,
                                      "An attribute argument must be a constant expression, typeof " +
-                                     "expression or array creation expression");
+                                     "expression or array creation expression" + extra);
                }
 
+               static void Error_AttributeArgumentNotValid (Location loc)
+               {
+                       Error_AttributeArgumentNotValid ("", loc);
+               }
+               
                static void Error_TypeParameterInAttribute (Location loc)
                {
                        Report.Error (
@@ -154,14 +161,20 @@ namespace Mono.CSharp {
                protected virtual Type CheckAttributeType (EmitContext ec)
                {
                        string NameAttribute = Name + "Attribute";
-                       Type t1 = ec.ResolvingTypeTree
+                       FullNamedExpression n1 = ec.ResolvingTypeTree
                                ? ec.DeclSpace.FindType (Location, Name)
-                               : RootContext.LookupType (ec.DeclSpace, Name, true, Location);
+                               : ec.DeclSpace.LookupType (Name, true, Location);
 
                        // FIXME: Shouldn't do this for quoted attributes: [@A]
-                       Type t2 = ec.ResolvingTypeTree
+                       FullNamedExpression n2 = ec.ResolvingTypeTree
                                ? ec.DeclSpace.FindType (Location, NameAttribute)
-                               : RootContext.LookupType (ec.DeclSpace, NameAttribute, true, Location);
+                               : ec.DeclSpace.LookupType (NameAttribute, true, Location);
+
+                       TypeExpr e1 = n1 == null ? null : n1 as TypeExpr;
+                       TypeExpr e2 = n2 == null ? null : n2 as TypeExpr;                       
+
+                       Type t1 = e1 == null ? null : e1.ResolveType (ec);
+                       Type t2 = e2 == null ? null : e2.ResolveType (ec);
 
                        String err0616 = null;
                        if (t1 != null && ! t1.IsSubclassOf (TypeManager.attribute_type)) {
@@ -193,6 +206,7 @@ namespace Mono.CSharp {
                                      "Could not find attribute '" + Name 
                                      + "' (are you missing a using directive or an assembly reference ?)");
 
+                       resolve_error = true;
                        return null;
                }
 
@@ -266,8 +280,13 @@ namespace Mono.CSharp {
                        return false;
                }
                
-               public CustomAttributeBuilder Resolve (EmitContext ec)
+               public virtual CustomAttributeBuilder Resolve (EmitContext ec)
                {
+                       if (resolve_error)
+                               return null;
+
+                       resolve_error = true;
+
                        Type oldType = Type;
                        
                        // Sanity check.
@@ -348,6 +367,10 @@ namespace Mono.CSharp {
 
                                if (DoCompares){
                                        if (usage_attr) {
+                                               if ((int)val == 0) {
+                                                       Report.Error (591, Location, "Invalid value for argument to 'System.AttributeUsage' attribute");
+                                                       return null;
+                                               }
                                                usage_attribute = new AttributeUsageAttribute ((AttributeTargets)val);
                                        } else if (MethodImplAttr) {
                                                this.ImplOptions = (MethodImplOptions) val;
@@ -563,13 +586,6 @@ namespace Mono.CSharp {
                                else
                                        cb = new CustomAttributeBuilder (
                                                (ConstructorInfo) constructor, pos_values);
-                       } catch (NullReferenceException) {
-                               // 
-                               // Don't know what to do here
-                               //
-                               Report.Warning (
-                                       -101, Location, "NullReferenceException while trying to create attribute." +
-                                        "Something's wrong!");
                        } catch (Exception e) {
                                //
                                // Sample:
@@ -577,10 +593,11 @@ namespace Mono.CSharp {
                                // [DefaultValue (CollectionChangeAction.Add)]
                                // class X { static void Main () {} }
                                //
-                               Report.Warning (
-                                       -23, Location, "The compiler can not encode this attribute in .NET due to a bug in the .NET runtime. Try the Mono runtime. The exception was: " + e.Message);
+                               Error_AttributeArgumentNotValid (Location);
+                               return null;
                        }
                        
+                       resolve_error = false;
                        return cb;
                }
 
@@ -664,11 +681,10 @@ namespace Mono.CSharp {
                /// </summary>
                public string GetIndexerAttributeValue (EmitContext ec)
                {
-                       if (pos_values == null) {
+                       if (pos_values == null)
                                // TODO: It is not neccessary to call whole Resolve (ApplyAttribute does it now) we need only ctor args.
                                // But because a lot of attribute class code must be rewritten will be better to wait...
                                Resolve (ec);
-                       }
                        
                        return pos_values [0] as string;
                }
@@ -676,15 +692,12 @@ namespace Mono.CSharp {
                /// <summary>
                /// Returns condition of ConditionalAttribute
                /// </summary>
-               public string GetConditionalAttributeValue (DeclSpace ds)
+               public string GetConditionalAttributeValue (EmitContext ec)
                {
-                       if (pos_values == null) {
-                               EmitContext ec = new EmitContext (ds, ds, Location, null, null, 0, false);
-
+                       if (pos_values == null)
                                // TODO: It is not neccessary to call whole Resolve (ApplyAttribute does it now) we need only ctor args.
                                // But because a lot of attribute class code must be rewritten will be better to wait...
                                Resolve (ec);
-                       }
 
                        // Some error occurred
                        if (pos_values [0] == null)
@@ -696,15 +709,12 @@ namespace Mono.CSharp {
                /// <summary>
                /// Creates the instance of ObsoleteAttribute from this attribute instance
                /// </summary>
-               public ObsoleteAttribute GetObsoleteAttribute (DeclSpace ds)
+               public ObsoleteAttribute GetObsoleteAttribute (EmitContext ec)
                {
-                       if (pos_values == null) {
-                               EmitContext ec = new EmitContext (ds, ds, Location, null, null, 0, false);
-
+                       if (pos_values == null)
                                // TODO: It is not neccessary to call whole Resolve (ApplyAttribute does it now) we need only ctor args.
                                // But because a lot of attribute class code must be rewritten will be better to wait...
                                Resolve (ec);
-                       }
 
                        // Some error occurred
                        if (pos_values == null)
@@ -724,15 +734,12 @@ namespace Mono.CSharp {
                /// before ApplyAttribute. We need to resolve the arguments.
                /// This situation occurs when class deps is differs from Emit order.  
                /// </summary>
-               public bool GetClsCompliantAttributeValue (DeclSpace ds)
+               public bool GetClsCompliantAttributeValue (EmitContext ec)
                {
-                       if (pos_values == null) {
-                               EmitContext ec = new EmitContext (ds, ds, Location, null, null, 0, false);
-
+                       if (pos_values == null)
                                // TODO: It is not neccessary to call whole Resolve (ApplyAttribute does it now) we need only ctor args.
                                // But because a lot of attribute class code must be rewritten will be better to wait...
                                Resolve (ec);
-                       }
 
                        // Some error occurred
                        if (pos_values [0] == null)
@@ -812,14 +819,19 @@ namespace Mono.CSharp {
                                }
                        }
 
-                       IPermission perm = sa.CreatePermission ();
-                       SecurityAction action;
+                       IPermission perm;
+                       try {
+                               perm = sa.CreatePermission ();
+                       }
+                       catch (Exception e) {
+                               Error_AttributeEmitError (String.Format ("{0} was thrown during attribute processing: {1}", e.GetType (), e.Message));
+                               return;
+                       }
+                       SecurityAction action = GetSecurityActionValue ();
 
                        // IS is correct because for corlib we are using an instance from old corlib
-                       if (perm is System.Security.CodeAccessPermission) {
-                               action = GetSecurityActionValue ();
-                       } else {
-                               switch (GetSecurityActionValue ()) {
+                       if (!(perm is System.Security.CodeAccessPermission)) {
+                               switch (action) {
                                        case SecurityAction.Demand:
                                                action = (SecurityAction)13;
                                                break;
@@ -829,18 +841,22 @@ namespace Mono.CSharp {
                                        case SecurityAction.InheritanceDemand:
                                                action = (SecurityAction)15;
                                                break;
-                                       default:
-                                               Error_AttributeEmitError ("Invalid SecurityAction for non-Code Access Security permission");
-                                               return;
                                }
                        }
 
                        PermissionSet ps = (PermissionSet)permissions [action];
                        if (ps == null) {
-                               ps = new PermissionSet (PermissionState.None);
+                               if (sa is PermissionSetAttribute)
+                                       ps = new PermissionSet (sa.Unrestricted ? PermissionState.Unrestricted : PermissionState.None);
+                               else
+                                       ps = new PermissionSet (PermissionState.None);
+
                                permissions.Add (action, ps);
+                       } else if (!ps.IsUnrestricted () && sa.Unrestricted) {
+                               ps = ps.Union (new PermissionSet (PermissionState.Unrestricted));
+                               permissions [action] = ps;
                        }
-                       ps.AddPermission (sa.CreatePermission ());
+                       ps.AddPermission (perm);
                }
 
                object GetValue (object value)
@@ -1039,7 +1055,11 @@ namespace Mono.CSharp {
                                Error_AttributeArgumentNotValid (Location);
                                return null;
                        }
-
+                       if (dll_name == null || dll_name == ""){
+                               Error_AttributeArgumentNotValid (": DllImport requires a non-empty string", Location);
+                               return null;
+                       }
+                       
                        // Now we process the named arguments
                        CallingConvention cc = CallingConvention.Winapi;
                        CharSet charset = CharSet.Ansi;
@@ -1196,12 +1216,40 @@ namespace Mono.CSharp {
                        // in effect where the attribute was used.  Since code elsewhere cannot assume
                        // that the NamespaceEntry is right, just overwrite it.
                        //
-                       // FIXME: Check every place the NamespaceEntry of RootContext.Tree.Types is used
-                       //        to ensure the right one is used.
+                       // Precondition: RootContext.Tree.Types == null || RootContext.Tree.Types == ns.
+                       //               The second case happens when we are recursively invoked from inside Emit.
+
+                       NamespaceEntry old = null;
+                       if (ec.DeclSpace == RootContext.Tree.Types) {
+                               old = ec.DeclSpace.NamespaceEntry;
+                               ec.DeclSpace.NamespaceEntry = ns;
+                               if (old != null && old != ns)
+                                       throw new InternalErrorException (Location + " non-null NamespaceEntry " + old);
+                       }
+
+                       Type retval = base.CheckAttributeType (ec);
+
                        if (ec.DeclSpace == RootContext.Tree.Types)
+                               ec.DeclSpace.NamespaceEntry = old;
+
+                       return retval;
+               }
+
+               public override CustomAttributeBuilder Resolve (EmitContext ec)
+               {
+                       if (ec.DeclSpace == RootContext.Tree.Types) {
+                               NamespaceEntry old = ec.DeclSpace.NamespaceEntry;
                                ec.DeclSpace.NamespaceEntry = ns;
+                               if (old != null)
+                                       throw new InternalErrorException (Location + " non-null NamespaceEntry " + old);
+                       }
+
+                       CustomAttributeBuilder retval = base.Resolve (ec);
 
-                       return base.CheckAttributeType (ec);
+                       if (ec.DeclSpace == RootContext.Tree.Types)
+                               ec.DeclSpace.NamespaceEntry = null;
+
+                       return retval;
                }
        }
 
@@ -1541,6 +1589,10 @@ namespace Mono.CSharp {
                        if (mb.DeclaringType is TypeBuilder)
                                return null;
 
+                       PropertyInfo pi = PropertyExpr.AccessorTable [mb] as PropertyInfo;
+                       if (pi != null)
+                               return GetMemberObsoleteAttribute (pi);
+
                        return GetMemberObsoleteAttribute (mb);
                }
 
index d9eb56663c599a8c2b9a5d6a59c29a2531e31f82..5c2c5fd65a0fb0a9482879bf851e0e15a2b2c8a4 100644 (file)
@@ -439,7 +439,7 @@ namespace Mono.CSharp {
                // from classes from the arraylist `type_bases' 
                //
                string base_class_name;
-               TypeExpr parent_type;
+               TypeExpr base_type;
 
                ArrayList type_bases;
 
@@ -450,8 +450,8 @@ namespace Mono.CSharp {
                protected Type[] ifaces;
                protected Type ptype;
 
-               // The parent member cache and our member cache
-               MemberCache parent_cache;
+               // The base member cache and our member cache
+               MemberCache base_cache;
                MemberCache member_cache;
 
                public const string DefaultIndexerName = "Item";
@@ -469,19 +469,19 @@ namespace Mono.CSharp {
                        base_class_name = null;
                }
 
-               public bool AddToMemberContainer (MemberCore symbol, bool is_method)
+               public bool AddToMemberContainer (MemberCore symbol)
                {
-                       return AddToContainer (symbol, is_method, String.Concat (Name, '.', symbol.Name), symbol.Name);
+                       return AddToContainer (symbol, String.Concat (Name, '.', symbol.Name), symbol.Name);
                }
 
                bool AddToTypeContainer (DeclSpace ds)
                {
-                       return AddToContainer (ds, false, ds.Name, ds.Basename);
+                       return AddToContainer (ds, ds.Name, ds.Basename);
                }
 
                public void AddConstant (Const constant)
                {
-                       if (!AddToMemberContainer (constant, false))
+                       if (!AddToMemberContainer (constant))
                                return;
 
                        if (constants == null)
@@ -522,7 +522,7 @@ namespace Mono.CSharp {
 
                public void AddMethod (Method method)
                {
-                       if (!AddToMemberContainer (method, true))
+                       if (!AddToMemberContainer (method))
                                return;
 
                        if (methods == null)
@@ -583,7 +583,7 @@ namespace Mono.CSharp {
 
                public void AddField (Field field)
                {
-                       if (!AddToMemberContainer (field, false))
+                       if (!AddToMemberContainer (field))
                                return;
 
                        if (fields == null)
@@ -612,8 +612,8 @@ namespace Mono.CSharp {
 
                public void AddProperty (Property prop)
                {
-                       if (!AddToMemberContainer (prop, false) || 
-                           !AddToMemberContainer (prop.Get, true) || !AddToMemberContainer (prop.Set, true))
+                       if (!AddToMemberContainer (prop) || 
+                               !AddToMemberContainer (prop.Get) || !AddToMemberContainer (prop.Set))
                                return;
 
                        if (properties == null)
@@ -627,14 +627,14 @@ namespace Mono.CSharp {
 
                public void AddEvent (Event e)
                {
-                       if (!AddToMemberContainer (e, false))
+                       if (!AddToMemberContainer (e))
                                return;
 
                        if (e is EventProperty) {
-                               if (!AddToMemberContainer (e.Add, true))
+                               if (!AddToMemberContainer (e.Add))
                                        return;
 
-                               if (!AddToMemberContainer (e.Remove, true))
+                               if (!AddToMemberContainer (e.Remove))
                                        return;
                        }
 
@@ -660,7 +660,7 @@ namespace Mono.CSharp {
 
                public void AddOperator (Operator op)
                {
-                       if (!AddToMemberContainer (op, true))
+                       if (!AddToMemberContainer (op))
                                return;
 
                        if (operators == null)
@@ -706,7 +706,16 @@ namespace Mono.CSharp {
 
                public override AttributeTargets AttributeTargets {
                        get {
-                               throw new NotSupportedException ();
+                               switch (Kind) {
+                               case Kind.Class:
+                                       return AttributeTargets.Class;
+                               case Kind.Struct:
+                                       return AttributeTargets.Struct;
+                               case Kind.Interface:
+                                       return AttributeTargets.Interface;
+                               default:
+                                       throw new NotSupportedException ();
+                               }
                        }
                }
 
@@ -902,38 +911,38 @@ namespace Mono.CSharp {
 
                public abstract PendingImplementation GetPendingImplementations ();
 
-               TypeExpr[] GetPartialBases (out TypeExpr parent, out bool error)
+               TypeExpr[] GetPartialBases (out TypeExpr base_class, out bool error)
                {
                        ArrayList ifaces = new ArrayList ();
 
-                       parent = null;
-                       Location parent_loc = Location.Null;
+                       base_class = null;
+                       Location base_loc = Location.Null;
 
                        foreach (ClassPart part in parts) {
-                               TypeExpr new_parent;
+                               TypeExpr new_base_class;
                                TypeExpr[] new_ifaces;
 
-                               new_ifaces = part.GetClassBases (out new_parent, out error);
+                               new_ifaces = part.GetClassBases (out new_base_class, out error);
                                if (error)
                                        return null;
 
-                               if ((parent != null) && (new_parent != null) &&
-                                   !parent.Equals (new_parent)) {
+                               if ((base_class != null) && (new_base_class != null) &&
+                                   !base_class.Equals (new_base_class)) {
                                        Report.Error (263, part.Location,
                                                      "Partial declarations of `{0}' must " +
                                                      "not specify different base classes",
                                                      Name);
 
-                                       if (!Location.IsNull (parent_loc))
-                                               Report.LocationOfPreviousError (parent_loc);
+                                       if (!Location.IsNull (base_loc))
+                                               Report.LocationOfPreviousError (base_loc);
 
                                        error = true;
                                        return null;
                                }
 
-                               if ((parent == null) && (new_parent != null)) {
-                                       parent = new_parent;
-                                       parent_loc = part.Location;
+                               if ((base_class == null) && (new_base_class != null)) {
+                                       base_class = new_base_class;
+                                       base_loc = part.Location;
                                }
 
                                if (new_ifaces == null)
@@ -960,36 +969,34 @@ namespace Mono.CSharp {
                        return retval;
                }
 
-               TypeExpr[] GetNormalBases (out TypeExpr parent, out bool error)
+               TypeExpr[] GetNormalBases (out TypeExpr base_class, out bool error)
                {
-                       parent = null;
+                       base_class = null;
 
                        int count = Bases.Count;
-                       int start, i, j;
+                       int start = 0, i, j;
 
                        if (Kind == Kind.Class){
-                               TypeExpr name = ResolveTypeExpr ((Expression) Bases [0], Location);
+                               TypeExpr name = ResolveBaseTypeExpr (
+                                       (Expression) Bases [0], false, Location);
 
                                if (name == null){
                                        error = true;
                                        return null;
                                }
 
-                               if (name.IsClass){
-                                       parent = name;
+                               if (!name.IsInterface) {
+                                       // base_class could be a class, struct, enum, delegate.
+                                       // This is validated in GetClassBases.
+                                       base_class = name;
                                        start = 1;
-                               } else {
-                                       start = 0;
                                }
-                       } else {
-                               start = 0;
                        }
 
                        TypeExpr [] ifaces = new TypeExpr [count-start];
                        
                        for (i = start, j = 0; i < count; i++, j++){
-                               Expression name = (Expression) Bases [i];
-                               TypeExpr resolved = ResolveTypeExpr (name, Location);
+                               TypeExpr resolved = ResolveBaseTypeExpr ((Expression) Bases [i], false, Location);
                                if (resolved == null) {
                                        error = true;
                                        return null;
@@ -1009,10 +1016,10 @@ namespace Mono.CSharp {
                ///   The return value is an array (might be null) of
                ///   interfaces implemented (as Types).
                ///   
-               ///   The @parent argument is set to the parent object or null
+               ///   The @base_class argument is set to the base object or null
                ///   if this is `System.Object'. 
                /// </summary>
-               TypeExpr [] GetClassBases (out TypeExpr parent, out bool error)
+               TypeExpr [] GetClassBases (out TypeExpr base_class, out bool error)
                {
                        int i;
 
@@ -1021,40 +1028,46 @@ namespace Mono.CSharp {
                        TypeExpr[] ifaces;
 
                        if (parts != null)
-                               ifaces = GetPartialBases (out parent, out error);
+                               ifaces = GetPartialBases (out base_class, out error);
                        else if (Bases == null){
-                               parent = null;
+                               base_class = null;
                                return null;
                        } else
-                               ifaces = GetNormalBases (out parent, out error);
+                               ifaces = GetNormalBases (out base_class, out error);
 
                        if (error)
                                return null;
 
-                       if ((parent != null) && (Kind == Kind.Class)){
-                               if (parent is TypeParameterExpr){
+                       if ((base_class != null) && (Kind == Kind.Class)){
+                               if (base_class is TypeParameterExpr){
                                        Report.Error (
-                                               689, parent.Location,
+                                               689, base_class.Location,
                                                "Type parameter `{0}' can not be used as a " +
-                                               "base class or interface", parent.Name);
+                                               "base class or interface", base_class.Name);
                                        error = true;
                                        return null;
                                }
 
-                               if (IsGeneric && parent.IsAttribute){
+                               if (IsGeneric && base_class.IsAttribute){
                                        Report.Error (
-                                               698, parent.Location,
+                                               698, base_class.Location,
                                                "A generic type cannot derive from `{0}' " +
                                                "because it is an attribute class",
-                                               parent.Name);
+                                               base_class.Name);
+                                       error = true;
+                                       return null;
+                               }
+
+                               if (base_class.Type.IsArray || base_class.Type.IsPointer) {
+                                       Report.Error (1521, base_class.Location, "Invalid base type");
                                        error = true;
                                        return null;
                                }
 
-                               if (parent.IsSealed){
+                               if (base_class.IsSealed){
                                        error = true;
-                                       Report.SymbolRelatedToPreviousError (parent.Type);
-                                       if (parent.Type.IsAbstract) {
+                                       Report.SymbolRelatedToPreviousError (base_class.Type);
+                                       if (base_class.Type.IsAbstract) {
                                                Report.Error (709, Location, "'{0}': Cannot derive from static class", GetSignatureForError ());
                                        } else {
                                                Report.Error (509, Location, "'{0}': Cannot derive from sealed class", GetSignatureForError ());
@@ -1062,23 +1075,23 @@ namespace Mono.CSharp {
                                        return null;
                                }
 
-                               if (!parent.CanInheritFrom ()){
+                               if (!base_class.CanInheritFrom ()){
                                        Report.Error (644, Location,
                                                      "`{0}' cannot inherit from special class `{1}'",
-                                                     Name, parent_type.Name);
+                                                     Name, base_class.Name);
                                        error = true;
                                        return null;
                                }
 
-                               if (!parent.AsAccessible (this, ModFlags)) {
-                                       Report.SymbolRelatedToPreviousError (parent.Type);
+                               if (!base_class.AsAccessible (this, ModFlags)) {
+                                       Report.SymbolRelatedToPreviousError (base_class.Type);
                                        Report.Error (60, Location, "Inconsistent accessibility: base class '{0}' is less accessible than class '{1}'", 
-                                               TypeManager.CSharpName (parent.Type), GetSignatureForError ());
+                                               TypeManager.CSharpName (base_class.Type), GetSignatureForError ());
                                }
                        }
 
-                       if (parent != null)
-                               base_class_name = parent.Name;
+                       if (base_class != null)
+                               base_class_name = base_class.Name;
 
                        if (ifaces == null)
                                return null;
@@ -1088,19 +1101,16 @@ namespace Mono.CSharp {
                        for (i = 0; i < count; i++) {
                                TypeExpr iface = (TypeExpr) ifaces [i];
 
-                               if ((Kind != Kind.Class) && !iface.IsInterface){
-                                       string what = Kind == Kind.Struct ?
-                                               "Struct" : "Interface";
-
-                                       Report.Error (527, Location,
-                                                     "In {0} `{1}', type `{2}' is not "+
-                                                     "an interface", what, Name, iface.Name);
+                               if (!iface.IsInterface) {
                                        error = true;
-                                       return null;
-                               }
-
-                               if (iface.IsClass) {
-                                       if (parent != null)
+                                       if (Kind != Kind.Class) {
+                                               string what = Kind == Kind.Struct ? "Struct" : "Interface";
+                                               
+                                               Report.Error (527, Location,
+                                                             "In {0} `{1}', type `{2}' is not "+
+                                                             "an interface", what, Name, iface.Name);
+                                       }
+                                       else if (base_class != null)
                                                Report.Error (1721, Location,
                                                              "In Class `{0}', `{1}' is not an interface, and a base class has already been defined",
                                                              Name, iface.Name);
@@ -1109,8 +1119,7 @@ namespace Mono.CSharp {
                                                              "In Class `{0}', `{1}' is not " +
                                                              "an interface, a base class must be listed first", Name, iface.Name);
                                        }
-                                       error = true;
-                                       return null;
+                                       continue;
                                }
   
                                for (int x = 0; x < i; x++) {
@@ -1119,19 +1128,23 @@ namespace Mono.CSharp {
                                                              "`{0}' is already listed in " +
                                                              "interface list", iface.Name);
                                                error = true;
-                                               return null;
                                        }
                                }
 
                                if ((Kind == Kind.Interface) &&
-                                   !iface.AsAccessible (Parent, ModFlags))
+                                   !iface.AsAccessible (Parent, ModFlags)) {
                                        Report.Error (61, Location,
                                                      "Inconsistent accessibility: base " +
                                                      "interface `{0}' is less accessible " +
                                                      "than interface `{1}'", iface.Name,
                                                      Name);
+                                       error = true;
+                               }
                        }
 
+                       if (error)
+                               return null;
+
                        return ifaces;
                }
 
@@ -1172,8 +1185,6 @@ namespace Mono.CSharp {
                //
                public override TypeBuilder DefineType ()
                {
-                       TypeExpr parent;
-
                        if (error)
                                return null;
 
@@ -1256,37 +1267,37 @@ namespace Mono.CSharp {
                        if ((Kind == Kind.Struct) && TypeManager.value_type == null)
                                throw new Exception ();
 
-                       TypeExpr[] iface_exprs = GetClassBases (out parent_type, out error); 
+                       TypeExpr[] iface_exprs = GetClassBases (out base_type, out error);
                        if (error)
                                return null;
 
-                       if (parent_type == null) {
+                       if (base_type == null) {
                                if (Kind == Kind.Class){
                                        if (RootContext.StdLib)
-                                               parent_type = TypeManager.system_object_expr;
+                                               base_type = TypeManager.system_object_expr;
                                        else if (Name != "System.Object")
-                                               parent_type = TypeManager.system_object_expr;
+                                               base_type = TypeManager.system_object_expr;
                                } else if (Kind == Kind.Struct){
                                        //
                                        // If we are compiling our runtime,
                                        // and we are defining ValueType, then our
-                                       // parent is `System.Object'.
+                                       // base is `System.Object'.
                                        //
                                        if (!RootContext.StdLib && Name == "System.ValueType")
-                                               parent_type = TypeManager.system_object_expr;
+                                               base_type = TypeManager.system_object_expr;
                                        else if (Kind == Kind.Struct)
-                                               parent_type = TypeManager.system_valuetype_expr;
+                                               base_type = TypeManager.system_valuetype_expr;
                                }
                        }
 
-                       if (parent_type != null) {
-                               parent_type = parent_type.ResolveAsTypeTerminal (ec);
-                               if (parent_type == null) {
+                       if (base_type != null) {
+                               base_type = base_type.ResolveAsTypeTerminal (ec);
+                               if (base_type == null) {
                                        error = true;
                                        return null;
                                }
 
-                               ptype = parent_type.Type;
+                               ptype = base_type.Type;
                        }
 
                        if (!CheckRecursiveDefinition ()) {
@@ -1311,6 +1322,8 @@ namespace Mono.CSharp {
 
                        // add interfaces that were not added at type creation
                        if (iface_exprs != null) {
+                               // FIXME: I think this should be ...ExpandInterfaces (Parent.EmitContext, ...).
+                               //        However, if Parent == RootContext.Tree.Types, its NamespaceEntry will be null.
                                ifaces = TypeManager.ExpandInterfaces (ec, iface_exprs);
                                if (ifaces == null) {
                                        error = true;
@@ -1351,7 +1364,7 @@ namespace Mono.CSharp {
                        //
                        ec.ContainerType = TypeBuilder;
 
-                       if ((parent_type != null) && parent_type.IsAttribute) {
+                       if ((base_type != null) && base_type.IsAttribute) {
                                RootContext.RegisterAttribute (this);
                        } else if (!(this is Iterator))
                                RootContext.RegisterOrder (this); 
@@ -1393,7 +1406,7 @@ namespace Mono.CSharp {
                        if (Parts != null) {
                                foreach (ClassPart part in Parts) {
                                        part.TypeBuilder = TypeBuilder;
-                                       part.parent_type = parent_type;
+                                       part.base_type = base_type;
                                        part.ec = new EmitContext (part, Mono.CSharp.Location.Null, null, null, ModFlags);
                                }
                        }
@@ -1452,10 +1465,10 @@ namespace Mono.CSharp {
                        // We need to be able to use the member cache while we are checking/defining
                        //
                        if (TypeBuilder.BaseType != null)
-                               parent_cache = TypeManager.LookupMemberCache (TypeBuilder.BaseType);
+                               base_cache = TypeManager.LookupMemberCache (TypeBuilder.BaseType);
 
                        if (TypeBuilder.IsInterface)
-                               parent_cache = TypeManager.LookupParentInterfacesCache (TypeBuilder);
+                               base_cache = TypeManager.LookupBaseInterfacesCache (TypeBuilder);
 
                        if (IsTopLevel) {
                                if ((ModFlags & Modifiers.NEW) != 0)
@@ -1596,9 +1609,9 @@ namespace Mono.CSharp {
                        return true;
                }
 
-               public MemberInfo FindMemberWithSameName (string name, bool ignore_methods)
+               public MemberInfo FindBaseMemberWithSameName (string name, bool ignore_methods)
                {
-                       return ParentCache.FindMemberWithSameName (name, ignore_methods, null);
+                       return BaseCache.FindMemberWithSameName (name, ignore_methods, null);
                }
 
                /// <summary>
@@ -2058,7 +2071,7 @@ namespace Mono.CSharp {
                        }
 
                        //
-                       // Lookup members in parent if requested.
+                       // Lookup members in base if requested.
                        //
                        if ((bf & BindingFlags.DeclaredOnly) == 0) {
                                if (TypeBuilder.BaseType != null) {
@@ -2124,7 +2137,7 @@ namespace Mono.CSharp {
                        //
                        // Check for internal or private fields that were never assigned
                        //
-                       if (RootContext.WarningLevel >= 3) {
+                       if (RootContext.WarningLevel >= 4) {
                                if (fields != null){
                                        foreach (Field f in fields) {
                                                if ((f.ModFlags & Modifiers.Accessibility) != Modifiers.PRIVATE)
@@ -2304,7 +2317,7 @@ namespace Mono.CSharp {
                        type_bases = null;
                        OptAttributes = null;
                        ifaces = null;
-                       parent_cache = null;
+                       base_cache = null;
                        member_cache = null;
                }
 
@@ -2318,36 +2331,34 @@ namespace Mono.CSharp {
                // Performs the validation on a Method's modifiers (properties have
                // the same properties).
                //
-               public bool MethodModifiersValid (int flags, string n, Location loc)
+               public bool MethodModifiersValid (MemberCore mc)
                {
                        const int vao = (Modifiers.VIRTUAL | Modifiers.ABSTRACT | Modifiers.OVERRIDE);
                        const int va = (Modifiers.VIRTUAL | Modifiers.ABSTRACT);
                        const int nv = (Modifiers.NEW | Modifiers.VIRTUAL);
                        bool ok = true;
+                       int flags = mc.ModFlags;
                        
                        //
                        // At most one of static, virtual or override
                        //
                        if ((flags & Modifiers.STATIC) != 0){
                                if ((flags & vao) != 0){
-                                       Report.Error (
-                                               112, loc, "static method " + MakeName (n) + "can not be marked " +
-                                               "as virtual, abstract or override");
+                                       Report.Error (112, mc.Location, "static method '{0}' can not be marked as virtual, abstract or override",
+                                               GetSignatureForError ());
                                        ok = false;
                                }
                        }
 
                        if (Kind == Kind.Struct){
                                if ((flags & va) != 0){
-                                       Modifiers.Error_InvalidModifier (loc, "virtual or abstract");
+                                       Modifiers.Error_InvalidModifier (mc.Location, "virtual or abstract");
                                        ok = false;
                                }
                        }
 
                        if ((flags & Modifiers.OVERRIDE) != 0 && (flags & nv) != 0){
-                               Report.Error (
-                                       113, loc, MakeName (n) +
-                                       " marked as override cannot be marked as new or virtual");
+                               Report.Error (113, mc.Location, "'{0}' marked as override cannot be marked as new or virtual", mc.GetSignatureForError ());
                                ok = false;
                        }
 
@@ -2358,39 +2369,36 @@ namespace Mono.CSharp {
                        if ((flags & Modifiers.ABSTRACT) != 0){
                                if ((flags & Modifiers.EXTERN) != 0){
                                        Report.Error (
-                                               180, loc, MakeName (n) + " can not be both abstract and extern");
+                                               180, mc.Location, "'{0}' can not be both abstract and extern", mc.GetSignatureForError ());
+                                       ok = false;
+                               }
+
+                               if ((flags & Modifiers.SEALED) != 0) {
+                                       Report.Error (502, mc.Location, "'{0}' cannot be both abstract and sealed", mc.GetSignatureForError ());
                                        ok = false;
                                }
 
                                if ((flags & Modifiers.VIRTUAL) != 0){
-                                       Report.Error (
-                                               503, loc, MakeName (n) + " can not be both abstract and virtual");
+                                       Report.Error (503, mc.Location, "'{0}' can not be both abstract and virtual", mc.GetSignatureForError ());
                                        ok = false;
                                }
 
                                if ((ModFlags & Modifiers.ABSTRACT) == 0){
-                                       Report.Error (
-                                               513, loc, MakeName (n) +
-                                               " is abstract but its container class is not");
+                                       Report.Error (513, mc.Location, "'{0}' is abstract but its container class is not", mc.GetSignatureForError ());
                                        ok = false;
-
                                }
                        }
 
                        if ((flags & Modifiers.PRIVATE) != 0){
                                if ((flags & vao) != 0){
-                                       Report.Error (
-                                               621, loc, MakeName (n) +
-                                               " virtual or abstract members can not be private");
+                                       Report.Error (621, mc.Location, "'{0}' virtual or abstract members can not be private", mc.GetSignatureForError ());
                                        ok = false;
                                }
                        }
 
                        if ((flags & Modifiers.SEALED) != 0){
                                if ((flags & Modifiers.OVERRIDE) == 0){
-                                       Report.Error (
-                                               238, loc, MakeName (n) +
-                                               " cannot be sealed because it is not an override");
+                                       Report.Error (238, mc.Location, "'{0}' cannot be sealed because it is not an override", mc.GetSignatureForError ());
                                        ok = false;
                                }
                        }
@@ -2425,6 +2433,11 @@ namespace Mono.CSharp {
                        if (base_type != null && !AttributeTester.IsClsCompliant (base_type)) {
                                Report.Error (3009, Location, "'{0}': base type '{1}' is not CLS-compliant", GetSignatureForError (), TypeManager.CSharpName (base_type));
                        }
+
+                       if (!Parent.IsClsCompliaceRequired (ds)) {
+                               Report.Error (3018, Location, "'{0}' cannot be marked as CLS-Compliant because it is a member of non CLS-Compliant type '{1}'", 
+                                       GetSignatureForError (), Parent.GetSignatureForError ());
+                       }
                        return true;
                }
 
@@ -2434,9 +2447,9 @@ namespace Mono.CSharp {
                /// </summary>
                void VerifyClsName ()
                {
-                       Hashtable parent_members = parent_cache == null ? 
+                       Hashtable base_members = base_cache == null ? 
                                new Hashtable () :
-                               parent_cache.GetPublicMembers ();
+                               base_cache.GetPublicMembers ();
                        Hashtable this_members = new Hashtable ();
 
                        foreach (DictionaryEntry entry in defined_names) {
@@ -2448,7 +2461,7 @@ namespace Mono.CSharp {
                                string basename = name.Substring (name.LastIndexOf ('.') + 1);
 
                                string lcase = basename.ToLower (System.Globalization.CultureInfo.InvariantCulture);
-                               object found = parent_members [lcase];
+                               object found = base_members [lcase];
                                if (found == null) {
                                        found = this_members [lcase];
                                        if (found == null) {
@@ -2492,7 +2505,8 @@ namespace Mono.CSharp {
                        }
                        
                        if (!found){
-                               Report.Error (540, "`" + full + "': containing class does not implement interface `" + interface_type.FullName + "'");
+                               Report.Error (540, loc, "`{0}': containing class does not implement interface `{1}'",
+                                             full, interface_type.FullName);
                                return false;
                        }
 
@@ -2563,9 +2577,9 @@ namespace Mono.CSharp {
                        get { return "T:"; }
                }
 
-               public virtual MemberCache ParentCache {
+               public virtual MemberCache BaseCache {
                        get {
-                               return parent_cache;
+                               return base_cache;
                        }
                }
                
@@ -2744,9 +2758,9 @@ namespace Mono.CSharp {
                                interface_type, full, name, loc);
                }
 
-               public override MemberCache ParentCache {
+               public override MemberCache BaseCache {
                        get {
-                               return PartialContainer.ParentCache;
+                               return PartialContainer.BaseCache;
                        }
                }
        }
@@ -2825,7 +2839,7 @@ namespace Mono.CSharp {
        public sealed class StaticClass: Class {
                public StaticClass (NamespaceEntry ns, TypeContainer parent, MemberName name, int mod,
                                    Attributes attrs, Location l)
-                       : base (ns, parent, name, mod & ~Modifiers.STATIC, attrs, l)
+                       : base (ns, parent, name, mod, attrs, l)
                {
                        if (RootContext.Version == LanguageVersion.ISO_1) {
                                Report.FeatureIsNotStandardized (l, "static classes");
@@ -2833,6 +2847,13 @@ namespace Mono.CSharp {
                        }
                }
 
+               protected override int AllowedModifiersProp {
+                       get {
+                               return Modifiers.NEW | Modifiers.PUBLIC | Modifiers.PROTECTED | Modifiers.INTERNAL | Modifiers.PRIVATE |
+                                       Modifiers.STATIC | Modifiers.UNSAFE;
+                       }
+               }
+
                protected override void DefineContainerMembers (MemberCoreArrayList list)
                {
                        if (list == null)
@@ -2844,7 +2865,7 @@ namespace Mono.CSharp {
                                        continue;
                                }
 
-                               if ((m.ModFlags & Modifiers.STATIC) != 0)
+                               if ((m.ModFlags & Modifiers.STATIC) != 0 || m is Enum || m is Delegate)
                                        continue;
 
                                if (m is Constructor) {
@@ -2864,6 +2885,11 @@ namespace Mono.CSharp {
 
                public override TypeBuilder DefineType()
                {
+                       if ((ModFlags & (Modifiers.SEALED | Modifiers.STATIC)) == (Modifiers.SEALED | Modifiers.STATIC)) {
+                               Report.Error (441, Location, "'{0}': a class cannot be both static and sealed", GetSignatureForError ());
+                               return null;
+                       }
+
                        TypeBuilder tb = base.DefineType ();
                        if (tb == null)
                                return null;
@@ -2896,9 +2922,7 @@ namespace Mono.CSharp {
        }
 
        public class Class : ClassOrStruct {
-               // <summary>
-               //   Modifiers allowed in a class declaration
-               // </summary>
+               // TODO: remove this and use only AllowedModifiersProp to fix partial classes bugs
                public const int AllowedModifiers =
                        Modifiers.NEW |
                        Modifiers.PUBLIC |
@@ -2916,24 +2940,13 @@ namespace Mono.CSharp {
                              Attributes attrs, Location l)
                        : base (ns, parent, name, attrs, Kind.Class, l)
                {
-                       int accmods;
-
-                       if (parent.Parent == null)
-                               accmods = Modifiers.INTERNAL;
-                       else
-                               accmods = Modifiers.PRIVATE;
-
-                       this.ModFlags = Modifiers.Check (AllowedModifiers, mod, accmods, l);
-                       if ((ModFlags & (Modifiers.ABSTRACT | Modifiers.SEALED)) == (Modifiers.ABSTRACT | Modifiers.SEALED)) {
-                               Report.Error (502, Location, "'{0}' cannot be both abstract and sealed", GetSignatureForError ());
-                       }
-
+                       this.ModFlags = mod;
                        attribute_usage = new AttributeUsageAttribute (AttributeTargets.All);
                }
 
-               public override AttributeTargets AttributeTargets {
+               virtual protected int AllowedModifiersProp {
                        get {
-                               return AttributeTargets.Class;
+                               return AllowedModifiers;
                        }
                }
 
@@ -2960,6 +2973,19 @@ namespace Mono.CSharp {
                public const TypeAttributes DefaultTypeAttributes =
                        TypeAttributes.AutoLayout | TypeAttributes.Class;
 
+               public override TypeBuilder DefineType()
+               {
+                       if ((ModFlags & Modifiers.ABSTRACT) == Modifiers.ABSTRACT && (ModFlags & (Modifiers.SEALED | Modifiers.STATIC)) != 0) {
+                               Report.Error (418, Location, "'{0}': an abstract class cannot be sealed or static", GetSignatureForError ());
+                               return null;
+                       }
+
+                       int accmods = Parent.Parent == null ? Modifiers.INTERNAL : Modifiers.PRIVATE;
+                       ModFlags = Modifiers.Check (AllowedModifiersProp, ModFlags, accmods, Location);
+
+                       return base.DefineType ();
+               }
+
                //
                // FIXME: How do we deal with the user specifying a different
                // layout?
@@ -2999,12 +3025,6 @@ namespace Mono.CSharp {
                        this.ModFlags |= Modifiers.SEALED;
                }
 
-               public override AttributeTargets AttributeTargets {
-                       get {
-                               return AttributeTargets.Struct;
-                       }
-               }
-
                public const TypeAttributes DefaultTypeAttributes =
                        TypeAttributes.SequentialLayout |
                        TypeAttributes.Sealed |
@@ -3061,12 +3081,6 @@ namespace Mono.CSharp {
                        return null;
                }
 
-               public override AttributeTargets AttributeTargets {
-                       get {
-                               return AttributeTargets.Interface;
-                       }
-               }
-
                public const TypeAttributes DefaultTypeAttributes =
                                        TypeAttributes.AutoLayout |
                                        TypeAttributes.Abstract |
@@ -3097,7 +3111,7 @@ namespace Mono.CSharp {
                //
                // The method we're overriding if this is an override method.
                //
-               protected MethodInfo parent_method = null;
+               protected MethodInfo base_method = null;
 
                static string[] attribute_targets = new string [] { "method", "return" };
 
@@ -3160,39 +3174,39 @@ namespace Mono.CSharp {
                                return true;
 
                        // Is null for System.Object while compiling corlib and base interfaces
-                       if (Parent.ParentCache == null) {
+                       if (Parent.BaseCache == null) {
                                if ((RootContext.WarningLevel >= 4) && ((ModFlags & Modifiers.NEW) != 0)) {
                                        Report.Warning (109, Location, "The member '{0}' does not hide an inherited member. The new keyword is not required", GetSignatureForError (Parent));
                                }
                                return true;
                        }
 
-                       Type parent_ret_type = null;
-                       parent_method = FindOutParentMethod (Parent, ref parent_ret_type);
+                       Type base_ret_type = null;
+                       base_method = FindOutBaseMethod (Parent, ref base_ret_type);
 
                        // method is override
-                       if (parent_method != null) {
+                       if (base_method != null) {
 
                                if (!CheckMethodAgainstBase ())
                                        return false;
 
                                if ((ModFlags & Modifiers.NEW) == 0) {
-                                       if (!MemberType.Equals (TypeManager.TypeToCoreType (parent_ret_type))) {
-                                               Report.SymbolRelatedToPreviousError (parent_method);
+                                       if (MemberType != TypeManager.TypeToCoreType (base_ret_type)) {
+                                               Report.SymbolRelatedToPreviousError (base_method);
                                                Report.Error (508, Location, GetSignatureForError (Parent) + ": cannot " +
                                                        "change return type when overriding inherited member");
                                                return false;
                                        }
                                } else {
-                                       if (parent_method.IsAbstract && !IsInterface) {
-                                               Report.SymbolRelatedToPreviousError (parent_method);
+                                       if (base_method.IsAbstract && !IsInterface) {
+                                               Report.SymbolRelatedToPreviousError (base_method);
                                                Report.Error (533, Location, "'{0}' hides inherited abstract member", GetSignatureForError (Parent));
                                                return false;
                                        }
                                }
 
-                               if (parent_method.IsSpecialName && !(this is PropertyBase)) {
-                                       Report.Error (561, Location, "'{0}': cannot override '{1}' because it is a special compiler-generated method", GetSignatureForError (Parent), TypeManager.GetFullNameSignature (parent_method));
+                               if (base_method.IsSpecialName && !(this is PropertyBase)) {
+                                       Report.Error (561, Location, "'{0}': cannot override '{1}' because it is a special compiler-generated method", GetSignatureForError (Parent), TypeManager.GetFullNameSignature (base_method));
                                        return false;
                                }
 
@@ -3203,18 +3217,20 @@ namespace Mono.CSharp {
                                                Parent.Methods.HasGetHashCode = true;
                                }
 
-                               ObsoleteAttribute oa = AttributeTester.GetMethodObsoleteAttribute (parent_method);
-                               if (oa != null) {
-                                       EmitContext ec = new EmitContext (this.Parent, this.Parent, Location, null, null, ModFlags, false);
-                                       if (OptAttributes == null || !OptAttributes.Contains (TypeManager.obsolete_attribute_type, ec)) {
-                                               Report.SymbolRelatedToPreviousError (parent_method);
-                                               Report.Warning (672, 1, Location, "Member '{0}' overrides obsolete member. Add the Obsolete attribute to '{0}'", GetSignatureForError (Parent));
+                               if ((ModFlags & Modifiers.OVERRIDE) != 0) {
+                                       ObsoleteAttribute oa = AttributeTester.GetMethodObsoleteAttribute (base_method);
+                                       if (oa != null) {
+                                               EmitContext ec = new EmitContext (this.Parent, this.Parent, Location, null, null, ModFlags, false);
+                                               if (OptAttributes == null || !OptAttributes.Contains (TypeManager.obsolete_attribute_type, ec)) {
+                                                       Report.SymbolRelatedToPreviousError (base_method);
+                                                       Report.Warning (672, 1, Location, "Member '{0}' overrides obsolete member. Add the Obsolete attribute to '{0}'", GetSignatureForError (Parent));
+                                               }
                                        }
                                }
                                return true;
                        }
 
-                       MemberInfo conflict_symbol = Parent.FindMemberWithSameName (Name, !(this is Property));
+                       MemberInfo conflict_symbol = Parent.FindBaseMemberWithSameName (Name, !(this is Property));
                        if ((ModFlags & Modifiers.OVERRIDE) != 0) {
                                if (conflict_symbol != null) {
                                        Report.SymbolRelatedToPreviousError (conflict_symbol);
@@ -3258,10 +3274,10 @@ namespace Mono.CSharp {
                        bool ok = true;
 
                        // TODO: replace with GetSignatureForError 
-                       string name = parent_method.DeclaringType.Name + "." + parent_method.Name;
+                       string name = base_method.DeclaringType.Name + "." + base_method.Name;
 
                        if ((ModFlags & Modifiers.OVERRIDE) != 0){
-                               if (!(parent_method.IsAbstract || parent_method.IsVirtual)){
+                               if (!(base_method.IsAbstract || base_method.IsVirtual)){
                                        Report.Error (
                                                506, Location, Parent.MakeName (Name) +
                                                ": cannot override inherited member `" +
@@ -3272,9 +3288,9 @@ namespace Mono.CSharp {
                                
                                // Now we check that the overriden method is not final
                                
-                               if (parent_method.IsFinal) {
+                               if (base_method.IsFinal) {
                                        // This happens when implementing interface methods.
-                                       if (parent_method.IsHideBySig && parent_method.IsVirtual) {
+                                       if (base_method.IsHideBySig && base_method.IsVirtual) {
                                                Report.Error (
                                                        506, Location, Parent.MakeName (Name) +
                                                        ": cannot override inherited member `" +
@@ -3290,20 +3306,20 @@ namespace Mono.CSharp {
                                // Check that the permissions are not being changed
                                //
                                MethodAttributes thisp = flags & MethodAttributes.MemberAccessMask;
-                               MethodAttributes parentp = parent_method.Attributes & MethodAttributes.MemberAccessMask;
+                               MethodAttributes base_classp = base_method.Attributes & MethodAttributes.MemberAccessMask;
 
-                               if (!CheckAccessModifiers (thisp, parentp, parent_method)) {
-                                       Error_CannotChangeAccessModifiers (Parent, parent_method, name);
+                               if (!CheckAccessModifiers (thisp, base_classp, base_method)) {
+                                       Error_CannotChangeAccessModifiers (Parent, base_method, name);
                                        ok = false;
                                }
                        }
 
                        if ((ModFlags & (Modifiers.NEW | Modifiers.OVERRIDE)) == 0 && Name != "Finalize") {
                                ModFlags |= Modifiers.NEW;
-                               Report.SymbolRelatedToPreviousError (parent_method);
-                               if (!IsInterface && (parent_method.IsVirtual || parent_method.IsAbstract)) {
+                               Report.SymbolRelatedToPreviousError (base_method);
+                               if (!IsInterface && (base_method.IsVirtual || base_method.IsAbstract)) {
                                        if (RootContext.WarningLevel >= 2)
-                                               Report.Warning (114, Location, "'{0}' hides inherited member '{1}'. To make the current member override that implementation, add the override keyword. Otherwise add the new keyword", GetSignatureForError (Parent), TypeManager.CSharpSignature (parent_method));
+                                               Report.Warning (114, Location, "'{0}' hides inherited member '{1}'. To make the current member override that implementation, add the override keyword. Otherwise add the new keyword", GetSignatureForError (Parent), TypeManager.CSharpSignature (base_method));
                                } else
                                        Report.Warning (108, Location, "The keyword new is required on '{0}' because it hides inherited member", GetSignatureForError (Parent));
                        }
@@ -3311,9 +3327,9 @@ namespace Mono.CSharp {
                        return ok;
                }
                
-               protected bool CheckAccessModifiers (MethodAttributes thisp, MethodAttributes parentp, MethodInfo base_method)
+               protected bool CheckAccessModifiers (MethodAttributes thisp, MethodAttributes base_classp, MethodInfo base_method)
                {
-                       if ((parentp & MethodAttributes.FamORAssem) == MethodAttributes.FamORAssem){
+                       if ((base_classp & MethodAttributes.FamORAssem) == MethodAttributes.FamORAssem){
                                //
                                // when overriding protected internal, the method can be declared
                                // protected internal only within the same assembly
@@ -3326,7 +3342,7 @@ namespace Mono.CSharp {
                                                //
                                                
                                                return false;
-                                       } else if (thisp != parentp) {
+                                       } else if (thisp != base_classp) {
                                                //
                                                // same assembly, but other attributes differ - report an error
                                                //
@@ -3345,7 +3361,7 @@ namespace Mono.CSharp {
                                        //
                                        return false;
                                } else if ((thisp & ~(MethodAttributes.Family | MethodAttributes.FamORAssem)) != 
-                                          (parentp & ~(MethodAttributes.Family | MethodAttributes.FamORAssem))) {
+                                          (base_classp & ~(MethodAttributes.Family | MethodAttributes.FamORAssem))) {
                                        //
                                        // protected ok, but other attributes differ - report an error
                                        //
@@ -3353,11 +3369,11 @@ namespace Mono.CSharp {
                                }
                                return true;
                        } else {
-                               return (thisp == parentp);
+                               return (thisp == base_classp);
                        }
                }
                
-               void Error_CannotChangeAccessModifiers (TypeContainer parent, MethodInfo parent_method, string name)
+               void Error_CannotChangeAccessModifiers (TypeContainer parent, MethodInfo base_method, string name)
                {
                        //
                        // FIXME: report the old/new permissions?
@@ -3380,9 +3396,9 @@ namespace Mono.CSharp {
                protected abstract bool CheckForDuplications ();
 
                /// <summary>
-               /// Gets parent method and its return type
+               /// Gets base method and its return type
                /// </summary>
-               protected abstract MethodInfo FindOutParentMethod (TypeContainer container, ref Type parent_ret_type);
+               protected abstract MethodInfo FindOutBaseMethod (TypeContainer container, ref Type base_ret_type);
 
                protected virtual bool DoDefineParameters ()
                {
@@ -3493,7 +3509,7 @@ namespace Mono.CSharp {
                        }
 
                        if (!AttributeTester.IsClsCompliant (MemberType)) {
-                               if ((this is Property) || (this is Indexer))
+                               if (this is PropertyBase)
                                        Report.Error (3003, Location, "Type of `{0}' is not CLS-compliant",
                                                      GetSignatureForError ());
                                else
@@ -3941,7 +3957,7 @@ namespace Mono.CSharp {
                                flags |= MethodAttributes.SpecialName | MethodAttributes.HideBySig;
 
                        MethodData = new MethodData (this, ParameterInfo, ModFlags, flags,
-                                                    this, mb, GenericMethod, parent_method);
+                                                    this, mb, GenericMethod, base_method);
 
                        if (!MethodData.Define (Parent))
                                return false;
@@ -4014,18 +4030,24 @@ namespace Mono.CSharp {
                        MethodData = null;
                }
 
-               protected override MethodInfo FindOutParentMethod (TypeContainer container, ref Type parent_ret_type)
+               protected override MethodInfo FindOutBaseMethod (TypeContainer container, ref Type base_ret_type)
                {
-                       MethodInfo mi = (MethodInfo) container.ParentCache.FindMemberToOverride (
+                       MethodInfo mi = (MethodInfo) container.BaseCache.FindMemberToOverride (
                                container.TypeBuilder, Name, ParameterTypes, false);
 
                        if (mi == null)
                                return null;
 
-                       parent_ret_type = mi.ReturnType;
+                       base_ret_type = mi.ReturnType;
                        return mi;
                }
        
+               public override bool MarkForDuplicationCheck ()
+               {
+                       caching_flags |= Flags.TestMethodDuplication;
+                       return true;
+               }
+
                protected override bool VerifyClsCompliance(DeclSpace ds)
                {
                        if (!base.VerifyClsCompliance (ds))
@@ -4103,7 +4125,7 @@ namespace Mono.CSharp {
 
                        caching_flags &= ~Flags.Excluded_Undetected;
 
-                       if (parent_method == null) {
+                       if (base_method == null) {
                                if (OptAttributes == null)
                                        return false;
 
@@ -4113,7 +4135,7 @@ namespace Mono.CSharp {
                                        return false;
 
                                foreach (Attribute a in attrs) {
-                                       string condition = a.GetConditionalAttributeValue (ds);
+                                       string condition = a.GetConditionalAttributeValue (Parent.EmitContext);
                                        if (RootContext.AllDefines.Contains (condition))
                                                return false;
                                }
@@ -4122,9 +4144,9 @@ namespace Mono.CSharp {
                                return true;
                        }
 
-                       IMethodData md = TypeManager.GetMethod (parent_method);
+                       IMethodData md = TypeManager.GetMethod (base_method);
                        if (md == null) {
-                               if (AttributeTester.IsConditionalMethodExcluded (parent_method)) {
+                               if (AttributeTester.IsConditionalMethodExcluded (base_method)) {
                                        caching_flags |= Flags.Excluded;
                                        return true;
                                }
@@ -4149,7 +4171,7 @@ namespace Mono.CSharp {
 
        public abstract class ConstructorInitializer {
                ArrayList argument_list;
-               protected ConstructorInfo parent_constructor;
+               protected ConstructorInfo base_constructor;
                Parameters parameters;
                Location loc;
                
@@ -4169,7 +4191,7 @@ namespace Mono.CSharp {
 
                public bool Resolve (ConstructorBuilder caller_builder, EmitContext ec)
                {
-                       Expression parent_constructor_group;
+                       Expression base_constructor_group;
                        Type t;
 
                        ec.CurrentBlock = new ToplevelBlock (Block.Flags.Implicit, parameters, loc);
@@ -4195,18 +4217,18 @@ namespace Mono.CSharp {
                        } else
                                t = ec.ContainerType;
 
-                       parent_constructor_group = Expression.MemberLookup (
+                       base_constructor_group = Expression.MemberLookup (
                                ec, t, ".ctor", MemberTypes.Constructor,
                                BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly,
                                loc);
                        
-                       if (parent_constructor_group == null){
-                               parent_constructor_group = Expression.MemberLookup (
+                       if (base_constructor_group == null){
+                               base_constructor_group = Expression.MemberLookup (
                                        ec, t, ".ctor", MemberTypes.Constructor,
                                        BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly,
                                        loc);
 
-                               if (parent_constructor_group != null)
+                               if (base_constructor_group != null)
                                        Report.Error (
                                                112, loc, "`{0}.{1}' is inaccessible due to " +
                                                "its protection level", t.FullName, t.Name);
@@ -4217,17 +4239,17 @@ namespace Mono.CSharp {
                                return false;
                        }
                        
-                       parent_constructor = (ConstructorInfo) Invocation.OverloadResolve (
-                               ec, (MethodGroupExpr) parent_constructor_group, argument_list,
+                       base_constructor = (ConstructorInfo) Invocation.OverloadResolve (
+                               ec, (MethodGroupExpr) base_constructor_group, argument_list,
                                false, loc);
                        
-                       if (parent_constructor == null){
+                       if (base_constructor == null){
                                Report.Error (1501, loc,
                                       "Can not find a constructor for this argument list");
                                return false;
                        }
                        
-                       if (parent_constructor == caller_builder){
+                       if (base_constructor == caller_builder){
                                Report.Error (516, String.Format ("Constructor `{0}' can not call itself", TypeManager.CSharpSignature (caller_builder)));
                                return false;
                        }
@@ -4237,12 +4259,12 @@ namespace Mono.CSharp {
 
                public void Emit (EmitContext ec)
                {
-                       if (parent_constructor != null){
+                       if (base_constructor != null){
                                ec.Mark (loc, false);
                                if (ec.IsStatic)
-                                       Invocation.EmitCall (ec, true, true, null, parent_constructor, argument_list, loc);
+                                       Invocation.EmitCall (ec, true, true, null, base_constructor, argument_list, loc);
                                else
-                                       Invocation.EmitCall (ec, true, false, ec.GetThis (loc), parent_constructor, argument_list, loc);
+                                       Invocation.EmitCall (ec, true, false, ec.GetThis (loc), base_constructor, argument_list, loc);
                        }
                }
 
@@ -4314,15 +4336,15 @@ namespace Mono.CSharp {
                }
 
                public override void CheckObsoleteAttribute(TypeContainer tc, Location loc) {
-                       if (parent_constructor == null)
+                       if (base_constructor == null)
                                return;
 
                        TypeContainer type_ds = TypeManager.LookupTypeContainer (tc.TypeBuilder.BaseType);
                        if (type_ds == null) {
-                               ObsoleteAttribute oa = AttributeTester.GetMemberObsoleteAttribute (parent_constructor);
+                               ObsoleteAttribute oa = AttributeTester.GetMemberObsoleteAttribute (base_constructor);
 
                                if (oa != null)
-                                       AttributeTester.Report_ObsoleteMessage (oa, TypeManager.CSharpSignature (parent_constructor), loc);
+                                       AttributeTester.Report_ObsoleteMessage (oa, TypeManager.CSharpSignature (base_constructor), loc);
 
                                return;
                        }
@@ -4615,7 +4637,7 @@ namespace Mono.CSharp {
                }
 
                // Is never override
-               protected override MethodInfo FindOutParentMethod (TypeContainer container, ref Type parent_ret_type)
+               protected override MethodInfo FindOutBaseMethod (TypeContainer container, ref Type base_ret_type)
                {
                        return null;
                }
@@ -4837,7 +4859,7 @@ namespace Mono.CSharp {
                                if (member.InterfaceType != null){
                                        if (implementing == null){
                                                Report.Error (539, method.Location,
-                                                             "'{0}' in explicit interface declaration is not an interface", method_name);
+                                                             "'{0}' in explicit interface declaration is not a member of interface", member.GetSignatureForError () );
                                                return false;
                                        }
                                }
@@ -5024,7 +5046,6 @@ namespace Mono.CSharp {
                        if (member is MethodCore)
                                ((MethodCore) member).Parameters.LabelParameters (ec, MethodBuilder, loc);
                         
-                       SymbolWriter sw = CodeGen.SymbolWriter;
                        ToplevelBlock block = method.Block;
                        
                        //
@@ -5103,10 +5124,10 @@ namespace Mono.CSharp {
                                        "Finalize", MemberTypes.Method, Expression.AllBindingFlags, method.Location);
 
                                if (member_lookup != null){
-                                       MethodGroupExpr parent_destructor = ((MethodGroupExpr) member_lookup);
+                                       MethodGroupExpr base_destructor = ((MethodGroupExpr) member_lookup);
                                
                                        ig.Emit (OpCodes.Ldarg_0);
-                                       ig.Emit (OpCodes.Call, (MethodInfo) parent_destructor.Methods [0]);
+                                       ig.Emit (OpCodes.Call, (MethodInfo) base_destructor.Methods [0]);
                                }
                        }
                        
@@ -5276,7 +5297,7 @@ namespace Mono.CSharp {
                                        MethodAttributes.NewSlot |
                                        MethodAttributes.Virtual;
                        } else {
-                               if (!Parent.MethodModifiersValid (ModFlags, Name, Location))
+                               if (!Parent.MethodModifiersValid (this))
                                        return false;
 
                                flags = Modifiers.MethodAttr (ModFlags);
@@ -5313,11 +5334,12 @@ namespace Mono.CSharp {
                        
                        // verify accessibility
                        if (!Parent.AsAccessible (MemberType, ModFlags)) {
+                               Report.SymbolRelatedToPreviousError (MemberType);
                                if (this is Property)
                                        Report.Error (53, Location,
                                                      "Inconsistent accessibility: property type `" +
                                                      TypeManager.CSharpName (MemberType) + "' is less " +
-                                                     "accessible than property `" + Name + "'");
+                                                     "accessible than property `" + GetSignatureForError () + "'");
                                else if (this is Indexer)
                                        Report.Error (54, Location,
                                                      "Inconsistent accessibility: indexer return type `" +
@@ -5426,7 +5448,7 @@ namespace Mono.CSharp {
                static string[] attribute_targets = new string [] { "field" };
 
                /// <summary>
-               ///  Symbol with same name in parent class/struct
+               ///  Symbol with same name in base class/struct
                /// </summary>
                public MemberInfo conflict_symbol;
 
@@ -5518,7 +5540,7 @@ namespace Mono.CSharp {
                        if (IsInterface)
                                return true;
 
-                       conflict_symbol = Parent.FindMemberWithSameName (Name, false);
+                       conflict_symbol = Parent.FindBaseMemberWithSameName (Name, false);
                        if (conflict_symbol == null) {
                                if ((RootContext.WarningLevel >= 4) && ((ModFlags & Modifiers.NEW) != 0)) {
                                        Report.Warning (109, Location, "The member '{0}' does not hide an inherited member. The new keyword is not required", GetSignatureForError (Parent));
@@ -5628,6 +5650,13 @@ namespace Mono.CSharp {
                        
                        MemberType = texpr.Type;
 
+                       if (MemberType == TypeManager.void_type) {
+                               Report.Error (1547, Location, "Keyword 'void' cannot be used in this context");
+                               return false;
+                       }
+
+                       ec.InUnsafe = old_unsafe;
+
                        if (!CheckBase ())
                                return false;
                        
@@ -6116,12 +6145,15 @@ namespace Mono.CSharp {
                                        parameters = new Parameters (parms, null, method.Location);
                                }
                                
+                               bool old_unsafe = ec.InUnsafe;
+                               ec.InUnsafe = InUnsafe;
                                Type [] types = parameters.GetParameterInfo (ec);
+                               ec.InUnsafe = old_unsafe;
 
                                return new InternalParameters (types, parameters);
                        }
 
-                       public override MethodBuilder Define(TypeContainer container)
+                       public override MethodBuilder Define (TypeContainer container)
                        {
                                if (container.EmitContext == null)
                                        throw new InternalErrorException ("SetMethod.Define called too early");
@@ -6170,12 +6202,14 @@ namespace Mono.CSharp {
                                : base (method, prefix)
                        {
                                this.method = method;
+                               Parent = method.Parent;
                        }
 
                        public PropertyMethod (MethodCore method, Accessor accessor, string prefix)
                                : base (method, accessor, prefix)
                        {
                                this.method = method;
+                               Parent = method.Parent;
                                this.ModFlags = accessor.ModFlags;
 
                                if (accessor.ModFlags != 0 && RootContext.Version == LanguageVersion.ISO_1) {
@@ -6207,10 +6241,10 @@ namespace Mono.CSharp {
                                //
                                // Check for custom access modifier
                                //
-                                if (ModFlags == 0) {
-                                        ModFlags = method.ModFlags;
-                                        flags = method.flags;
-                                } else {
+                               if (ModFlags == 0) {
+                                       ModFlags = method.ModFlags;
+                                       flags = method.flags;
+                               } else {
                                        CheckModifiers (container, ModFlags);
                                        ModFlags |= (method.ModFlags & (~Modifiers.Accessibility));
                                        flags = Modifiers.MethodAttr (ModFlags);
@@ -6246,26 +6280,32 @@ namespace Mono.CSharp {
                        }
 
                        void CheckModifiers (TypeContainer container, int modflags)
-                        {
-                                int flags = 0;
-                                int mflags = method.ModFlags & Modifiers.Accessibility;
+                       {
+                               int flags = 0;
+                               int mflags = method.ModFlags & Modifiers.Accessibility;
 
-                                if ((mflags & Modifiers.PUBLIC) != 0) {
-                                        flags |= Modifiers.PROTECTED | Modifiers.INTERNAL | Modifiers.PRIVATE;
-                                }
-                                else if ((mflags & Modifiers.PROTECTED) != 0) {
-                                        if ((mflags & Modifiers.INTERNAL) != 0)
-                                                flags |= Modifiers.PROTECTED | Modifiers.INTERNAL;
+                               if ((mflags & Modifiers.PUBLIC) != 0) {
+                                       flags |= Modifiers.PROTECTED | Modifiers.INTERNAL | Modifiers.PRIVATE;
+                               }
+                               else if ((mflags & Modifiers.PROTECTED) != 0) {
+                                       if ((mflags & Modifiers.INTERNAL) != 0)
+                                               flags |= Modifiers.PROTECTED | Modifiers.INTERNAL;
 
-                                        flags |= Modifiers.PRIVATE;
-                                }
-                                else if ((mflags & Modifiers.INTERNAL) != 0)
-                                        flags |= Modifiers.PRIVATE;
+                                       flags |= Modifiers.PRIVATE;
+                               }
+                               else if ((mflags & Modifiers.INTERNAL) != 0)
+                                       flags |= Modifiers.PRIVATE;
 
-                                if ((mflags == modflags) || (modflags & (~flags)) != 0)
-                                        Report.Error (273, Location, "{0}: accessibility modifier must be more restrictive than the property or indexer",
-                                                       GetSignatureForError (container));
-                        }
+                               if ((mflags == modflags) || (modflags & (~flags)) != 0)
+                                       Report.Error (273, Location, "{0}: accessibility modifier must be more restrictive than the property or indexer",
+                                               GetSignatureForError (container));
+                       }
+
+                       public override bool MarkForDuplicationCheck ()
+                       {
+                               caching_flags |= Flags.TestMethodDuplication;
+                               return true;
+                       }
                }
 
                public PropertyMethod Get, Set;
@@ -6318,7 +6358,6 @@ namespace Mono.CSharp {
                        //
                        // Accessors modifiers check
                        //
-
                        if (Get.ModFlags != 0 && Set.ModFlags != 0) {
                                Report.Error (274, Location, "'{0}': cannot specify accessibility modifiers for both accessors of the property or indexer.",
                                                GetSignatureForError ());
@@ -6350,7 +6389,6 @@ namespace Mono.CSharp {
                        return TypeManager.CSharpSignature (PropertyBuilder, false);
                }
 
-
                protected override bool CheckForDuplications ()
                {
                        ArrayList ar = Parent.Indexers;
@@ -6379,33 +6417,33 @@ namespace Mono.CSharp {
                }
 
                // TODO: rename to Resolve......
-               protected override MethodInfo FindOutParentMethod (TypeContainer container, ref Type parent_ret_type)
+               protected override MethodInfo FindOutBaseMethod (TypeContainer container, ref Type base_ret_type)
                {
-                       PropertyInfo parent_property = container.ParentCache.FindMemberToOverride (
+                       PropertyInfo base_property = container.BaseCache.FindMemberToOverride (
                                container.TypeBuilder, Name, ParameterTypes, true) as PropertyInfo;
 
-                       if (parent_property == null)
+                       if (base_property == null)
                                return null;
 
-                       parent_ret_type = parent_property.PropertyType;
-                       MethodInfo get_accessor = parent_property.GetGetMethod (true);
-                       MethodInfo set_accessor = parent_property.GetSetMethod (true);
+                       base_ret_type = base_property.PropertyType;
+                       MethodInfo get_accessor = base_property.GetGetMethod (true);
+                       MethodInfo set_accessor = base_property.GetSetMethod (true);
                        MethodAttributes get_accessor_access, set_accessor_access;
 
                        if ((ModFlags & Modifiers.OVERRIDE) != 0) {
                                if (Get != null && !Get.IsDummy && get_accessor == null) {
-                                       Report.SymbolRelatedToPreviousError (parent_property);
-                                       Report.Error (545, Location, "'{0}': cannot override because '{1}' does not have an overridable get accessor", GetSignatureForError (), TypeManager.GetFullNameSignature (parent_property));
+                                       Report.SymbolRelatedToPreviousError (base_property);
+                                       Report.Error (545, Location, "'{0}': cannot override because '{1}' does not have an overridable get accessor", GetSignatureForError (), TypeManager.GetFullNameSignature (base_property));
                                }
 
                                if (Set != null && !Set.IsDummy && set_accessor == null) {
-                                       Report.SymbolRelatedToPreviousError (parent_property);
-                                       Report.Error (546, Location, "'{0}': cannot override because '{1}' does not have an overridable set accessor", GetSignatureForError (), TypeManager.GetFullNameSignature (parent_property));
+                                       Report.SymbolRelatedToPreviousError (base_property);
+                                       Report.Error (546, Location, "'{0}': cannot override because '{1}' does not have an overridable set accessor", GetSignatureForError (), TypeManager.GetFullNameSignature (base_property));
                                }
                        }
                        
                        //
-                       // Check parent accessors access
+                       // Check base class accessors access
                        //
                        get_accessor_access = set_accessor_access = 0;
                        if ((ModFlags & Modifiers.NEW) == 0) {
@@ -6415,7 +6453,7 @@ namespace Mono.CSharp {
 
                                        if (!Get.IsDummy && !CheckAccessModifiers (get_flags & MethodAttributes.MemberAccessMask, get_accessor_access, get_accessor))
                                                Report.Error (507, Location, "'{0}' can't change the access modifiers when overriding inherited member '{1}'",
-                                                               GetSignatureForError (), TypeManager.GetFullNameSignature (parent_property));
+                                                               GetSignatureForError (), TypeManager.GetFullNameSignature (base_property));
                                }
 
                                if (set_accessor != null)  {
@@ -6424,7 +6462,7 @@ namespace Mono.CSharp {
 
                                        if (!Set.IsDummy && !CheckAccessModifiers (set_flags & MethodAttributes.MemberAccessMask, set_accessor_access, set_accessor))
                                                Report.Error (507, Location, "'{0}' can't change the access modifiers when overriding inherited member '{1}'",
-                                                               GetSignatureForError (container), TypeManager.GetFullNameSignature (parent_property));
+                                                               GetSignatureForError (container), TypeManager.GetFullNameSignature (base_property));
                                }
                        }
 
@@ -6469,6 +6507,17 @@ namespace Mono.CSharp {
                        Set.UpdateName (this);
                }
 
+               protected override bool VerifyClsCompliance (DeclSpace ds)
+               {
+                       if (!base.VerifyClsCompliance (ds))
+                               return false;
+
+                       if ((Get.ModFlags != ModFlags && !Get.IsDummy) || (Set.ModFlags != ModFlags && !Set.IsDummy)) {
+                               Report.Error (3025, Get.ModFlags != ModFlags ? Get.Location : Set.Location,
+                                       "CLS-compliant accessors must have the same accessibility as their property");
+                       }
+                       return true;
+               }
 
                public override string[] ValidAttributeTargets {
                        get {
@@ -6929,7 +6978,6 @@ namespace Mono.CSharp {
                                }
 
                                ILGenerator ig = method_data.MethodBuilder.GetILGenerator ();
-                               EmitContext ec = CreateEmitContext (tc, ig);
                                FieldInfo field_info = (FieldInfo)method.FieldBuilder;
 
                                method_data.MethodBuilder.SetImplementationFlags (MethodImplAttributes.Synchronized);
@@ -7291,6 +7339,11 @@ namespace Mono.CSharp {
                        if (!base.Define ())
                                return false;
 
+                       if (MemberType == TypeManager.void_type) {
+                               Report.Error (620, Location, "Indexers cannot have void type");
+                               return false;
+                       }
+
                        if (OptAttributes != null) {
                                Attribute indexer_attr = OptAttributes.Search (TypeManager.indexer_name_type, ec);
                                if (indexer_attr != null) {
@@ -7323,14 +7376,14 @@ namespace Mono.CSharp {
                        }
 
                        if (InterfaceType != null) {
-                               string parent_IndexerName = TypeManager.IndexerPropertyName (InterfaceType);
-                               if (parent_IndexerName != Name)
-                                       ShortName = parent_IndexerName;
+                               string base_IndexerName = TypeManager.IndexerPropertyName (InterfaceType);
+                               if (base_IndexerName != Name)
+                                       ShortName = base_IndexerName;
                                UpdateMemberName ();
                        }
 
-                       if (!Parent.AddToMemberContainer (this, true) ||
-                           !Parent.AddToMemberContainer (Get, true) || !Parent.AddToMemberContainer (Set, true))
+                       if (!Parent.AddToMemberContainer (this) ||
+                               !Parent.AddToMemberContainer (Get) || !Parent.AddToMemberContainer (Set))
                                return false;
 
                        if (!CheckBase ())
@@ -7409,6 +7462,13 @@ namespace Mono.CSharp {
                {
                        return String.Concat (tc.Name, ".this[", Parameters.FixedParameters [0].TypeName.ToString (), ']');
                }
+
+               public override bool MarkForDuplicationCheck ()
+               {
+                       caching_flags |= Flags.TestMethodDuplication;
+                       return true;
+               }
+
        }
 
        public class Operator : MethodCore, IIteratorContainer {
@@ -7528,6 +7588,11 @@ namespace Mono.CSharp {
                        if (!DoDefine (ds))
                                return false;
 
+                       if (MemberType == TypeManager.void_type) {
+                               Report.Error (590, Location, "User-defined operators cannot return void");
+                               return false;
+                       }
+
                        OperatorMethod = new Method (
                                Parent, null, Type, ModFlags, false, MemberName,
                                Parameters, OptAttributes, Location);
@@ -7664,7 +7729,7 @@ namespace Mono.CSharp {
                }
 
                // Operator cannot be override
-               protected override MethodInfo FindOutParentMethod (TypeContainer container, ref Type parent_ret_type)
+               protected override MethodInfo FindOutBaseMethod (TypeContainer container, ref Type base_ret_type)
                {
                        return null;
                }
@@ -7747,6 +7812,12 @@ namespace Mono.CSharp {
                        return ToString ();
                }
                
+               public override bool MarkForDuplicationCheck ()
+               {
+                       caching_flags |= Flags.TestMethodDuplication;
+                       return true;
+               }
+
                public override string ToString ()
                {
                        if (OperatorMethod == null)
index cd0d122eaa40bf8bccec825a6d3df47dbe50462c..9073d2a00a2a791e8461aac964e8ae330cf4c8fa 100644 (file)
@@ -445,6 +445,9 @@ namespace Mono.CSharp {
                        DeclSpace = ds;
                        CheckState = RootContext.Checked;
                        ConstantCheckState = true;
+
+                       if ((return_type is TypeBuilder) && return_type.IsGenericTypeDefinition)
+                               throw new Exception ("FUCK");
                        
                        IsStatic = (code_flags & Modifiers.STATIC) != 0;
                        InIterator = (code_flags & Modifiers.METHOD_YIELDS) != 0;
@@ -638,17 +641,12 @@ namespace Mono.CSharp {
                                ReturnLabel = ig.DefineLabel ();
                }
 
-               public void EmitTopBlock (ToplevelBlock block, InternalParameters ip, Location loc)
-               {
-                       EmitTopBlock (block, ip, loc, "");
-               }
-
                //
                // Here until we can fix the problem with Mono.CSharp.Switch, which
                // currently can not cope with ig == null during resolve (which must
                // be fixed for switch statements to work on anonymous methods).
                //
-               public void EmitTopBlock (ToplevelBlock block, InternalParameters ip, Location loc, string methodName)
+               public void EmitTopBlock (ToplevelBlock block, InternalParameters ip, Location loc)
                {
                        if (block == null)
                                return;
@@ -1065,6 +1063,10 @@ namespace Mono.CSharp {
                        if (OptAttributes == null)
                                return null;
 
+                       // Ensure that we only have GlobalAttributes, since the Search below isn't safe with other types.
+                       if (!OptAttributes.CheckTargets (this))
+                               return null;
+
                        EmitContext temp_ec = new EmitContext (RootContext.Tree.Types, Mono.CSharp.Location.Null, null, null, 0, false);
                        Attribute a = OptAttributes.Search (TypeManager.cls_compliant_attribute_type, temp_ec);
                        if (a != null) {
@@ -1079,6 +1081,7 @@ namespace Mono.CSharp {
                public AssemblyBuilder Builder;
                     
                bool is_cls_compliant;
+               public Attribute ClsCompliantAttribute;
 
                ListDictionary declarative_security;
 
@@ -1108,11 +1111,11 @@ namespace Mono.CSharp {
 
                public void ResolveClsCompliance ()
                {
-                       Attribute a = GetClsCompliantAttribute ();
-                       if (a == null)
+                       ClsCompliantAttribute = GetClsCompliantAttribute ();
+                       if (ClsCompliantAttribute == null)
                                return;
 
-                       is_cls_compliant = a.GetClsCompliantAttributeValue (null);
+                       is_cls_compliant = ClsCompliantAttribute.GetClsCompliantAttributeValue (null);
                }
 
                // fix bug #56621
@@ -1346,13 +1349,20 @@ namespace Mono.CSharp {
                                return;
                        }
                                
-                       ApplyAttributeBuilder (null, new CustomAttributeBuilder (TypeManager.unverifiable_code_ctor, new object [0]));
+                       Builder.SetCustomAttribute (new CustomAttributeBuilder (TypeManager.unverifiable_code_ctor, new object [0]));
                }
                 
                public override void ApplyAttributeBuilder (Attribute a, CustomAttributeBuilder customBuilder)
                {
-                       if (a != null && a.Type == TypeManager.cls_compliant_attribute_type) {
-                               Report.Warning (3012, a.Location, "You must specify the CLSCompliant attribute on the assembly, not the module, to enable CLS compliance checking");
+                       if (a.Type == TypeManager.cls_compliant_attribute_type) {
+                               if (CodeGen.Assembly.ClsCompliantAttribute == null) {
+                                       Report.Warning (3012, a.Location, "You must specify the CLSCompliant attribute on the assembly, not the module, to enable CLS compliance checking");
+                               }
+                               else if (CodeGen.Assembly.IsClsCompliant != a.GetBoolean ()) {
+                                       Report.SymbolRelatedToPreviousError (CodeGen.Assembly.ClsCompliantAttribute.Location, CodeGen.Assembly.ClsCompliantAttribute.Name);
+                                       Report.Error (3017, a.Location, "You cannot specify the CLSCompliant attribute on a module that differs from the CLSCompliant attribute on the assembly");
+                                       return;
+                               }
                        }
 
                        Builder.SetCustomAttribute (customBuilder);
index e6bdf4674c0c7a0c35c58e5000ac1e8785e4e066..4580d57e28bbf9a865157de6d7fae0290eb3f14d 100644 (file)
@@ -587,6 +587,7 @@ namespace Mono.CSharp {
                        if (expr_type.Equals (target_type))
                                return true;
 
+
                        // First numeric conversions 
 
                        if (expr_type == TypeManager.sbyte_type){
@@ -693,6 +694,20 @@ namespace Mono.CSharp {
                                        return true;
                        }       
                        
+                       if (expr.eclass == ExprClass.MethodGroup){
+                               if (TypeManager.IsDelegateType (target_type) && RootContext.Version != LanguageVersion.ISO_1){
+                                       MethodGroupExpr mg = expr as MethodGroupExpr;
+                                       if (mg != null){
+                                               //
+                                               // This should not happen frequently, so we can create an object
+                                               // to test compatibility
+                                               //
+                                               Expression c = ImplicitDelegateCreation.Create (ec, mg, target_type, Location.Null);
+                                               return c != null;
+                                       }
+                               }
+                       }
+                       
                        if (ImplicitReferenceConversionExists (ec, expr, target_type))
                                return true;
 
@@ -751,6 +766,13 @@ namespace Mono.CSharp {
                                        return true;
                        }
 
+                       //
+                       // If `expr_type' implements `target_type' (which is an iface)
+                       // see TryImplicitIntConversion
+                       // 
+                       if (target_type.IsInterface && target_type.IsAssignableFrom (expr_type))
+                               return true;
+
                        if (target_type == TypeManager.void_ptr_type && expr_type.IsPointer)
                                return true;
 
@@ -759,13 +781,12 @@ namespace Mono.CSharp {
                                        return false;
 
                                AnonymousMethod am = (AnonymousMethod) expr;
-                               int errors = Report.Errors;
 
                                Expression conv = am.Compatible (ec, target_type, true);
                                if (conv != null)
                                        return true;
                        }
-                       
+
                        return false;
                }
 
@@ -1288,7 +1309,7 @@ namespace Mono.CSharp {
                }
 
                /// <summary>
-               ///   Attemps to perform an implict constant conversion of the IntConstant
+               ///   Attempts to perform an implicit constant conversion of the IntConstant
                ///   into a different data type using casts (See Implicit Constant
                ///   Expression Conversions)
                /// </summary>
@@ -1339,6 +1360,14 @@ namespace Mono.CSharp {
 
                                return new EnumConstant (e, target_type);
                        }
+
+                       //
+                       // If `target_type' is an interface and the type of `ic' implements the interface
+                       // e.g. target_type is IComparable, IConvertible, IFormattable
+                       //
+                       if (target_type.IsInterface && target_type.IsAssignableFrom (ic.Type))
+                               return new BoxedCast (ic);
+
                        return null;
                }
 
@@ -1358,7 +1387,7 @@ namespace Mono.CSharp {
                }
 
                /// <summary>
-               ///   Attemptes to implicityly convert `target' into `type', using
+               ///   Attempts to implicitly convert `source' into `target_type', using
                ///   ImplicitConversion.  If there is no implicit conversion, then
                ///   an error is signaled
                /// </summary>
index 0ca658d7961f8df7fe1ced73465f41eb417e22d2..fccf04b5bc97e4e401187d055aa1e4c2ef566ac2 100644 (file)
@@ -112,7 +112,6 @@ namespace Mono.CSharp {
 
                public string GetTypeName ()
                {
-                       string suffix = "";
                        if (Left != null)
                                return Left.GetTypeName () + "." +
                                        MakeName (Name, TypeArguments);
@@ -218,7 +217,7 @@ namespace Mono.CSharp {
                /// </summary>
                public int ModFlags;
 
-               public readonly TypeContainer Parent;
+               public /*readonly*/ TypeContainer Parent;
 
                /// <summary>
                ///   Location where this declaration happens
@@ -358,7 +357,7 @@ namespace Mono.CSharp {
                        if (obsolete_attr == null)
                                return null;
 
-                       ObsoleteAttribute obsolete = obsolete_attr.GetObsoleteAttribute (ds);
+                       ObsoleteAttribute obsolete = obsolete_attr.GetObsoleteAttribute (ds.EmitContext);
                        if (obsolete == null)
                                return null;
 
@@ -411,7 +410,7 @@ namespace Mono.CSharp {
                                        TypeManager.cls_compliant_attribute_type, ds.EmitContext);
                                if (cls_attribute != null) {
                                        caching_flags |= Flags.HasClsCompliantAttribute;
-                                       return cls_attribute.GetClsCompliantAttributeValue (ds);
+                                       return cls_attribute.GetClsCompliantAttributeValue (ds.EmitContext);
                                }
                        }
                        return ds.GetClsCompliantAttributeValue ();
@@ -426,6 +425,14 @@ namespace Mono.CSharp {
                        }
                }
 
+               /// <summary>
+               /// It helps to handle error 102 & 111 detection
+               /// </summary>
+               public virtual bool MarkForDuplicationCheck ()
+               {
+                       return false;
+               }
+
                /// <summary>
                /// The main virtual method for CLS-Compliant verifications.
                /// The method returns true if member is CLS-Compliant and false if member is not
@@ -435,8 +442,11 @@ namespace Mono.CSharp {
                protected virtual bool VerifyClsCompliance (DeclSpace ds)
                {
                        if (!IsClsCompliaceRequired (ds)) {
-                               if ((RootContext.WarningLevel >= 2) && HasClsCompliantAttribute && !IsExposedFromAssembly (ds)) {
-                                       Report.Warning (3019, Location, "CLS compliance checking will not be performed on '{0}' because it is private or internal", GetSignatureForError ());
+                               if (HasClsCompliantAttribute && RootContext.WarningLevel >= 2) {
+                                       if (!IsExposedFromAssembly (ds))
+                                               Report.Warning (3019, Location, "CLS compliance checking will not be performed on '{0}' because it is private or internal", GetSignatureForError ());
+                                       if (!CodeGen.Assembly.IsClsCompliant)
+                                               Report.Warning (3021, Location, "'{0}' does not need a CLSCompliant attribute because the assembly does not have a CLSCompliant attribute", GetSignatureForError ());
                                }
                                return false;
                        }
@@ -515,7 +525,7 @@ namespace Mono.CSharp {
                //
                public NamespaceEntry NamespaceEntry;
 
-               public Hashtable Cache = new Hashtable ();
+               private Hashtable Cache = new Hashtable ();
                
                public string Basename;
                
@@ -565,7 +575,7 @@ namespace Mono.CSharp {
                /// <summary>
                /// Adds the member to defined_names table. It tests for duplications and enclosing name conflicts
                /// </summary>
-               protected bool AddToContainer (MemberCore symbol, bool is_method, string fullname, string basename)
+               protected bool AddToContainer (MemberCore symbol, string fullname, string basename)
                {
                        if (basename == Basename && !(this is Interface)) {
                                if (symbol is TypeParameter)
@@ -581,26 +591,23 @@ namespace Mono.CSharp {
 
                        MemberCore mc = (MemberCore)defined_names [fullname];
 
-                       if (is_method && (mc is MethodCore || mc is IMethodData)) {
-                               symbol.caching_flags |= Flags.TestMethodDuplication;
-                               mc.caching_flags |= Flags.TestMethodDuplication;
+                       if (mc == null) {
+                               defined_names.Add (fullname, symbol);
                                return true;
                        }
 
-                       if (mc != null) {
-                               if (symbol is TypeParameter)
-                                       Report.Error (692, symbol.Location, "Duplicate type parameter `{0}'", basename);
-                               else {
-                                       Report.SymbolRelatedToPreviousError (mc);
-                                       Report.Error (102, symbol.Location,
-                                                     "The type '{0}' already contains a definition for '{1}'",
-                                                     GetSignatureForError (), basename);
-                               }
-                               return false;
-                       }
+                       if (symbol.MarkForDuplicationCheck () && mc.MarkForDuplicationCheck ())
+                               return true;
 
-                       defined_names.Add (fullname, symbol);
-                       return true;
+                       if (symbol is TypeParameter)
+                               Report.Error (692, symbol.Location, "Duplicate type parameter `{0}'", basename);
+                       else {
+                               Report.SymbolRelatedToPreviousError (mc);
+                               Report.Error (102, symbol.Location,
+                                             "The type '{0}' already contains a definition for '{1}'",
+                                             GetSignatureForError (), basename);
+                       }
+                       return false;
                }
 
                public void RecordDecl ()
@@ -634,17 +641,6 @@ namespace Mono.CSharp {
                                in_transit = value;
                        }
                }
-
-               /// <summary>
-               ///   Looks up the alias for the name
-               /// </summary>
-               public IAlias LookupAlias (string name)
-               {
-                       if (NamespaceEntry != null)
-                               return NamespaceEntry.LookupAlias (name);
-                       else
-                               return null;
-               }
                
                // 
                // root_types contains all the types.  All TopLevel types
@@ -714,24 +710,17 @@ namespace Mono.CSharp {
                }
 
                EmitContext type_resolve_ec;
-               EmitContext GetTypeResolveEmitContext (TypeContainer parent, Location loc)
-               {
-                       type_resolve_ec = new EmitContext (parent, this, loc, null, null, ModFlags, false);
-                       type_resolve_ec.ResolvingTypeTree = true;
 
-                       return type_resolve_ec;
-               }
-
-               public Type ResolveNestedType (Type t, Location loc)
+               public FullNamedExpression ResolveNestedType (FullNamedExpression t, Location loc)
                {
-                       TypeContainer tc = TypeManager.LookupTypeContainer (t);
+                       TypeContainer tc = TypeManager.LookupTypeContainer (t.Type);
                        if ((tc != null) && tc.IsGeneric) {
                                if (!IsGeneric) {
-                                       int tnum = TypeManager.GetNumberOfTypeArguments (t);
+                                       int tnum = TypeManager.GetNumberOfTypeArguments (t.Type);
                                        Report.Error (305, loc,
                                                      "Using the generic type `{0}' " +
                                                      "requires {1} type arguments",
-                                                     TypeManager.GetFullName (t), tnum);
+                                                     TypeManager.GetFullName (t.Type), tnum);
                                        return null;
                                }
 
@@ -741,12 +730,8 @@ namespace Mono.CSharp {
                                else
                                        args = TypeParameters;
 
-                               TypeExpr ctype = new ConstructedType (t, args, loc);
-                               ctype = ctype.ResolveAsTypeTerminal (ec);
-                               if (ctype == null)
-                                       return null;
-
-                               t = ctype.Type;
+                               TypeExpr ctype = new ConstructedType (t.Type, args, loc);
+                               return ctype.ResolveAsTypeTerminal (ec);
                        }
 
                        return t;
@@ -756,10 +741,19 @@ namespace Mono.CSharp {
                //    Resolves the expression `e' for a type, and will recursively define
                //    types.  This should only be used for resolving base types.
                // </summary>
-               public TypeExpr ResolveTypeExpr (Expression e, Location loc)
+               public TypeExpr ResolveBaseTypeExpr (Expression e, bool silent, Location loc)
                {
-                       if (type_resolve_ec == null)
-                               type_resolve_ec = GetTypeResolveEmitContext (Parent, loc);
+                       if (type_resolve_ec == null) {
+                               // FIXME: I think this should really be one of:
+                               //
+                               // a. type_resolve_ec = Parent.EmitContext;
+                               // b. type_resolve_ec = new EmitContext (Parent, Parent, loc, null, null, ModFlags, false);
+                               //
+                               // However, if Parent == RootContext.Tree.Types, its NamespaceEntry will be null.
+                               //
+                               type_resolve_ec = new EmitContext (Parent, this, loc, null, null, ModFlags, false);
+                               type_resolve_ec.ResolvingTypeTree = true;
+                       }
                        type_resolve_ec.loc = loc;
                        if (this is GenericMethod)
                                type_resolve_ec.ContainerType = Parent.TypeBuilder;
@@ -987,16 +981,17 @@ namespace Mono.CSharp {
                        return tc.DefineType ();
                }
                
-               Type LookupInterfaceOrClass (string ns, string name, out bool error)
+               FullNamedExpression LookupInterfaceOrClass (string ns, string name, out bool error)
                {
                        DeclSpace parent;
+                       FullNamedExpression result;
                        Type t;
                        object r;
                        
                        error = false;
 
                        if (dh.Lookup (ns, name, out r))
-                               return (Type) r;
+                               return (FullNamedExpression) r;
                        else {
                                if (ns != ""){
                                        if (Namespace.IsNamespace (ns)){
@@ -1009,8 +1004,23 @@ namespace Mono.CSharp {
                        }
                        
                        if (t != null) {
-                               dh.Insert (ns, name, t);
-                               return t;
+                               result = new TypeExpression (t, Location.Null);
+                               dh.Insert (ns, name, result);
+                               return result;
+                       }
+
+                       if (ns != "" && Namespace.IsNamespace (ns)) {
+                               result = Namespace.LookupNamespace (ns, false).Lookup (this, name, Location.Null);
+                               if (result != null) {
+                                       dh.Insert (ns, name, result);
+                                       return result;
+                               }
+                       }
+
+                       if (ns == "" && Namespace.IsNamespace (name)) {
+                               result = Namespace.LookupNamespace (name, false);
+                               dh.Insert (ns, name, result);
+                               return result;
                        }
 
                        //
@@ -1021,7 +1031,10 @@ namespace Mono.CSharp {
                                ns = MakeFQN (ns, name.Substring (0, p));
                                name = name.Substring (p+1);
                        }
-                       
+
+                       if (ns.IndexOf ('+') != -1)
+                               ns = ns.Replace ('+', '.');
+
                        parent = RootContext.Tree.LookupByNamespace (ns, name);
                        if (parent == null) {
                                dh.Insert (ns, name, null);
@@ -1034,8 +1047,9 @@ namespace Mono.CSharp {
                                return null;
                        }
                        
-                       dh.Insert (ns, name, t);
-                       return t;
+                       result = new TypeExpression (t, Location.Null);
+                       dh.Insert (ns, name, result);
+                       return result;
                }
 
                public static void Error_AmbiguousTypeReference (Location loc, string name, string t1, string t2)
@@ -1048,7 +1062,7 @@ namespace Mono.CSharp {
                public Type FindNestedType (Location loc, string name,
                                            out DeclSpace containing_ds)
                {
-                       Type t;
+                       FullNamedExpression t;
                        bool error;
 
                        containing_ds = this;
@@ -1063,8 +1077,8 @@ namespace Mono.CSharp {
                                        if (error)
                                                return null;
 
-                                       if ((t != null) && containing_ds.CheckAccessLevel (t))
-                                               return t;
+                                       if ((t != null) && containing_ds.CheckAccessLevel (t.Type))
+                                               return t.Type;
 
                                        current_type = current_type.BaseType;
                                }
@@ -1086,15 +1100,16 @@ namespace Mono.CSharp {
                ///   during the tree resolution process and potentially define
                ///   recursively the type
                /// </remarks>
-               public Type FindType (Location loc, string name)
+               public FullNamedExpression FindType (Location loc, string name)
                {
-                       Type t;
+                       FullNamedExpression t;
                        bool error;
 
                        //
                        // For the case the type we are looking for is nested within this one
                        // or is in any base class
                        //
+
                        DeclSpace containing_ds = this;
 
                        while (containing_ds != null){
@@ -1108,7 +1123,7 @@ namespace Mono.CSharp {
                                        if (error)
                                                return null;
 
-                                       if ((t != null) && containing_ds.CheckAccessLevel (t))
+                                       if ((t != null) && containing_ds.CheckAccessLevel (t.Type))
                                                return ResolveNestedType (t, loc);
 
                                        current_type = current_type.BaseType;
@@ -1155,34 +1170,27 @@ namespace Mono.CSharp {
                                if (name.IndexOf ('.') > 0)
                                        continue;
 
-                               IAlias alias_value = ns.LookupAlias (name);
-                               if (alias_value != null) {
-                                       t = LookupInterfaceOrClass ("", alias_value.Name, out error);
-                                       if (error)
-                                               return null;
-
-                                       if (t != null)
-                                               return t;
-                               }
+                               t = ns.LookupAlias (name);
+                               if (t != null)
+                                       return t;
 
                                //
                                // Now check the using clause list
                                //
-                               Type match = null;
+                               FullNamedExpression match = null;
                                foreach (Namespace using_ns in ns.GetUsingTable ()) {
                                        match = LookupInterfaceOrClass (using_ns.Name, name, out error);
                                        if (error)
                                                return null;
 
-                                       if (match != null) {
-                                               if (t != null){
-                                                       if (CheckAccessLevel (match)) {
-                                                               Error_AmbiguousTypeReference (loc, name, t.FullName, match.FullName);
-                                                               return null;
-                                                       }
+                                       if ((match != null) && (match is TypeExpr)) {
+                                               Type matched = ((TypeExpr) match).Type;
+                                               if (!CheckAccessLevel (matched))
                                                        continue;
+                                               if (t != null){
+                                                       Error_AmbiguousTypeReference (loc, name, t.FullName, match.FullName);
+                                                       return null;
                                                }
-                                               
                                                t = match;
                                        }
                                }
@@ -1194,6 +1202,76 @@ namespace Mono.CSharp {
                        return null;
                }
 
+               //
+               // Public function used to locate types, this can only
+               // be used after the ResolveTree function has been invoked.
+               //
+               // Returns: Type or null if they type can not be found.
+               //
+               // Come to think of it, this should be a DeclSpace
+               //
+               public FullNamedExpression LookupType (string name, bool silent, Location loc)
+               {
+                       FullNamedExpression e;
+
+                       if (Cache.Contains (name)) {
+                               e = (FullNamedExpression) Cache [name];
+                       } else {
+                               //
+                               // For the case the type we are looking for is nested within this one
+                               // or is in any base class
+                               //
+                               DeclSpace containing_ds = this;
+                               while (containing_ds != null){
+                                       
+                                       // if the member cache has been created, lets use it.
+                                       // the member cache is MUCH faster.
+                                       if (containing_ds.MemberCache != null) {
+                                               Type t = containing_ds.MemberCache.FindNestedType (name);
+                                               if (t == null) {
+                                                       containing_ds = containing_ds.Parent;
+                                                       continue;
+                                               }
+
+                                               e = new TypeExpression (t, Location.Null);
+                                               e = ResolveNestedType (e, Location.Null);
+                                               Cache [name] = e;
+                                               return e;
+                                       }
+                                       
+                                       // no member cache. Do it the hard way -- reflection
+                                       Type current_type = containing_ds.TypeBuilder;
+                                       
+                                       while (current_type != null &&
+                                              current_type != TypeManager.object_type) {
+                                               //
+                                               // nested class
+                                               //
+                                               Type t = TypeManager.LookupType (current_type.FullName + "." + name);
+                                               if (t != null){
+                                                       e = new TypeExpression (t, Location.Null);
+                                                       e = ResolveNestedType (e, Location.Null);
+                                                       Cache [name] = e;
+                                                       return e;
+                                               }
+                                               
+                                               current_type = current_type.BaseType;
+                                       }
+                                       
+                                       containing_ds = containing_ds.Parent;
+                               }
+                               
+                               e = NamespaceEntry.LookupNamespaceOrType (this, name, loc);
+                               if (!silent || e != null)
+                                       Cache [name] = e;
+                       }
+
+                       if (e == null && !silent)
+                               Report.Error (246, loc, "Cannot find type `"+name+"'");
+                       
+                       return e;
+               }
+
                /// <remarks>
                ///   This function is broken and not what you're looking for.  It should only
                ///   be used while the type is still being created since it doesn't use the cache
@@ -1240,7 +1318,7 @@ namespace Mono.CSharp {
                                Attribute cls_attribute = OptAttributes.Search (TypeManager.cls_compliant_attribute_type, ec);
                                if (cls_attribute != null) {
                                        caching_flags |= Flags.HasClsCompliantAttribute;
-                                       if (cls_attribute.GetClsCompliantAttributeValue (this)) {
+                                       if (cls_attribute.GetClsCompliantAttributeValue (ec)) {
                                                caching_flags |= Flags.ClsCompliantAttributeTrue;
                                                return true;
                                        }
@@ -1369,7 +1447,7 @@ namespace Mono.CSharp {
                                type_params [i] = new TypeParameter (Parent, name, constraints, Location);
 
                                string full_name = Name + "." + name;
-                               AddToContainer (type_params [i], false, full_name, name);
+                               AddToContainer (type_params [i], full_name, name);
                        }
                }
 
@@ -1615,12 +1693,12 @@ namespace Mono.CSharp {
                }
 
                /// <summary>
-               ///   Returns the IMemberContainer of the parent class or null if this
+               ///   Returns the IMemberContainer of the base class or null if this
                ///   is an interface or TypeManger.object_type.
                ///   This is used when creating the member cache for a class to get all
-               ///   members from the parent class.
+               ///   members from the base class.
                /// </summary>
-               MemberCache ParentCache {
+               MemberCache BaseCache {
                        get;
                }
 
@@ -1682,10 +1760,10 @@ namespace Mono.CSharp {
                        Timer.IncrementCounter (CounterType.MemberCache);
                        Timer.StartTimer (TimerType.CacheInit);
 
-                       // If we have a parent class (we have a parent class unless we're
+                       // If we have a base class (we have a base class unless we're
                        // TypeManager.object_type), we deep-copy its MemberCache here.
-                       if (Container.ParentCache != null)
-                               member_hash = SetupCache (Container.ParentCache);
+                       if (Container.BaseCache != null)
+                               member_hash = SetupCache (Container.BaseCache);
                        else
                                member_hash = new Hashtable ();
 
@@ -1720,16 +1798,16 @@ namespace Mono.CSharp {
                }
 
                /// <summary>
-               ///   Bootstrap this member cache by doing a deep-copy of our parent.
+               ///   Bootstrap this member cache by doing a deep-copy of our base.
                /// </summary>
-               Hashtable SetupCache (MemberCache parent)
+               Hashtable SetupCache (MemberCache base_class)
                {
                        Hashtable hash = new Hashtable ();
 
-                       if (parent == null)
+                       if (base_class == null)
                                return hash;
 
-                       IDictionaryEnumerator it = parent.member_hash.GetEnumerator ();
+                       IDictionaryEnumerator it = base_class.member_hash.GetEnumerator ();
                        while (it.MoveNext ()) {
                                hash [it.Key] = ((ArrayList) it.Value).Clone ();
                         }
@@ -1812,7 +1890,7 @@ namespace Mono.CSharp {
                                }
 
                                // When this method is called for the current class, the list will
-                               // already contain all inherited members from our parent classes.
+                               // already contain all inherited members from our base classes.
                                // We cannot add new members in front of the list since this'd be an
                                // expensive operation, that's why the list is sorted in reverse order
                                // (ie. members from the current class are coming last).
@@ -2055,9 +2133,9 @@ namespace Mono.CSharp {
 
 
                        // `applicable' is a list of all members with the given member name `name'
-                       // in the current class and all its parent classes.  The list is sorted in
+                       // in the current class and all its base classes.  The list is sorted in
                        // reverse order due to the way how the cache is initialy created (to speed
-                       // things up, we're doing a deep-copy of our parent).
+                       // things up, we're doing a deep-copy of our base).
 
                        for (int i = applicable.Count-1; i >= 0; i--) {
                                CacheEntry entry = (CacheEntry) applicable [i];
@@ -2108,6 +2186,22 @@ namespace Mono.CSharp {
                        return copy;
                }
                
+               // find the nested type @name in @this.
+               public Type FindNestedType (string name)
+               {
+                       ArrayList applicable = (ArrayList) member_hash [name];
+                       if (applicable == null)
+                               return null;
+                       
+                       for (int i = applicable.Count-1; i >= 0; i--) {
+                               CacheEntry entry = (CacheEntry) applicable [i];
+                               if ((entry.EntryType & EntryType.NestedType & EntryType.MaskType) != 0)
+                                       return (Type) entry.Member;
+                       }
+                       
+                       return null;
+               }
+               
                //
                // This finds the method or property for us to override. invocationType is the type where
                // the override is going to be declared, name is the name of the method/property, and
index 5e304f9fb4efed29e050df0d9cdd116e0d73d6a3..70ea16b6a353c01903d4fdc3102d7e1c3e1d68db 100644 (file)
@@ -90,6 +90,12 @@ namespace Mono.CSharp {
                        TypeAttributes attr = Modifiers.TypeAttr (ModFlags, IsTopLevel) |
                                TypeAttributes.Class | TypeAttributes.Sealed;
 
+                       if (TypeManager.multicast_delegate_type == null)
+                               Report.Error (-100, Location, "Internal error: delegate used before " +
+                                             "System.MulticastDelegate is resolved.  This can only " +
+                                             "happen during corlib compilation, when using a delegate " +
+                                             "in any of the `core' classes.  See bug #72015 for details.");
+
                        if (IsTopLevel) {
                                if (TypeManager.NamespaceClash (Name, Location))
                                        return null;
@@ -114,17 +120,20 @@ namespace Mono.CSharp {
                                        param_names [i] = TypeParameters [i].Name;
 
                                GenericTypeParameterBuilder[] gen_params;
-                               
                                gen_params = TypeBuilder.DefineGenericParameters (param_names);
 
-                               for (int i = 0; i < gen_params.Length; i++)
-                                       TypeParameters [i].Define (gen_params [i]);
+                               int offset = CountTypeParameters - CurrentTypeParameters.Length;
+                               for (int i = offset; i < gen_params.Length; i++)
+                                       CurrentTypeParameters [i - offset].Define (gen_params [i]);
 
-                               foreach (TypeParameter type_param in TypeParameters) {
-                                       if (!type_param.DefineType (ec))
+                               foreach (TypeParameter type_param in CurrentTypeParameters) {
+                                       if (!type_param.Resolve (this))
                                                return null;
                                }
 
+                               for (int i = offset; i < gen_params.Length; i++)
+                                       CurrentTypeParameters [i - offset].DefineConstraints ();
+
                                TypeExpr current = new ConstructedType (Name, TypeParameters, Location);
                                current = current.ResolveAsTypeTerminal (ec);
                                if (current == null)
@@ -848,7 +857,7 @@ namespace Mono.CSharp {
                                delegate_instance_expression = ec.GetThis (loc);
 
                        if (delegate_instance_expression != null && delegate_instance_expression.Type.IsValueType)
-                               delegate_instance_expression = new BoxedCast (mg.InstanceExpression);
+                               delegate_instance_expression = new BoxedCast (delegate_instance_expression);
 
                        method_group = mg;
                        eclass = ExprClass.Value;
@@ -926,7 +935,7 @@ namespace Mono.CSharp {
                        Type e_type = e.Type;
 
                        if (!TypeManager.IsDelegateType (e_type)) {
-                               e.Error_UnexpectedKind ("method", loc);
+                               Report.Error (149, loc, "Method name expected");
                                return null;
                        }
 
index 9c0141132ecdc8c3a817c9d40d333e2fce6c7f9b..094cf32a7edb403dfb434dc163709b43933fff4e 100644 (file)
@@ -170,13 +170,11 @@ namespace Mono.CSharp {
 
                                n.WriteTo (RootContext.Documentation.XmlCommentOutput);
                        }
-                       else if (mc.IsExposedFromAssembly (ds) &&
-                               // There are no warnings when the container also
-                               // misses documentations.
-                               (ds == null || ds.DocComment != null))
-                       {
-                               Report.Warning (1591, 4, mc.Location,
-                                       "Missing XML comment for publicly visible type or member '{0}'", mc.GetSignatureForError ());
+                       else if (mc.IsExposedFromAssembly (ds)) {
+                               Constructor c = mc as Constructor;
+                               if (c == null || !c.IsDefault ())
+                                       Report.Warning (1591, 4, mc.Location,
+                                               "Missing XML comment for publicly visible type or member '{0}'", mc.GetSignatureForError ());
                        }
                }
 
@@ -263,8 +261,7 @@ namespace Mono.CSharp {
                // returns a full runtime type name from a name which might
                // be C# specific type name.
                //
-               private static Type FindDocumentedType (MemberCore mc,
-                       string name, DeclSpace ds, bool allowAlias)
+               private static Type FindDocumentedType (MemberCore mc, string name, DeclSpace ds, string cref)
                {
                        bool isArray = false;
                        string identifier = name;
@@ -275,15 +272,14 @@ namespace Mono.CSharp {
                                        isArray = true;
                                }
                        }
-                       Type t = FindDocumentedTypeNonArray (mc, identifier,
-                               ds, allowAlias);
+                       Type t = FindDocumentedTypeNonArray (mc, identifier, ds, cref);
                        if (t != null && isArray)
                                t = Array.CreateInstance (t, 0).GetType ();
                        return t;
                }
 
-               private static Type FindDocumentedTypeNonArray (MemberCore mc,
-                       string identifier, DeclSpace ds, bool allowAlias)
+               private static Type FindDocumentedTypeNonArray (MemberCore mc, 
+                       string identifier, DeclSpace ds, string cref)
                {
                        switch (identifier) {
                        case "int":
@@ -319,15 +315,23 @@ namespace Mono.CSharp {
                        case "void":
                                return typeof (void);
                        }
-                       if (allowAlias) {
-                               IAlias alias = ds.LookupAlias (identifier);
-                               if (alias != null)
-                                       identifier = alias.Name;
-                       }
-                       Type t = ds.FindType (mc.Location, identifier);
-                       if (t == null)
-                               t = TypeManager.LookupTypeDirect (identifier);
-                       return t;
+                       FullNamedExpression e = ds.FindType (mc.Location, identifier);
+                       if (e != null) {
+                               if (!(e is TypeExpr))
+                                       return null;
+                               return ((TypeExpr) e).ResolveType (ds.EmitContext);
+                       }
+                       int index = identifier.LastIndexOf ('.');
+                       if (index < 0)
+                               return null;
+                       int warn;
+                       Type parent = FindDocumentedType (mc, identifier.Substring (0, index), ds, cref);
+                       if (parent == null)
+                               return null;
+                       return FindDocumentedMember (mc, parent,
+                               identifier.Substring (index + 1),
+                               Type.EmptyTypes,
+                               ds, out warn, cref) as Type;
                }
 
                //
@@ -451,7 +455,7 @@ namespace Mono.CSharp {
                                ((PropertyInfo) mi).PropertyType :
                                null;
                        if (returnTypeName != null) {
-                               Type returnType = FindDocumentedType (mc, returnTypeName, ds, true);
+                               Type returnType = FindDocumentedType (mc, returnTypeName, ds, cref);
                                if (returnType == null || returnType != expected) {
                                        warningType = 1581;
                                        Report.Warning (1581, 1, mc.Location, "Invalid return type in XML comment cref attribute '{0}'", cref);
@@ -461,8 +465,6 @@ namespace Mono.CSharp {
                        return mis [0];
                }
 
-               private static Type [] emptyParamList = new Type [0];
-
                //
                // Processes "see" or "seealso" elements.
                // Checks cref attribute.
@@ -480,7 +482,6 @@ namespace Mono.CSharp {
 
                        string signature; // "x:" are stripped
                        string name; // method invokation "(...)" are removed
-                       string identifiers; // array indexer "[]" are removed
                        string parameters; // method parameter list
 
                        // strip 'T:' 'M:' 'F:' 'P:' 'E:' etc.
@@ -527,13 +528,13 @@ namespace Mono.CSharp {
                        }
 
                        // check if parameters are valid
-                       Type [] parameterTypes = emptyParamList;
+                       Type [] parameterTypes = Type.EmptyTypes;
                        if (parameters.Length > 0) {
                                string [] paramList = parameters.Split (',');
                                ArrayList plist = new ArrayList ();
                                for (int i = 0; i < paramList.Length; i++) {
                                        string paramTypeName = paramList [i].Trim (wsChars);
-                                       Type paramType = FindDocumentedType (mc, paramTypeName, ds, true);
+                                       Type paramType = FindDocumentedType (mc, paramTypeName, ds, cref);
                                        if (paramType == null) {
                                                Report.Warning (1580, 1, mc.Location, "Invalid type for parameter '{0}' in XML comment cref attribute '{1}'", i + 1, cref);
                                                return;
@@ -553,7 +554,7 @@ namespace Mono.CSharp {
                                parameters = sb.ToString ();
                        }
 
-                       Type type = FindDocumentedType (mc, name, ds, true);
+                       Type type = FindDocumentedType (mc, name, ds, cref);
                        if (type != null) {
                                xref.SetAttribute ("cref", "T:" + type.FullName.Replace ("+", "."));
                                return; // a type
@@ -569,7 +570,7 @@ namespace Mono.CSharp {
                        if (period > 0) {
                                string typeName = name.Substring (0, period);
                                string memberName = name.Substring (period + 1);
-                               type = FindDocumentedType (mc, typeName, ds, false);
+                               type = FindDocumentedType (mc, typeName, ds, cref);
                                int warnResult;
                                if (type != null) {
                                        MemberInfo mi = FindDocumentedMember (mc, type, memberName, parameterTypes, ds, out warnResult, cref);
@@ -648,7 +649,17 @@ namespace Mono.CSharp {
                                paramSpec += ")";
 
                        string name = mc is Constructor ? "#ctor" : mc.Name;
-                       return String.Concat (mc.DocCommentHeader, ds.Name, ".", name, paramSpec);
+                       string suffix = String.Empty;
+                       Operator op = mc as Operator;
+                       if (op != null) {
+                               switch (op.OperatorType) {
+                               case Operator.OpType.Implicit:
+                               case Operator.OpType.Explicit:
+                                       suffix = "~" + op.OperatorMethodBuilder.ReturnType.FullName.Replace ('+', '.');
+                                       break;
+                               }
+                       }
+                       return String.Concat (mc.DocCommentHeader, ds.Name, ".", name, paramSpec, suffix);
                }
 
                //
@@ -674,7 +685,6 @@ namespace Mono.CSharp {
                                paramTags [xname] = xname;
                        }
                        Parameter [] plist = mc.Parameters.FixedParameters;
-                       Parameter parr = mc.Parameters.ArrayParameter;
                        if (plist != null) {
                                foreach (Parameter p in plist) {
                                        if (paramTags.Count > 0 && paramTags [p.Name] == null)
index c76972509181f4e6083a1ae7d6c44427f4b7cf9b..35aafa8592de39a2521916ab5596b9e82a06e880 100644 (file)
@@ -20,7 +20,6 @@ namespace Mono.CSharp
        using System.Text;
        using System.Globalization;
        using System.Xml;
-       using System.Diagnostics;
 
        public enum Target {
                Library, Exe, Module, WinExe
@@ -63,7 +62,6 @@ namespace Mono.CSharp
                static bool timestamps = false;
                static bool pause = false;
                static bool show_counters = false;
-               public static bool parser_verbose = false;
                
                //
                // Whether to load the initial config file (what CSC.RSP has by default)
@@ -270,11 +268,9 @@ namespace Mono.CSharp
                        bool ok = MainDriver (args);
                        
                        if (ok && Report.Errors == 0) {
-                               Console.Write("Compilation succeeded");
                                if (Report.Warnings > 0) {
-                                       Console.Write(" - {0} warning(s)", Report.Warnings);
+                                       Console.WriteLine ("Compilation succeeded - {0} warning(s)", Report.Warnings);
                                }
-                               Console.WriteLine();
                                if (show_counters){
                                        Console.WriteLine ("Counter1: " + counter1);
                                        Console.WriteLine ("Counter2: " + counter2);
@@ -301,7 +297,7 @@ namespace Mono.CSharp
                                        a = Assembly.LoadFrom (assembly);
                                } else {
                                        string ass = assembly;
-                                       if (ass.EndsWith (".dll"))
+                                       if (ass.EndsWith (".dll") || ass.EndsWith (".exe"))
                                                ass = assembly.Substring (0, assembly.Length - 4);
                                        a = Assembly.Load (ass);
                                }
@@ -310,7 +306,7 @@ namespace Mono.CSharp
                        } catch (FileNotFoundException){
                                foreach (string dir in link_paths){
                                        string full_path = Path.Combine (dir, assembly);
-                                       if (!assembly.EndsWith (".dll"))
+                                       if (!assembly.EndsWith (".dll") && !assembly.EndsWith (".exe"))
                                                full_path += ".dll";
 
                                        try {
@@ -1316,10 +1312,23 @@ namespace Mono.CSharp
                static string [] AddArgs (string [] args, string [] extra_args)
                {
                        string [] new_args;
-
                        new_args = new string [extra_args.Length + args.Length];
-                       args.CopyTo (new_args, 0);
-                       extra_args.CopyTo (new_args, args.Length);
+
+                       // if args contains '--' we have to take that into account
+                       // split args into first half and second half based on '--'
+                       // and add the extra_args before --
+                       int split_position = Array.IndexOf (args, "--");
+                       if (split_position != -1)
+                       {
+                               Array.Copy (args, new_args, split_position);
+                               extra_args.CopyTo (new_args, split_position);
+                               Array.Copy (args, split_position, new_args, split_position + extra_args.Length, args.Length - split_position);
+                       }
+                       else
+                       {
+                               args.CopyTo (new_args, 0);
+                               extra_args.CopyTo (new_args, args.Length);
+                       }
 
                        return new_args;
                }
@@ -1422,6 +1431,13 @@ namespace Mono.CSharp
                        if (tokenize)
                                return true;
                        
+                       //
+                       // This will point to the NamespaceEntry of the last file that was parsed, and may
+                       // not be meaningful when resolving classes from other files.  So, reset it to prevent
+                       // silent bugs.
+                       //
+                       RootContext.Tree.Types.NamespaceEntry = null;
+
                        //
                        // If we are an exe, require a source file for the entry point
                        //
@@ -1452,7 +1468,7 @@ namespace Mono.CSharp
                        //
                        // Load Core Library for default compilation
                        //
-                       if (RootContext.StdLib) 
+                       if (RootContext.StdLib)
                                references.Insert (0, "mscorlib");
 
                        if (load_default_config)
@@ -1612,7 +1628,7 @@ namespace Mono.CSharp
 
                                if (ep == null) {
                                        if (RootContext.MainClass != null) {
-                                               object main_cont = RootContext.Tree.Decls [RootContext.MainClass];
+                                               DeclSpace main_cont = RootContext.Tree.Decls [RootContext.MainClass] as DeclSpace;
                                                if (main_cont == null) {
                                                        Report.Error (1555, output_file, "Could not find '{0}' specified for Main method", RootContext.MainClass); 
                                                        return false;
@@ -1622,6 +1638,9 @@ namespace Mono.CSharp
                                                        Report.Error (1556, output_file, "'{0}' specified for Main method must be a valid class or struct", RootContext.MainClass);
                                                        return false;
                                                }
+
+                                               Report.Error (1558, main_cont.Location, "'{0}' does not have a suitable static Main method", main_cont.GetSignatureForError ());
+                                               return false;
                                        }
 
                                        if (Report.Errors == 0)
index 87e2815a583a986c3a826bab8902b6b1c8de0c62..4fb48ea2434a804d5654c938b07583b720961938 100644 (file)
@@ -51,20 +51,15 @@ namespace Mono.CSharp {
                // Returns a method group.
                MethodGroup             = 4,
 
-               // Allows SimpleNames to be returned.
-               // This is used by MemberAccess to construct long names that can not be
-               // partially resolved (namespace-qualified names for example).
-               SimpleName              = 8,
-
                // Mask of all the expression class flags.
-               MaskExprClass           = 15,
+               MaskExprClass           = 7,
 
                // Disable control flow analysis while resolving the expression.
                // This is used when resolving the instance expression of a field expression.
-               DisableFlowAnalysis     = 16,
+               DisableFlowAnalysis     = 8,
 
                // Set if this is resolving the first part of a MemberAccess.
-               Intermediate            = 32
+               Intermediate            = 16
        }
 
        //
@@ -235,9 +230,9 @@ namespace Mono.CSharp {
                        //
                        if (ma == MethodAttributes.Private) {
                                Type declaring_type = mi.DeclaringType;
-                                       
+
                                if (invocation_type != declaring_type)
-                                       return TypeManager.IsNestedFamilyAccessible (invocation_type, declaring_type);
+                                       return TypeManager.IsNestedChildOf (invocation_type, declaring_type);
 
                                return true;
                        }
@@ -308,11 +303,10 @@ namespace Mono.CSharp {
                }
 
                //
-               // This is used if the expression should be resolved as a type.
-               // the default implementation fails.   Use this method in
-               // those participants in the SimpleName chain system.
+               // This is used if the expression should be resolved as a type or namespace name.
+               // the default implementation fails.   
                //
-               public virtual Expression ResolveAsTypeStep (EmitContext ec)
+               public virtual FullNamedExpression ResolveAsTypeStep (EmitContext ec)
                {
                        return null;
                }
@@ -326,14 +320,23 @@ namespace Mono.CSharp {
                {
                        int errors = Report.Errors;
 
-                       TypeExpr te = ResolveAsTypeStep (ec) as TypeExpr;
+                       FullNamedExpression fne = ResolveAsTypeStep (ec);
 
-                       if ((te == null) || (te.eclass != ExprClass.Type) || (te.Type == null)) {
+                       if (fne == null) {
                                if (errors == Report.Errors)
                                        Report.Error (246, Location, "Cannot find type '{0}'", ToString ());
                                return null;
                        }
 
+                       if (fne.eclass != ExprClass.Type) {
+                               if (errors == Report.Errors)
+                                       Report.Error (118, Location, "'{0}' denotes a '{1}', where a type was expected",
+                                                     fne.FullName, fne.ExprClassName ());
+                               return null;
+                       }
+
+                       TypeExpr te = fne as TypeExpr;
+
                        if (!te.CheckAccessLevel (ec.DeclSpace)) {
                                Report.Error (122, Location, "'{0}' is inaccessible due to its protection level", te.Name);
                                return null;
@@ -372,19 +375,7 @@ namespace Mono.CSharp {
                        if (e == null)
                                return null;
 
-                       if (e is SimpleName){
-                               SimpleName s = (SimpleName) e;
-
-                               if ((flags & ResolveFlags.SimpleName) == 0) {
-                                       MemberLookupFailed (ec, null, ec.ContainerType, s.Name,
-                                                           ec.DeclSpace.Name, loc);
-                                       return null;
-                               }
-
-                               return s;
-                       }
-
-                       if ((e is TypeExpr) || (e is ComposedCast)) {
+                       if ((e is TypeExpr) || (e is ComposedCast) || (e is Namespace)) {
                                if ((flags & ResolveFlags.Type) == 0) {
                                        e.Error_UnexpectedKind (flags, loc);
                                        return null;
@@ -395,6 +386,7 @@ namespace Mono.CSharp {
 
                        switch (e.eclass) {
                        case ExprClass.Type:
+                       case ExprClass.Namespace:
                                if ((flags & ResolveFlags.VariableOrValue) == 0) {
                                        e.Error_UnexpectedKind (flags, loc);
                                        return null;
@@ -431,11 +423,12 @@ namespace Mono.CSharp {
                                                     " ExprClass is Invalid after resolve");
                        }
 
-                       if (e.type == null)
+                       if (e.type == null && !(e is Namespace)) {
                                throw new Exception (
                                        "Expression " + e.GetType () +
                                        " did not set its type after Resolve\n" +
                                        "called from: " + this.GetType ());
+                       }
 
                        return e;
                }
@@ -588,8 +581,7 @@ namespace Mono.CSharp {
                        return null;
                }
 
-
-               private static ArrayList almostMatchedMembers = new ArrayList (4);
+               protected static ArrayList almostMatchedMembers = new ArrayList (4);
 
                //
                // FIXME: Probably implement a cache for (t,name,current_access_set)?
@@ -741,16 +733,28 @@ namespace Mono.CSharp {
                                if (qualifier_type != ec.ContainerType) {
                                        // Although a derived class can access protected members of
                                        // its base class it cannot do so through an instance of the
-                                       // base class (CS1540).  If the qualifier_type is a parent of the
+                                       // base class (CS1540).  If the qualifier_type is a base of the
                                        // ec.ContainerType and the lookup succeeds with the latter one,
                                        // then we are in this situation.
-                                       foreach (MemberInfo m in almostMatchedMembers)
+                                       for (int i = 0; i < almostMatchedMembers.Count; ++i) {
+                                               MemberInfo m = (MemberInfo) almostMatchedMembers [i];
+                                               for (int j = 0; j < i; ++j) {
+                                                       if (m == almostMatchedMembers [j]) {
+                                                               m = null;
+                                                               break;
+                                                       }
+                                               }
+                                               if (m == null)
+                                                       continue;
+
+                                               Report.SymbolRelatedToPreviousError (m);
                                                Report.Error (1540, loc, 
                                                              "Cannot access protected member `{0}' via a qualifier of type `{1}';"
                                                              + " the qualifier must be of type `{2}' (or derived from it)", 
                                                              TypeManager.GetFullNameSignature (m),
                                                              TypeManager.CSharpName (qualifier_type),
                                                              TypeManager.CSharpName (ec.ContainerType));
+                                       }
                                        return;
                                }
                                almostMatchedMembers.Clear ();
@@ -786,13 +790,15 @@ namespace Mono.CSharp {
                                }
                        }
 
+                       if (name == ".ctor" && TypeManager.FindMembers (qualifier_type, MemberTypes.Constructor,
+                               BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly, null, null).Count == 0)
+                       {
+                               Report.Error (143, loc, String.Format ("The type '{0}' has no constructors defined", TypeManager.CSharpName (queried_type)));
+                               return;
+                       }
 
-
-                       if (qualifier_type != null)
+                       if (qualifier_type != null) {
                                Report.Error (122, loc, "'{0}' is inaccessible due to its protection level", TypeManager.CSharpName (qualifier_type) + "." + name);
-                       else if (name == ".ctor") {
-                               Report.Error (143, loc, String.Format ("The type {0} has no constructors defined",
-                                                                      TypeManager.CSharpName (queried_type)));
                        } else {
                                Report.Error (122, loc, "'{0}' is inaccessible due to its protection level", name);
                }
@@ -872,9 +878,9 @@ namespace Mono.CSharp {
                        return operator_true;
                }
                
-               static string ExprClassName (ExprClass c)
+               public string ExprClassName ()
                {
-                       switch (c){
+                       switch (eclass){
                        case ExprClass.Invalid:
                                return "Invalid";
                        case ExprClass.Value:
@@ -904,11 +910,7 @@ namespace Mono.CSharp {
                /// </summary>
                public void Error_UnexpectedKind (string expected, Location loc)
                {
-                       string kind = "Unknown";
-                       
-                       kind = ExprClassName (eclass);
-
-                       Report.Error (118, loc, "Expression denotes a `" + kind +
+                       Report.Error (118, loc, "Expression denotes a `" + ExprClassName () +
                               "' where a `" + expected + "' was expected");
                }
 
@@ -927,9 +929,6 @@ namespace Mono.CSharp {
                        if ((flags & ResolveFlags.MethodGroup) != 0)
                                valid.Add ("method group");
 
-                       if ((flags & ResolveFlags.SimpleName) != 0)
-                               valid.Add ("simple name");
-
                        if (valid.Count == 0)
                                valid.Add ("unknown");
 
@@ -942,9 +941,7 @@ namespace Mono.CSharp {
                                sb.Append (valid [i]);
                        }
 
-                       string kind = ExprClassName (eclass);
-
-                       Error (119, "Expression denotes a `" + kind + "' where " +
+                       Error (119, "Expression denotes a `" + ExprClassName () + "' where " +
                               "a `" + sb.ToString () + "' was expected");
                }
                
@@ -1022,7 +1019,7 @@ namespace Mono.CSharp {
                                }
 
                                s = v.ToString ();
-                       } else if (c is UIntConstant){
+                       } else if (c is UIntConstant){
                                uint v = ((UIntConstant) c).Value;
 
                                if (target_type == TypeManager.int32_type){
@@ -1048,7 +1045,7 @@ namespace Mono.CSharp {
                                else if (target_type == TypeManager.uint64_type)
                                        return (ulong) v;
                                s = v.ToString ();
-                       } else if (c is LongConstant){ 
+                       } else if (c is LongConstant){ 
                                long v = ((LongConstant) c).Value;
 
                                if (target_type == TypeManager.int32_type){
@@ -1077,7 +1074,7 @@ namespace Mono.CSharp {
                                                return (ulong) v;
                                }
                                s = v.ToString ();
-                       } else if (c is ULongConstant){
+                       } else if (c is ULongConstant){
                                ulong v = ((ULongConstant) c).Value;
 
                                if (target_type == TypeManager.int32_type){
@@ -2003,54 +2000,17 @@ namespace Mono.CSharp {
        }
        
        /// <summary>
-       ///   SimpleName expressions are initially formed of a single
-       ///   word and it only happens at the beginning of the expression.
+       ///   SimpleName expressions are formed of a single word and only happen at the beginning 
+       ///   of a dotted-name.
        /// </summary>
-       ///
-       /// <remarks>
-       ///   The expression will try to be bound to a Field, a Method
-       ///   group or a Property.  If those fail we pass the name to our
-       ///   caller and the SimpleName is compounded to perform a type
-       ///   lookup.  The idea behind this process is that we want to avoid
-       ///   creating a namespace map from the assemblies, as that requires
-       ///   the GetExportedTypes function to be called and a hashtable to
-       ///   be constructed which reduces startup time.  If later we find
-       ///   that this is slower, we should create a `NamespaceExpr' expression
-       ///   that fully participates in the resolution process. 
-       ///   
-       ///   For example `System.Console.WriteLine' is decomposed into
-       ///   MemberAccess (MemberAccess (SimpleName ("System"), "Console"), "WriteLine")
-       ///   
-       ///   The first SimpleName wont produce a match on its own, so it will
-       ///   be turned into:
-       ///   MemberAccess (SimpleName ("System.Console"), "WriteLine").
-       ///   
-       ///   System.Console will produce a TypeExpr match.
-       ///   
-       ///   The downside of this is that we might be hitting `LookupType' too many
-       ///   times with this scheme.
-       /// </remarks>
        public class SimpleName : Expression {
                public string Name;
                public readonly TypeArguments Arguments;
 
-               //
-               // If true, then we are a simple name, not composed with a ".
-               //
-               bool is_base;
-
-               public SimpleName (string a, string b, Location l)
-               {
-                       Name = String.Concat (a, ".", b);
-                       loc = l;
-                       is_base = false;
-               }
-               
                public SimpleName (string name, Location l)
                {
                        Name = name;
                        loc = l;
-                       is_base = true;
                }
 
                public SimpleName (string name, TypeArguments args, Location l)
@@ -2058,7 +2018,6 @@ namespace Mono.CSharp {
                        Name = name;
                        Arguments = args;
                        loc = l;
-                       is_base = true;
                }
 
                public static void Error_ObjectRefRequired (EmitContext ec, Location l, string name)
@@ -2109,60 +2068,23 @@ namespace Mono.CSharp {
                        return SimpleNameResolve (ec, null, true, intermediate);
                }
 
-               public override Expression ResolveAsTypeStep (EmitContext ec)
+               public override FullNamedExpression ResolveAsTypeStep (EmitContext ec)
                {
                        DeclSpace ds = ec.DeclSpace;
-                       NamespaceEntry ns = ds.NamespaceEntry;
-                       Type t;
-                       IAlias alias_value;
-
-                       //
-                       // Since we are cheating: we only do the Alias lookup for
-                       // namespaces if the name does not include any dots in it
-                       //
-                       if (ns != null && is_base)
-                               alias_value = ns.LookupAlias (Name);
-                       else
-                               alias_value = null;
+                       FullNamedExpression dt;
 
-                       TypeParameterExpr generic_type = ds.LookupGeneric (Name, loc);
-                       if (generic_type != null)
-                               return generic_type.ResolveAsTypeTerminal (ec);
+                       dt = ds.LookupGeneric (Name, loc);
+                       if (dt != null)
+                               return dt.ResolveAsTypeStep (ec);
 
-                       if (ec.ResolvingTypeTree){
-                               int errors = Report.Errors;
-                               Type dt = ds.FindType (loc, Name);
-                               
-                               if (Report.Errors != errors)
-                                       return null;
-                               
-                               if (dt != null)
-                                       return new TypeExpression (dt, loc);
-
-                               if (alias_value != null){
-                                       if (alias_value.IsType)
-                                               return alias_value.ResolveAsType (ec);
-                                       if ((t = RootContext.LookupType (ds, alias_value.Name, true, loc)) != null)
-                                               return new TypeExpression (t, loc);
-                               }
-                       }
-
-                       if ((t = RootContext.LookupType (ds, Name, true, loc)) != null)
-                               return new TypeExpression (t, loc);
-
-                       if (alias_value != null) {
-                               if (alias_value.IsType)
-                                       return alias_value.ResolveAsType (ec);
-                               if ((t = RootContext.LookupType (ds, alias_value.Name, true, loc)) != null)
-                                       return new TypeExpression (t, loc);
-                               
-                               // we have alias value, but it isn't Type, so try if it's namespace
-                               return new SimpleName (alias_value.Name, loc);
-                       }
+                       int errors = Report.Errors;
+                       dt = ec.ResolvingTypeTree 
+                               ? ds.FindType (loc, Name)
+                               : ds.LookupType (Name, true, loc);
+                       if (Report.Errors != errors)
+                               return null;
 
-                       // No match, maybe our parent can compose us
-                       // into something meaningful.
-                       return this;
+                       return dt;
                }
 
                Expression SimpleNameResolve (EmitContext ec, Expression right_side,
@@ -2174,12 +2096,9 @@ namespace Mono.CSharp {
 
                        Block current_block = ec.CurrentBlock;
                        if (current_block != null){
-                               //LocalInfo vi = current_block.GetLocalInfo (Name);
-                               if (is_base &&
-                                   current_block.IsVariableNameUsedInChildBlock(Name)) {
+                               if (current_block.IsVariableNameUsedInChildBlock (Name)) {
                                        Report.Error (135, Location,
-                                                     "'{0}' has a different meaning in a " +
-                                                     "child block", Name);
+                                                     "'{0}' has a different meaning in a child block", Name);
                                        return null;
                                }
                        }
@@ -2244,6 +2163,8 @@ namespace Mono.CSharp {
                        //
 
                        DeclSpace lookup_ds = ec.DeclSpace;
+                       Type almost_matched_type = null;
+                       ArrayList almost_matched = null;
                        do {
                                if (lookup_ds.TypeBuilder == null)
                                        break;
@@ -2252,6 +2173,11 @@ namespace Mono.CSharp {
                                if (e != null)
                                        break;
 
+                               if (almost_matched == null && almostMatchedMembers.Count > 0) {
+                                       almost_matched_type = lookup_ds.TypeBuilder;
+                                       almost_matched = (ArrayList) almostMatchedMembers.Clone ();
+                               }
+
                                lookup_ds =lookup_ds.Parent;
                        } while (lookup_ds != null);
 
@@ -2259,32 +2185,20 @@ namespace Mono.CSharp {
                                e = MemberLookup (ec, ec.ContainerType, Name, loc);
 
                        if (e == null) {
-                               //
-                               // Since we are cheating (is_base is our hint
-                               // that we are the beginning of the name): we
-                               // only do the Alias lookup for namespaces if
-                               // the name does not include any dots in it
-                               //
-                               NamespaceEntry ns = ec.DeclSpace.NamespaceEntry;
-                               if (is_base && ns != null){
-                                       IAlias alias_value = ns.LookupAlias (Name);
-                                       if (alias_value != null){
-                                               if (alias_value.IsType)
-                                                       return alias_value.ResolveAsType (ec);
-
-                                               Name = alias_value.Name;
-                                               Type t;
-
-                                               if ((t = TypeManager.LookupType (Name)) != null)
-                                                       return new TypeExpression (t, loc);
-                                       
-                                               // No match, maybe our parent can compose us
-                                               // into something meaningful.
-                                               return this;
-                                       }
+                               if (almost_matched == null && almostMatchedMembers.Count > 0) {
+                                       almost_matched_type = ec.ContainerType;
+                                       almost_matched = (ArrayList) almostMatchedMembers.Clone ();
                                }
+                               e = ResolveAsTypeStep (ec);
+                       }
 
-                               return ResolveAsTypeStep (ec);
+                       if (e == null) {
+                               if (almost_matched != null)
+                                       almostMatchedMembers = almost_matched;
+                               if (almost_matched_type == null)
+                                       almost_matched_type = ec.ContainerType;
+                               MemberLookupFailed (ec, null, almost_matched_type, ((SimpleName) this).Name, ec.DeclSpace.Name, loc);
+                               return null;
                        }
 
                        if (e is TypeExpr)
@@ -2355,12 +2269,22 @@ namespace Mono.CSharp {
                        return Name;
                }
        }
+
+       /// <summary>
+       ///   Represents a namespace or a type.  The name of the class was inspired by
+       ///   section 10.8.1 (Fully Qualified Names).
+       /// </summary>
+       public abstract class FullNamedExpression : Expression {
+               public abstract string FullName {
+                       get;
+               }
+       }
        
        /// <summary>
        ///   Fully resolved expression that evaluates to a type
        /// </summary>
-       public abstract class TypeExpr : Expression, IAlias {
-               override public Expression ResolveAsTypeStep (EmitContext ec)
+       public abstract class TypeExpr : FullNamedExpression {
+               override public FullNamedExpression ResolveAsTypeStep (EmitContext ec)
                {
                        TypeExpr t = DoResolveAsTypeStep (ec);
                        if (t == null)
@@ -2427,6 +2351,15 @@ namespace Mono.CSharp {
 
                protected abstract TypeExpr DoResolveAsTypeStep (EmitContext ec);
 
+               public virtual Type ResolveType (EmitContext ec)
+               {
+                       TypeExpr t = ResolveAsTypeTerminal (ec);
+                       if (t == null)
+                               return null;
+
+                       return t.Type;
+               }
+
                public abstract string Name {
                        get;
                }
@@ -2449,18 +2382,9 @@ namespace Mono.CSharp {
                {
                        return Name;
                }
-
-               bool IAlias.IsType {
-                       get { return true; }
-               }
-
-               TypeExpr IAlias.ResolveAsType (EmitContext ec)
-               {
-                       return ResolveAsTypeTerminal (ec);
-               }
        }
 
-       public class TypeExpression : TypeExpr, IAlias {
+       public class TypeExpression : TypeExpr {
                public TypeExpression (Type t, Location l)
                {
                        Type = t;
@@ -2479,7 +2403,7 @@ namespace Mono.CSharp {
                        }
                }
 
-               string IAlias.Name {
+               public override string FullName {
                        get {
                                return Type.FullName != null ? Type.FullName : Type.Name;
                        }
@@ -2502,10 +2426,12 @@ namespace Mono.CSharp {
                protected override TypeExpr DoResolveAsTypeStep (EmitContext ec)
                {
                        if (type == null) {
-                               type = RootContext.LookupType (
-                                       ec.DeclSpace, name, false, Location.Null);
-                               if (type == null)
+                               FullNamedExpression t = ec.DeclSpace.LookupType (name, false, Location.Null);
+                               if (t == null)
+                                       return null;
+                               if (!(t is TypeExpr))
                                        return null;
+                               type = ((TypeExpr) t).ResolveType (ec);
                        }
 
                        return this;
@@ -2516,6 +2442,12 @@ namespace Mono.CSharp {
                                return name;
                        }
                }
+
+               public override string FullName {
+                       get {
+                               return name;
+                       }
+               }
        }
 
        /// <summary>
@@ -2528,13 +2460,13 @@ namespace Mono.CSharp {
                { }
        }
 
-       public class TypeAliasExpression : TypeExpr, IAlias {
-               IAlias alias;
+       public class TypeAliasExpression : TypeExpr {
+               FullNamedExpression alias;
                TypeExpr texpr;
                TypeArguments args;
                string name;
 
-               public TypeAliasExpression (IAlias alias, TypeArguments args, Location l)
+               public TypeAliasExpression (FullNamedExpression alias, TypeArguments args, Location l)
                {
                        this.alias = alias;
                        this.args = args;
@@ -2542,18 +2474,22 @@ namespace Mono.CSharp {
 
                        eclass = ExprClass.Type;
                        if (args != null)
-                               name = alias.Name + "<" + args.ToString () + ">";
+                               name = alias.FullName + "<" + args.ToString () + ">";
                        else
-                               name = alias.Name;
+                               name = alias.FullName;
                }
 
                public override string Name {
+                       get { return alias.FullName; }
+               }
+
+               public override string FullName {
                        get { return name; }
                }
 
                protected override TypeExpr DoResolveAsTypeStep (EmitContext ec)
                {
-                       texpr = alias.ResolveAsType (ec);
+                       texpr = alias.ResolveAsTypeTerminal (ec);
                        if (texpr == null)
                                return null;
 
@@ -3258,6 +3194,8 @@ namespace Mono.CSharp {
                LocalTemporary temp;
                bool prepared;
 
+               internal static PtrHashtable AccessorTable = new PtrHashtable (); 
+
                public PropertyExpr (EmitContext ec, PropertyInfo pi, Location l)
                {
                        PropertyInfo = pi;
@@ -3341,10 +3279,10 @@ namespace Mono.CSharp {
                                PropertyInfo pi = (PropertyInfo) group [0];
 
                                if (getter == null)
-                                       getter = pi.GetGetMethod (true);;
+                                       getter = pi.GetGetMethod (true);
 
                                if (setter == null)
-                                       setter = pi.GetSetMethod (true);;
+                                       setter = pi.GetSetMethod (true);
 
                                MethodInfo accessor = getter != null ? getter : setter;
 
@@ -3361,7 +3299,15 @@ namespace Mono.CSharp {
                {
                        FindAccessors (ec.ContainerType);
 
-                       is_static = getter != null ? getter.IsStatic : setter.IsStatic;
+                       if (getter != null) {
+                               AccessorTable [getter] = PropertyInfo;
+                               is_static = getter.IsStatic;
+                       }
+
+                       if (setter != null) {
+                               AccessorTable [setter] = PropertyInfo;
+                               is_static = setter.IsStatic;
+                       }
                }
 
                bool InstanceResolve (EmitContext ec, bool must_do_cs1540_check)
@@ -3721,7 +3667,7 @@ namespace Mono.CSharp {
                public override void Emit (EmitContext ec)
                {
                        if (instance_expr is This)
-                               Report.Error (79, loc, "The event `{0}' can only appear on the left hand side of += or -=, try calling the actual delegate");
+                               Report.Error (79, loc, "The event `{0}' can only appear on the left hand side of += or -=, try calling the actual delegate", Name);
                        else
                                Report.Error (70, loc, "The event `{0}' can only appear on the left hand side of += or -= "+
                                              "(except on the defining type)", Name);
index 1ae16150f746a25a9d325be482dd50a317d17eda..c969a4a9bb5a1597f74c9335c79b3733b5144188 100644 (file)
@@ -166,7 +166,7 @@ namespace Mono.CSharp {
 
                        EnumMember em = new EnumMember (this, expr, name, loc, opt_attrs);
                        em.DocComment = documentation;
-                       if (!AddToContainer (em, false, name, ""))
+                       if (!AddToContainer (em, name, ""))
                                return;
 
 
@@ -225,11 +225,11 @@ namespace Mono.CSharp {
                                return null;
                        }
 
-                       TypeExpr texpr = ResolveTypeExpr (BaseType, Location);
-                       if (texpr == null)
+                       TypeExpr ute = ResolveBaseTypeExpr (BaseType, false, Location);
+                       if (ute == null)
                                return null;
 
-                       UnderlyingType = texpr.Type;
+                       UnderlyingType = ute.Type;
 
                        if (UnderlyingType != TypeManager.int32_type &&
                            UnderlyingType != TypeManager.uint32_type &&
index 5bbf8ca48f1413f2af8dc1c128cb8ec5be57fdf1..41cae69c6f145687467692b4a60b1c9698f6d088 100644 (file)
@@ -2724,7 +2724,7 @@ namespace Mono.CSharp {
                                ((oper == Operator.LogicalAnd && (bool)lc.GetValue () == false) ||
                                 (oper == Operator.LogicalOr && (bool)lc.GetValue () == true))) {
 
-                               // TODO: make a sence to resolve unreachable expression as we do for statement
+                               // TODO: make a sense to resolve unreachable expression as we do for statement
                                Report.Warning (429, 4, loc, "Unreachable expression code detected");
                                return left;
                        }
@@ -3556,13 +3556,12 @@ namespace Mono.CSharp {
                                }
                        }
 
+                       // Dead code optimalization
                        if (expr is BoolConstant){
                                BoolConstant bc = (BoolConstant) expr;
 
-                               if (bc.Value)
-                                       return trueExpr;
-                               else
-                                       return falseExpr;
+                               Report.Warning (429, 4, bc.Value ? falseExpr.Location : trueExpr.Location, "Unreachable expression code detected");
+                               return bc.Value ? trueExpr : falseExpr;
                        }
 
                        return this;
@@ -4251,7 +4250,14 @@ namespace Mono.CSharp {
                                                pr.AddressOf (ec, mode);
                                        }
                                } else {
-                                       ((IMemoryLocation)Expr).AddressOf (ec, mode);
+                                       if (Expr is IMemoryLocation)
+                                               ((IMemoryLocation) Expr).AddressOf (ec, mode);
+                                       else {
+                                               Report.Error (
+                                                       1510, Expr.Location,
+                                                       "An lvalue is required as an argument to out or ref");
+                                               return;
+                                       }
                                }
                        } else
                                Expr.Emit (ec);
@@ -4817,14 +4823,12 @@ namespace Mono.CSharp {
 
                        if (Arguments != null)
                                arg_count = Arguments.Count;
-
-#if REVIEW_IFDEF
+  
                         if ((me.Name == "Invoke") &&
                            TypeManager.IsDelegateType (me.DeclaringType)) {
                                 Error_InvokeOnDelegate (loc);
                                 return null;
                         }
-#endif
 
                        MethodBase[] methods = me.Methods;
 
@@ -5897,11 +5901,16 @@ namespace Mono.CSharp {
                                }
 
                                method = Invocation.OverloadResolve (
-                                       ec, (MethodGroupExpr) ml, Arguments, false, loc);
+                                       ec, (MethodGroupExpr) ml, Arguments, true, loc);
                                
                        }
 
-                       if (method == null) { 
+                       if (method == null) {
+                               if (almostMatchedMembers.Count != 0) {
+                                       MemberLookupFailed (ec, type, type, ".ctor", null, loc);
+                                       return null;
+                               }
+
                                 if (!is_struct || Arguments.Count > 0) {
                                        Error (1501, String.Format (
                                            "New invocation: Can not find a constructor in `{0}' for this argument list",
@@ -7215,7 +7224,7 @@ namespace Mono.CSharp {
                        if (sn == null || left == null || left.Type.Name != sn.Name)
                                return false;
 
-                       return RootContext.LookupType (ec.DeclSpace, sn.Name, true, loc) != null;
+                       return ec.DeclSpace.LookupType (sn.Name, true, loc) != null;
                }
                
                // TODO: possible optimalization
@@ -7435,17 +7444,15 @@ namespace Mono.CSharp {
                        if (expr == null)
                                return null;
 
-                       if (expr is SimpleName){
-                               SimpleName child_expr = (SimpleName) expr;
-                               string fqname = DeclSpace.MakeFQN (child_expr.Name, Identifier);
-
-                               Expression new_expr;
-                               if (args != null)
-                                       new_expr = new ConstructedType (fqname, args, loc);
-                               else
-                                       new_expr = new SimpleName (fqname, loc);
-
-                               return new_expr.Resolve (ec, flags);
+                       if (expr is Namespace) {
+                               Namespace ns = (Namespace) expr;
+                               string lookup_id = MemberName.MakeName (Identifier, args);
+                               FullNamedExpression retval = ns.Lookup (ec.DeclSpace, lookup_id, loc);
+                               if ((retval != null) && (args != null))
+                                       retval = new ConstructedType (retval, args, loc).ResolveAsTypeStep (ec);
+                               if (retval == null)
+                                       Report.Error (234, loc, "The type or namespace name `{0}' could not be found in namespace `{1}'", Identifier, ns.FullName);
+                               return retval;
                        }
                                        
                        //
@@ -7506,8 +7513,6 @@ namespace Mono.CSharp {
                                return null;
                        }
 
-                       int errors = Report.Errors;
-
                        Expression member_lookup;
                        member_lookup = MemberLookup (
                                ec, expr_type, expr_type, Identifier, loc);
@@ -7523,7 +7528,8 @@ namespace Mono.CSharp {
                        }
 
                        if (member_lookup is TypeExpr) {
-                               if (!(expr is TypeExpr) && !(expr is SimpleName)) {
+                               if (!(expr is TypeExpr) && 
+                                   !IdenticalNameAndTypeName (ec, original, expr, loc)) {
                                        Error (572, "Can't reference type `" + Identifier + "' through an expression; try `" +
                                               member_lookup.Type + "' instead");
                                        return null;
@@ -7575,58 +7581,31 @@ namespace Mono.CSharp {
 
                public override Expression DoResolve (EmitContext ec)
                {
-                       return DoResolve (ec, null, ResolveFlags.VariableOrValue |
-                                         ResolveFlags.SimpleName | ResolveFlags.Type);
+                       return DoResolve (ec, null, ResolveFlags.VariableOrValue | ResolveFlags.Type);
                }
 
                public override Expression DoResolveLValue (EmitContext ec, Expression right_side)
                {
-                       return DoResolve (ec, right_side, ResolveFlags.VariableOrValue |
-                                         ResolveFlags.SimpleName | ResolveFlags.Type);
+                       return DoResolve (ec, right_side, ResolveFlags.VariableOrValue | ResolveFlags.Type);
                }
 
-               public override Expression ResolveAsTypeStep (EmitContext ec)
+               public override FullNamedExpression ResolveAsTypeStep (EmitContext ec)
                {
-                       string fname = null;
-                       MemberAccess full_expr = this;
-                       while (full_expr != null) {
-                               if (fname != null)
-                                       fname = String.Concat (full_expr.Identifier, ".", fname);
-                               else
-                                       fname = full_expr.Identifier;
-
-                               fname = MemberName.MakeName (fname, args);
-
-                               if (full_expr.Expr is SimpleName) {
-                                       string full_name = String.Concat (((SimpleName) full_expr.Expr).Name, ".", fname);
-                                       Type fully_qualified = ec.DeclSpace.FindType (loc, full_name);
-                                       if (fully_qualified != null) {
-                                               if (args == null)
-                                                       return new TypeExpression (fully_qualified, loc);
-
-                                               ConstructedType ctype = new ConstructedType (fully_qualified, args, loc);
-                                               return ctype.ResolveAsTypeStep (ec);
-                                       }
-                               }
-
-                               full_expr = full_expr.Expr as MemberAccess;
-                       }
-
-                       Expression new_expr = expr.ResolveAsTypeStep (ec);
+                       FullNamedExpression new_expr = expr.ResolveAsTypeStep (ec);
 
                        if (new_expr == null)
                                return null;
 
-                       if (new_expr is SimpleName){
-                               SimpleName child_expr = (SimpleName) new_expr;
-                               string fqname = DeclSpace.MakeFQN (child_expr.Name, Identifier);
-                               
-                               if (args != null)
-                                       new_expr = new ConstructedType (fqname, args, loc);
-                               else
-                                       new_expr = new SimpleName (fqname, loc);
+                       string lookup_id = MemberName.MakeName (Identifier, args);
 
-                               return new_expr.ResolveAsTypeStep (ec);
+                       if (new_expr is Namespace) {
+                               Namespace ns = (Namespace) new_expr;
+                               FullNamedExpression retval = ns.Lookup (ec.DeclSpace, lookup_id, loc);
+                               if ((retval != null) && (args != null))
+                                       retval = new ConstructedType (retval, args, loc).ResolveAsTypeStep (ec);
+                               if (retval == null)
+                                       Report.Error (234, loc, "The type or namespace name `{0}' could not be found in namespace `{1}'", Identifier, ns.FullName);
+                               return retval;
                        }
 
                        TypeExpr tnew_expr = new_expr.ResolveAsTypeTerminal (ec);
@@ -7642,18 +7621,20 @@ namespace Mono.CSharp {
                        }
 
                        Expression member_lookup;
-                       string lookup_id;
-                       lookup_id = MemberName.MakeName (Identifier, args);
-                       member_lookup = MemberLookupFinal (
-                               ec, expr_type, expr_type, lookup_id, loc);
-                       if (member_lookup == null)
+                       member_lookup = MemberLookupFinal (ec, expr_type, expr_type, lookup_id, loc);
+                       if (member_lookup == null) {
+                               Report.Error (234, loc, "The type name `{0}' could not be found in type `{1}'", 
+                                             Identifier, new_expr.FullName);
                                return null;
+                       }
 
-                       TypeExpr texpr = member_lookup as TypeExpr;
-                       if (texpr == null)
+                       if (!(member_lookup is TypeExpr)) {
+                               Report.Error (118, loc, "'{0}.{1}' denotes a '{2}', where a type was expected",
+                                             new_expr.FullName, Identifier, member_lookup.ExprClassName ());
                                return null;
+                       }
 
-                       texpr = texpr.ResolveAsTypeTerminal (ec);
+                       TypeExpr texpr = member_lookup.ResolveAsTypeTerminal (ec);
                        if (texpr == null)
                                return null;
 
@@ -8868,7 +8849,9 @@ namespace Mono.CSharp {
                                //
                                // For now, fall back to the full lookup in that case.
                                //
-                               type = RootContext.LookupType (ec.DeclSpace, cname, false, loc);
+                               FullNamedExpression e = ec.DeclSpace.LookupType (cname, false, loc);
+                               if (e is TypeExpr)
+                                       type = ((TypeExpr) e).ResolveType (ec);
                                if (type == null)
                                        return null;
                        }
@@ -8877,6 +8860,12 @@ namespace Mono.CSharp {
                                UnsafeError (loc);
                                return null;
                        }
+
+                       if (type.IsArray && (type.GetElementType () == TypeManager.arg_iterator_type ||
+                               type.GetElementType () == TypeManager.typed_reference_type)) {
+                               Report.Error (611, loc, "Array elements cannot be of type '{0}'", TypeManager.CSharpName (type.GetElementType ()));
+                               return null;
+                       }
                        
                        eclass = ExprClass.Type;
                        return this;
@@ -8887,6 +8876,12 @@ namespace Mono.CSharp {
                                return left + dim;
                        }
                }
+
+               public override string FullName {
+                       get {
+                               return type.FullName;
+                       }
+               }
        }
 
        //
index 18f5714392490aea3015ffdd0fffa4ec53737b3c..9118631e509b83f4577e2a97a51f984d6327a80a 100644 (file)
@@ -689,7 +689,10 @@ namespace Mono.CSharp
                                if (result.ParameterVector != null)
                                        parameters.Or (result.ParameterVector);
 
-                               reachability.Or (new_r);
+                               if ((branching.Type == BranchingType.Block) && branching.Block.Implicit)
+                                       reachability = new_r.Clone ();
+                               else
+                                       reachability.Or (new_r);
 
                                Report.Debug (2, "  MERGING CHILD DONE", this, result,
                                              new_r, reachability);
@@ -1135,7 +1138,7 @@ namespace Mono.CSharp
                                throw new NotSupportedException ();
 
                        UsageVector vector = new UsageVector (
-                               SiblingType.Conditional, null, Block, Location,
+                               SiblingType.Block, null, Block, Location,
                                param_map.Length, local_map.Length);
 
                        UsageVector result = vector.MergeChild (this);
index 938a1c3388011f979c6ad857cb3784e209331684..759664ed240c14a7ed53c435776e583fd1bc1c16 100644 (file)
@@ -159,8 +159,6 @@ namespace Mono.CSharp {
 
                public bool Resolve (EmitContext ec)
                {
-                       DeclSpace ds = ec.DeclSpace;
-
                        iface_constraints = new ArrayList ();
                        type_param_constraints = new ArrayList ();
 
@@ -686,7 +684,7 @@ namespace Mono.CSharp {
                        get { return Name; }
                }
 
-               MemberCache IMemberContainer.ParentCache {
+               MemberCache IMemberContainer.BaseCache {
                        get { return null; }
                }
 
@@ -837,6 +835,12 @@ namespace Mono.CSharp {
                        }
                }
 
+               public override string FullName {
+                       get {
+                               return type_parameter.Name;
+                       }
+               }
+
                public TypeParameter TypeParameter {
                        get {
                                return type_parameter;
@@ -970,7 +974,6 @@ namespace Mono.CSharp {
 
                public bool Resolve (EmitContext ec)
                {
-                       DeclSpace ds = ec.DeclSpace;
                        int count = args.Count;
                        bool ok = true;
 
@@ -1016,6 +1019,16 @@ namespace Mono.CSharp {
                        full_name = name + "<" + args.ToString () + ">";
                }
 
+               public ConstructedType (FullNamedExpression fname, TypeArguments args, Location l)
+               {
+                       loc = l;
+                       this.name = fname.FullName;
+                       this.args = args;
+
+                       eclass = ExprClass.Type;
+                       full_name = name + "<" + args.ToString () + ">";
+               }
+
                protected ConstructedType (TypeArguments args, Location l)
                {
                        loc = l;
@@ -1350,6 +1363,11 @@ namespace Mono.CSharp {
                        return type == cobj.type;
                }
 
+               public override int GetHashCode ()
+               {
+                       return base.GetHashCode ();
+               }
+
                public string Basename {
                        get {
                                int pos = name.LastIndexOf ('`');
@@ -1365,6 +1383,13 @@ namespace Mono.CSharp {
                                return full_name;
                        }
                }
+
+
+               public override string FullName {
+                       get {
+                               return full_name;
+                       }
+               }
        }
 
        public class GenericMethod : DeclSpace
@@ -1429,7 +1454,7 @@ namespace Mono.CSharp {
 
                public override MemberCache MemberCache {
                        get {
-                               throw new Exception ();
+                               return null;
                        }
                }
 
@@ -1673,9 +1698,6 @@ namespace Mono.CSharp {
                        }
 
                        if (a.IsGenericInstance && b.IsGenericInstance) {
-                               Type at = a.GetGenericTypeDefinition ();
-                               Type bt = b.GetGenericTypeDefinition ();
-
                                if (a.GetGenericTypeDefinition () != b.GetGenericTypeDefinition ())
                                        return false;
 
@@ -1797,9 +1819,6 @@ namespace Mono.CSharp {
                        if (a.GetGenericTypeDefinition () != b.GetGenericTypeDefinition ())
                                return false;
 
-                       Type[] aargs = GetTypeArguments (a);
-                       Type[] bargs = GetTypeArguments (b);
-
                        return MayBecomeEqualGenericInstances (
                                GetTypeArguments (a), GetTypeArguments (b), class_infered, method_infered);
                }
@@ -1810,7 +1829,6 @@ namespace Mono.CSharp {
                        if (aargs.Length != bargs.Length)
                                return false;
 
-                       Type[] args = new Type [aargs.Length];
                        for (int i = 0; i < aargs.Length; i++) {
                                if (!MayBecomeEqualGenericTypes (aargs [i], bargs [i], class_infered, method_infered))
                                        return false;
index 98e3860f479d4e7eec8e1ff4cdb3d56694d1cc18..85cd202458601957feeb19acffd112fa21a28714 100644 (file)
@@ -8,7 +8,7 @@
 //
 // TODO:
 //    Flow analysis for Yield.
-//    Emit calls to parent object constructor.
+//    Emit calls to base object constructor.
 //
 // Generics note:
 //    Current should be defined to return T, and IEnumerator.Current returns object
index a3188858e0b2b28684a7d5b477081b90a59a06ec..4babbf721c682c913bc2c354100fe7d49e18bf02 100644 (file)
@@ -84,7 +84,7 @@ namespace Mono.CSharp {
                        string path = Path.GetFullPath (name);
 
                        if (source_files.Contains (path)){
-                               Report.Warning (2002, name, "Source file '{0}' specified multiple times");
+                               Report.Warning (2002, name, "Source file '{0}' specified multiple times", path);
                                return;
                        }
 
index be26cc164fd5c4df483f3b4299955fb9ecc9227d..ec0a8347be7f965ea04df864df213b262a8c2377 100644 (file)
@@ -13,8 +13,11 @@ namespace Mono.CSharp {
 
        /// <summary>
        ///   Keeps track of the namespaces defined in the C# code.
+       ///
+       ///   This is an Expression to allow it to be referenced in the
+       ///   compiler parse/intermediate tree during name resolution.
        /// </summary>
-       public class Namespace : IAlias {
+       public class Namespace : FullNamedExpression, IAlias {
                static ArrayList all_namespaces = new ArrayList ();
                static Hashtable namespaces_map = new Hashtable ();
                
@@ -31,6 +34,11 @@ namespace Mono.CSharp {
                /// </summary>
                public Namespace (Namespace parent, string name)
                {
+                       // Expression members.
+                       this.eclass = ExprClass.Namespace;
+                       this.Type = null;
+                       this.loc = Location.Null;
+
                        this.parent = parent;
 
                        string pname = parent != null ? parent.Name : "";
@@ -50,6 +58,16 @@ namespace Mono.CSharp {
                        namespaces_map [fullname] = true;
                }
 
+               public override Expression DoResolve (EmitContext ec)
+               {
+                       return this;
+               }
+
+               public override void Emit (EmitContext ec)
+               {
+                       throw new InternalErrorException ("Expression tree referenced namespace " + fullname + " during Emit ()");
+               }
+
                public static bool IsNamespace (string name)
                {
                        return namespaces_map [name] != null;
@@ -88,9 +106,9 @@ namespace Mono.CSharp {
                        return Root.GetNamespace (name, create);
                }
 
-               public IAlias Lookup (DeclSpace ds, string name, Location loc)
+               public FullNamedExpression Lookup (DeclSpace ds, string name, Location loc)
                {
-                       IAlias o = Lookup (name);
+                       IAlias o = (IAlias) defined_names [name];
 
                        Type t;
                        DeclSpace tdecl = o as DeclSpace;
@@ -100,7 +118,7 @@ namespace Mono.CSharp {
                                        return null;
 
                                if ((ds == null) || ds.CheckAccessLevel (t))
-                                       return new TypeExpression (t, loc);
+                                       return new TypeExpression (t, Location.Null);
                        }
 
                        Namespace ns = GetNamespace (name, false);
@@ -111,7 +129,7 @@ namespace Mono.CSharp {
                        if ((t == null) || ((ds != null) && !ds.CheckAccessLevel (t)))
                                return null;
 
-                       return new TypeExpression (t, loc);
+                       return new TypeExpression (t, Location.Null);
                }
 
                public void AddNamespaceEntry (NamespaceEntry entry)
@@ -124,11 +142,6 @@ namespace Mono.CSharp {
                        defined_names.Add (name, o);
                }
 
-               public IAlias Lookup (string name)
-               {
-                       return (IAlias) defined_names [name];
-               }
-
                static public ArrayList UserDefinedNamespaces {
                        get {
                                return all_namespaces;
@@ -144,6 +157,12 @@ namespace Mono.CSharp {
                        }
                }
 
+               public override string FullName {
+                       get {
+                               return fullname;
+                       }
+               }
+
                /// <summary>
                ///   The parent of this namespace, used by the parser to "Pop"
                ///   the current namespace declaration
@@ -228,7 +247,7 @@ namespace Mono.CSharp {
                                if (resolved_ns != null)
                                        return resolved_ns;
 
-                               object resolved = NamespaceEntry.LookupForUsing (Name, Location);
+                               FullNamedExpression resolved = NamespaceEntry.LookupForUsing (Name, Location);
                                resolved_ns = resolved as Namespace;
                                return resolved_ns;
                        }
@@ -248,9 +267,9 @@ namespace Mono.CSharp {
                                Location = loc;
                        }
 
-                       IAlias resolved;
+                       FullNamedExpression resolved;
 
-                       public IAlias Resolve ()
+                       public FullNamedExpression Resolve ()
                        {
                                if (resolved != null)
                                        return resolved;
@@ -266,9 +285,12 @@ namespace Mono.CSharp {
                                if (resolved == null)
                                        return null;
 
-                               if (resolved.IsType)
-                                       resolved = new TypeAliasExpression (
-                                               resolved, Alias.TypeArguments, Location);
+                               if (Alias.TypeArguments == null)
+                                       return resolved;
+
+                               EmitContext ec = RootContext.Tree.Types.EmitContext;
+                               resolved = new TypeAliasExpression (resolved, Alias.TypeArguments, Location);
+                               resolved = resolved.ResolveAsTypeStep (ec);
 
                                return resolved;
                        }
@@ -376,26 +398,13 @@ namespace Mono.CSharp {
                        aliases [name] = new AliasEntry (this, name, alias, loc);
                }
 
-               protected AliasEntry GetAliasEntry (string alias)
+               public FullNamedExpression LookupAlias (string alias)
                {
                        AliasEntry entry = null;
-
                        if (aliases != null)
                                entry = (AliasEntry) aliases [alias];
-                       if (entry == null && Parent != null)
-                               entry = Parent.GetAliasEntry (alias);
 
-                       return entry;
-               }
-
-               public IAlias LookupAlias (string alias)
-               {
-                       AliasEntry entry = GetAliasEntry (alias);
-
-                       if (entry == null)
-                               return null;
-
-                       return entry.Resolve ();
+                       return entry == null ? null : entry.Resolve ();
                }
 
                //
@@ -405,7 +414,7 @@ namespace Mono.CSharp {
                // Section 16.3.2 says that the same rule is applied when resolving the namespace-name
                // in the using-namespace-directive.
                //
-               public IAlias LookupForUsing (string dotted_name, Location loc)
+               public FullNamedExpression LookupForUsing (string dotted_name, Location loc)
                {
                        int pos = dotted_name.IndexOf ('.');
                        string simple_name = dotted_name;
@@ -415,7 +424,7 @@ namespace Mono.CSharp {
                                rest = dotted_name.Substring (pos + 1);
                        }
 
-                       IAlias o = NS.Lookup (null, simple_name, loc);
+                       FullNamedExpression o = NS.Lookup (null, simple_name, loc);
                        if (o == null && ImplicitParent != null)
                                o = ImplicitParent.LookupNamespaceOrType (null, simple_name, loc);
 
@@ -426,16 +435,16 @@ namespace Mono.CSharp {
                        if (ns != null)
                                return ns.Lookup (null, rest, loc);
                        
-                       Type nested = TypeManager.LookupType (o.Name + "." + rest);
+                       Type nested = TypeManager.LookupType (o.FullName + "." + rest);
                        if (nested == null)
                                return null;
 
-                       return new TypeExpression (nested, loc);
+                       return new TypeExpression (nested, Location.Null);
                }
 
-               public IAlias LookupNamespaceOrType (DeclSpace ds, string name, Location loc)
+               public FullNamedExpression LookupNamespaceOrType (DeclSpace ds, string name, Location loc)
                {
-                       IAlias resolved = null;
+                       FullNamedExpression resolved = null;
                        for (NamespaceEntry curr_ns = this; curr_ns != null; curr_ns = curr_ns.ImplicitParent) {
                                if ((resolved = curr_ns.Lookup (ds, name, loc)) != null)
                                        break;
@@ -443,9 +452,9 @@ namespace Mono.CSharp {
                        return resolved;
                }
 
-               private IAlias Lookup (DeclSpace ds, string name, Location loc)
+               private FullNamedExpression Lookup (DeclSpace ds, string name, Location loc)
                {
-                       IAlias o;
+                       FullNamedExpression o;
                        Namespace ns;
 
                        //
@@ -471,11 +480,11 @@ namespace Mono.CSharp {
                                        return o;
                                }
 
-                               Type nested = TypeManager.LookupType (o.Name + "." + last);
+                               Type nested = TypeManager.LookupType (o.FullName + "." + last);
                                if ((nested == null) || ((ds != null) && !ds.CheckAccessLevel (nested)))
                                        return null;
 
-                               return new TypeExpression (nested, loc);
+                               return new TypeExpression (nested, Location.Null);
                        }
 
                        //
@@ -488,12 +497,9 @@ namespace Mono.CSharp {
                        //
                        // Check aliases.
                        //
-                       AliasEntry entry = GetAliasEntry (name);
-                       if (entry != null) {
-                               IAlias alias = entry.Resolve ();
-                               if (alias != null)
-                                       return alias;
-                       }
+                       o = LookupAlias (name);
+                       if (o != null)
+                               return o;
 
                        if (name.IndexOf ('.') > 0)
                                return null;
@@ -501,12 +507,12 @@ namespace Mono.CSharp {
                        //
                        // Check using entries.
                        //
-                       IAlias t = null, match = null;
+                       FullNamedExpression t = null, match = null;
                        foreach (Namespace using_ns in GetUsingTable ()) {
                                match = using_ns.Lookup (ds, name, loc);
-                               if ((match != null) && match.IsType){
+                               if ((match != null) && (match is TypeExpr)) {
                                        if (t != null) {
-                                                       DeclSpace.Error_AmbiguousTypeReference (loc, name, t.Name, match.Name);
+                                               DeclSpace.Error_AmbiguousTypeReference (loc, name, t.FullName, match.FullName);
                                                return null;
                                        } else {
                                                t = match;
@@ -523,9 +529,11 @@ namespace Mono.CSharp {
                {
                        if (namespace_using_table != null)
                                return namespace_using_table;
-                       
-                       if (using_clauses == null)
-                               return new Namespace [0];
+
+                       if (using_clauses == null) {
+                               namespace_using_table = new Namespace [0];
+                               return namespace_using_table;
+                       }
 
                        ArrayList list = new ArrayList (using_clauses.Count);
 
@@ -616,10 +624,6 @@ namespace Mono.CSharp {
                /// </summary>
                public void VerifyUsing ()
                {
-                       TypeContainer dummy = new RootTypes ();
-                       EmitContext ec = new EmitContext (
-                               dummy, Location.Null, null, null, 0, false);
-
                        if (using_clauses != null){
                                foreach (UsingEntry ue in using_clauses){
                                        if (ue.Resolve () != null)
@@ -636,17 +640,12 @@ namespace Mono.CSharp {
 
                        if (aliases != null){
                                foreach (DictionaryEntry de in aliases){
-                                       AliasEntry entry = (AliasEntry) de.Value;
-
-                                       IAlias alias = entry.Resolve ();
-                                       if (alias != null) {
-                                               if (alias.IsType)
-                                                       alias.ResolveAsType (ec);
+                                       AliasEntry alias = (AliasEntry) de.Value;
 
+                                       if (alias.Resolve () != null)
                                                continue;
-                                       }
 
-                                       error246 (entry.Location, entry.Alias.GetTypeName ());
+                                       error246 (alias.Location, alias.Alias.GetTypeName ());
                                }
                        }
                }
index 17523aca7a8ecb7049a1e05a7164f6c4858d94b3..3375ef78d1e40ace17e265e977cca01080448368 100644 (file)
@@ -69,6 +69,10 @@ namespace Mono.CSharp {
 
                public override void ApplyAttributeBuilder(Attribute a, CustomAttributeBuilder cb)
                {
+                       if (a.Type == TypeManager.cls_compliant_attribute_type) {
+                               Report.Warning (3023, 1, a.Location, "CLSCompliant attribute has no meaning when applied to return types. Try putting it on the method instead");
+                       }
+
                        // This occurs after Warning -28
                        if (builder == null)
                                return;
@@ -148,6 +152,8 @@ namespace Mono.CSharp {
                GenericConstraints constraints;
                Type parameter_type;
 
+               EmitContext ec;  // because ApplyAtrribute doesn't have ec
+
                /* These two fields are mbas specific. The corresponding 
                changes need to be merged from mbas */
                
@@ -186,10 +192,27 @@ namespace Mono.CSharp {
 
                public override void ApplyAttributeBuilder (Attribute a, CustomAttributeBuilder cb)
                {
+                       if (a.Type == TypeManager.in_attribute_type && Attributes == ParameterAttributes.Out) {
+                               Report.Error (36, a.Location, "Can not use [In] attribute on out parameter");
+                               return;
+                       }
+
                        if (a.Type == TypeManager.param_array_type) {
                                Report.Error (674, a.Location, "Do not use 'System.ParamArrayAttribute'. Use the 'params' keyword instead");
                                return;
                        }
+
+                       if (a.Type == TypeManager.out_attribute_type && (ModFlags & Modifier.REF) != 0 &&
+                           !OptAttributes.Contains (TypeManager.in_attribute_type, ec)) {
+                               Report.Error (662, a.Location,
+                                       "'{0}' cannot specify only Out attribute on a ref parameter. Use both In and Out attributes, or neither", GetSignatureForError ());
+                               return;
+                       }
+
+                       if (a.Type == TypeManager.cls_compliant_attribute_type) {
+                               Report.Warning (3022, 1, a.Location, "CLSCompliant attribute has no meaning when applied to parameters. Try putting it on the method instead");
+                       }
+
                        base.ApplyAttributeBuilder (a, cb);
                }
 
@@ -199,6 +222,8 @@ namespace Mono.CSharp {
                public bool Resolve (EmitContext ec, Location l)
                {
                        TypeExpr texpr = TypeName.ResolveAsTypeTerminal (ec);
+                       this.ec = ec;
+
                        if (texpr == null)
                                return false;
 
@@ -214,7 +239,7 @@ namespace Mono.CSharp {
                        }
 
                        if (parameter_type == TypeManager.void_type){
-                               Report.Error (1536, l, "`void' parameter is not permitted");
+                               Report.Error (1536, l, "Invalid parameter type 'void'");
                                return false;
                        }
 
@@ -337,11 +362,6 @@ namespace Mono.CSharp {
                                        
                        if (OptAttributes != null) {
                                OptAttributes.Emit (ec, this);
-       
-                               if (par_attr == ParameterAttributes.Out){
-                                       if (OptAttributes.Contains (TypeManager.in_attribute_type, ec))
-                                               Report.Error (36, loc,  "Can not use [In] attribute on out parameter");
-                               }
                        }
                }
 
@@ -350,7 +370,6 @@ namespace Mono.CSharp {
                                return attribute_targets;
                        }
                }
-               
        }
 
        /// <summary>
@@ -413,7 +432,6 @@ namespace Mono.CSharp {
                        // Note: as per the spec, the `params' arguments (ArrayParameter)
                        // are not used in the signature computation for a method
                        //
-
                }
 
                void Error_DuplicateParameterName (string name)
@@ -529,7 +547,6 @@ namespace Mono.CSharp {
 
                                        types [i] = t;
                                        i++;
-
                                }
                        }
                        
index 550904b3fd2597c8bd3b1064d497e29aa6638af6..5663f612e9e4cc6db6a9de24aacde4ef14751b40 100644 (file)
@@ -23,7 +23,7 @@ namespace Mono.CSharp {
 
                // 
                // Whether it is optional, this is used to allow the explicit/implicit
-               // implementation when a parent class already implements an interface. 
+               // implementation when a base class already implements an interface. 
                //
                // For example:
                //
@@ -68,7 +68,7 @@ namespace Mono.CSharp {
 
                /// <summary>
                ///   This is the array of TypeAndMethods that describes the pending implementations
-               ///   (both interfaces and abstract methods in parent class)
+               ///   (both interfaces and abstract methods in base class)
                /// </summary>
                TypeAndMethods [] pending_implementations;
 
@@ -88,7 +88,7 @@ namespace Mono.CSharp {
 
                // <remarks>
                //   Returns a list of the abstract methods that are exposed by all of our
-               //   parents that we must implement.  Notice that this `flattens' the
+               //   bases that we must implement.  Notice that this `flattens' the
                //   method search space, and takes into account overrides.  
                // </remarks>
                static ArrayList GetAbstractMethods (Type t)
@@ -248,9 +248,9 @@ namespace Mono.CSharp {
                        if (type_builder.BaseType == null)
                                return ret;
                        
-                       Type [] parent_impls = TypeManager.GetInterfaces (type_builder.BaseType);
+                       Type [] base_impls = TypeManager.GetInterfaces (type_builder.BaseType);
                        
-                       foreach (Type t in parent_impls) {
+                       foreach (Type t in base_impls) {
                                for (int i = 0; i < ret.Length; i ++) {
                                        if (t == ret [i].Type) {
                                                ret [i].Optional = true;
@@ -452,7 +452,7 @@ namespace Mono.CSharp {
                ///   For that case, we create an explicit implementation function
                ///   I.M in Y.
                /// </summary>
-               void DefineProxy (Type iface, MethodInfo parent_method, MethodInfo iface_method,
+               void DefineProxy (Type iface, MethodInfo base_method, MethodInfo iface_method,
                                  Type [] args)
                {
                        MethodBuilder proxy;
@@ -465,44 +465,34 @@ namespace Mono.CSharp {
                                MethodAttributes.NewSlot |
                                MethodAttributes.Virtual,
                                CallingConventions.Standard | CallingConventions.HasThis,
-                               parent_method.ReturnType, args);
+                               base_method.ReturnType, args);
 
                        ParameterData pd = Invocation.GetParameterData (iface_method);
                        proxy.DefineParameter (0, ParameterAttributes.None, "");
                        for (int i = 0; i < pd.Count; i++) {
                                string name = pd.ParameterName (i);
                                ParameterAttributes attr = Parameter.GetParameterAttributes (pd.ParameterModifier (i));
-                               ParameterBuilder pb = proxy.DefineParameter (i + 1, attr, name);
+                               proxy.DefineParameter (i + 1, attr, name);
                        }
 
                        int top = args.Length;
                        ILGenerator ig = proxy.GetILGenerator ();
 
-                       ig.Emit (OpCodes.Ldarg_0);
-                       for (int i = 0; i < top; i++){
-                               switch (i){
-                               case 0:
-                                       ig.Emit (OpCodes.Ldarg_1); break;
-                               case 1:
-                                       ig.Emit (OpCodes.Ldarg_2); break;
-                               case 2:
-                                       ig.Emit (OpCodes.Ldarg_3); break;
-                               default:
-                                       ig.Emit (OpCodes.Ldarg, i - 1); break;
-                               }
-                       }
-                       ig.Emit (OpCodes.Call, parent_method);
+                       for (int i = 0; i <= top; i++)
+                               ParameterReference.EmitLdArg (ig, i);
+
+                       ig.Emit (OpCodes.Call, base_method);
                        ig.Emit (OpCodes.Ret);
 
                        container.TypeBuilder.DefineMethodOverride (proxy, iface_method);
                }
                
                /// <summary>
-               ///   This function tells whether one of our parent classes implements
+               ///   This function tells whether one of our base classes implements
                ///   the given method (which turns out, it is valid to have an interface
-               ///   implementation in a parent
+               ///   implementation in a base
                /// </summary>
-               bool ParentImplements (Type iface_type, MethodInfo mi)
+               bool BaseImplements (Type iface_type, MethodInfo mi)
                {
                        MethodSignature ms;
                        
@@ -516,9 +506,9 @@ namespace Mono.CSharp {
                        if (list.Count == 0)
                                return false;
 
-                       MethodInfo parent = (MethodInfo) list [0];
-                       if (!parent.IsAbstract)
-                               DefineProxy (iface_type, parent, mi, args);
+                       MethodInfo base_method = (MethodInfo) list [0];
+                       if (!base_method.IsAbstract)
+                               DefineProxy (iface_type, base_method, mi, args);
                        return true;
                }
 
@@ -550,7 +540,7 @@ namespace Mono.CSharp {
                                                        continue;
                                                }
 
-                                               if (ParentImplements (type, mi))
+                                               if (BaseImplements (type, mi))
                                                        continue;
 
                                                if (pending_implementations [i].optional)
index 3fd268bd583d8f2079056a26cc63fcc89edc8c4c..2824da00840d2b489a253daa496655bd89113fc5 100644 (file)
@@ -40,7 +40,7 @@ namespace Mono.CSharp {
                //
                // Whether we are being linked against the standard libraries.
                // This is only used to tell whether `System.Object' should
-               // have a parent or not.
+               // have a base class or not.
                //
                public static bool StdLib = true;
 
@@ -48,8 +48,8 @@ namespace Mono.CSharp {
                // This keeps track of the order in which classes were defined
                // so that we can poulate them in that order.
                //
-               // Order is important, because we need to be able to tell by
-               // examining the parent's list of methods which ones are virtual
+               // Order is important, because we need to be able to tell, by
+               // examining the list of methods of the base class, which ones are virtual
                // or abstract as well as the parent names (to implement new, 
                // override).
                //
@@ -64,7 +64,7 @@ namespace Mono.CSharp {
                
                static TypeBuilder impl_details_class;
 
-               public static int WarningLevel = 2;
+               public static int WarningLevel = 3;
 
                public static Target Target = Target.Exe;
                public static string TargetExt = ".exe";
@@ -391,6 +391,7 @@ namespace Mono.CSharp {
                                "System.Runtime.CompilerServices.IndexerNameAttribute",
                                "System.Runtime.CompilerServices.DecimalConstantAttribute",
                                "System.Runtime.InteropServices.InAttribute",
+                               "System.Runtime.InteropServices.OutAttribute",
                                "System.Runtime.InteropServices.StructLayoutAttribute",
                                "System.Runtime.InteropServices.FieldOffsetAttribute",
                                "System.InvalidOperationException",
@@ -482,107 +483,6 @@ namespace Mono.CSharp {
                        helper_classes.Add (helper_class);
                }
                
-               //
-               // This idea is from Felix Arrese-Igor
-               //
-               // Returns : the implicit parent of a composite namespace string
-               //   eg. Implicit parent of A.B is A
-               //
-               static public string ImplicitParent (string ns)
-               {
-                       int i = ns.LastIndexOf ('.');
-                       if (i < 0)
-                               return null;
-                       
-                       return ns.Substring (0, i);
-               }
-
-               static Type NamespaceLookup (DeclSpace ds, string name, int num_type_args, Location loc)
-               {
-                       IAlias result = ds.NamespaceEntry.LookupNamespaceOrType (ds, name, loc);
-                       if (result == null)
-                               return null;
-
-                       if (!result.IsType)
-                               return null;
-
-                       TypeExpr texpr = result.ResolveAsType (ds.EmitContext);
-                       if (texpr == null)
-                               return null;
-
-                       return texpr.Type;
-               }
-               
-               static public Type LookupType (DeclSpace ds, string name, bool silent, Location loc)
-               {
-                       return LookupType (ds, name, silent, 0, loc);
-               }
-
-               //
-               // Public function used to locate types, this can only
-               // be used after the ResolveTree function has been invoked.
-               //
-               // Returns: Type or null if they type can not be found.
-               //
-               // Come to think of it, this should be a DeclSpace
-               //
-               static public Type LookupType (DeclSpace ds, string name, bool silent,
-                                              int num_type_params, Location loc)
-               {
-                       Type t;
-
-                       if (ds.Cache.Contains (name)){
-                               t = (Type) ds.Cache [name];
-                               if (t != null)
-                                       return t;
-                       } else {
-                               //
-                               // For the case the type we are looking for is nested within this one
-                               // or is in any base class
-                               //
-                               DeclSpace containing_ds = ds;
-                               while (containing_ds != null){
-                                       Type current_type = containing_ds.TypeBuilder;
-                                       
-                                       while (current_type != null) {
-                                               //
-                                               // nested class
-                                               //
-                                               Type type = TypeManager.LookupType (current_type.FullName + "." + name);
-                                               if (type != null){
-                                                       t = ds.ResolveNestedType (type, loc);
-                                                       ds.Cache [name] = t;
-                                                       return t;
-                                               }
-                                               
-                                               current_type = current_type.BaseType;
-                                       }
-                                       
-                                       containing_ds = containing_ds.Parent;
-                               }
-                               
-                               t = NamespaceLookup (ds, name, num_type_params, loc);
-                               if (!silent || t != null){
-                                       ds.Cache [name] = t;
-                                       return t;
-                               }
-                       }
-
-                       if (!silent)
-                               Report.Error (246, loc, "Cannot find type `"+name+"'");
-                       
-                       return null;
-               }
-
-               // <summary>
-               //   This is the silent version of LookupType, you can use this
-               //   to `probe' for a type
-               // </summary>
-               static public Type LookupType (TypeContainer tc, string name, Location loc)
-               {
-                       return LookupType (tc, name, true, loc);
-               }
-
                static void Report1530 (Location loc)
                {
                        Report.Error (1530, loc, "Keyword new not allowed for namespace elements");
index 44fd3cc326f55863b61f8281240af78ca4c7f57a..df0ba63808e3ad1c3ce29b5672793959be85d387 100644 (file)
@@ -146,6 +146,11 @@ namespace Mono.CSharp {
                                return false;
                        }
                        
+                       Assign ass = expr as Assign;
+                       if (ass != null && ass.Source is Constant) {
+                               Report.Warning (665, 3, loc, "Assignment in conditional expression is always constant; did you mean to use == instead of = ?");
+                       }
+
                        //
                        // Dead code elimination
                        //
@@ -670,6 +675,7 @@ namespace Mono.CSharp {
                bool defined;
                bool referenced;
                Label label;
+               ILGenerator ig;
 
                FlowBranching.UsageVector vectors;
                
@@ -682,6 +688,7 @@ namespace Mono.CSharp {
                {
                        if (defined)
                                return label;
+                       ig = ec.ig;
                        label = ec.ig.DefineLabel ();
                        defined = true;
 
@@ -718,6 +725,10 @@ namespace Mono.CSharp {
 
                protected override void DoEmit (EmitContext ec)
                {
+                       if (ig != null && ig != ec.ig) {
+                               Report.Error (1632, "Control cannot leave body of anonymous method");
+                               return;
+                       }
                        LabelTarget (ec);
                        ec.ig.MarkLabel (label);
                }
@@ -820,7 +831,6 @@ namespace Mono.CSharp {
 
                public override bool Resolve (EmitContext ec)
                {
-                       bool in_catch = ec.CurrentBranching.InCatch ();
                        ec.CurrentBranching.CurrentUsageVector.Throw ();
 
                        if (expr != null){
@@ -831,7 +841,7 @@ namespace Mono.CSharp {
                                ExprClass eclass = expr.eclass;
 
                                if (!(eclass == ExprClass.Variable || eclass == ExprClass.PropertyAccess ||
-                                     eclass == ExprClass.Value || eclass == ExprClass.IndexerAccess)) {
+                                       eclass == ExprClass.Value || eclass == ExprClass.IndexerAccess)) {
                                        expr.Error_UnexpectedKind ("value, variable, property or indexer access ", loc);
                                        return false;
                                }
@@ -839,20 +849,25 @@ namespace Mono.CSharp {
                                Type t = expr.Type;
                                
                                if ((t != TypeManager.exception_type) &&
-                                   !t.IsSubclassOf (TypeManager.exception_type) &&
-                                   !(expr is NullLiteral)) {
+                                       !t.IsSubclassOf (TypeManager.exception_type) &&
+                                       !(expr is NullLiteral)) {
                                        Error (155,
-                                                     "The type caught or thrown must be derived " +
-                                                     "from System.Exception");
+                                               "The type caught or thrown must be derived " +
+                                               "from System.Exception");
                                        return false;
                                }
-                       } else if (!in_catch) {
-                               Error (156,
-                                      "A throw statement with no argument is only " +
-                                      "allowed in a catch clause");
+                               return true;
+                       }
+
+                       if (ec.CurrentBranching.InFinally (true)) {
+                               Error (724, "A throw statement with no argument is only allowed in a catch clause nested inside of the innermost catch clause");
                                return false;
                        }
 
+                       if (!ec.CurrentBranching.InCatch ()) {
+                               Error (156, "A throw statement with no argument is only allowed in a catch clause");
+                               return false;
+                       }
                        return true;
                }
                        
@@ -1418,12 +1433,12 @@ namespace Mono.CSharp {
                // </summary>
                public LocalInfo ThisVariable {
                        get {
-                               if (this_variable != null)
-                                       return this_variable;
-                               else if (Parent != null)
-                                       return Parent.ThisVariable;
-                               else
-                                       return null;
+                               for (Block b = this; b != null; b = b.Parent) {
+                                       if (b.this_variable != null)
+                                               return b.this_variable;
+                               }
+                               
+                               return null;
                        }
                }
 
@@ -1745,8 +1760,6 @@ namespace Mono.CSharp {
                /// </remarks>
                public void ResolveMeta (ToplevelBlock toplevel, EmitContext ec, InternalParameters ip)
                {
-                       ILGenerator ig = ec.ig;
-
                        bool old_unsafe = ec.InUnsafe;
 
                        // If some parent block was unsafe, we remain unsafe even if this block
@@ -1934,7 +1947,7 @@ namespace Mono.CSharp {
 
                        Report.Debug (4, "RESOLVE BLOCK", StartLocation, ec.CurrentBranching);
 
-                       bool unreachable = false;
+                       bool unreachable = unreachable_shown;
 
                        int statement_count = statements.Count;
                        for (int ix = 0; ix < statement_count; ix++){
@@ -1952,8 +1965,10 @@ namespace Mono.CSharp {
                                        else
                                                s.loc = Location.Null;
 
-                                       statements [ix] = EmptyStatement.Value;
-                                       continue;
+                                       if (ok && !(s is Block)) {
+                                               statements [ix] = EmptyStatement.Value;
+                                               continue;
+                                       }
                                }
 
                                if (s.Resolve (ec) == false) {
@@ -2010,7 +2025,18 @@ namespace Mono.CSharp {
                public override bool ResolveUnreachable (EmitContext ec, bool warn)
                {
                        unreachable_shown = true;
-                       return base.ResolveUnreachable (ec, warn);
+
+                       if (warn && (RootContext.WarningLevel >= 2))
+                               Report.Warning (162, loc, "Unreachable code detected");
+
+                       if (Implicit)
+                               return Resolve (ec);
+
+                       ec.StartFlowBranching (FlowBranching.BranchingType.Block, loc);
+                       bool ok = Resolve (ec);
+                       ec.KillFlowBranching ();
+
+                       return ok;
                }
                
                protected override void DoEmit (EmitContext ec)
@@ -2021,7 +2047,7 @@ namespace Mono.CSharp {
                                // Check whether we are the last statement in a
                                // top-level block.
 
-                               if ((Parent == null) && (ix+1 == num_statements))
+                               if (((Parent == null) || Implicit) && (ix+1 == num_statements) && !(s is Block))
                                        ec.IsLastStatement = true;
                                else
                                        ec.IsLastStatement = false;
@@ -2115,8 +2141,6 @@ namespace Mono.CSharp {
 
                static int did = 0;
                
-               int my_id = did++;
-
                        
                public void RegisterCaptureContext (CaptureContext cc)
                {
@@ -3883,7 +3907,7 @@ namespace Mono.CSharp {
                        ILGenerator ig = ec.ig;
 
                        int i = assign.Length;
-                       foreach (DictionaryEntry e in var_list){
+                       for (int ii = 0; ii < var_list.Count; ++ii){
                                Expression var = resolved_vars [--i];
                                Label skip = ig.DefineLabel ();
                                
@@ -4086,6 +4110,11 @@ namespace Mono.CSharp {
                        if (expr == null)
                                return false;
 
+                       if (expr is NullLiteral) {
+                               Report.Error (186, expr.Location, "Use of null is not valid in this context");
+                               return false;
+                       }
+
                        TypeExpr texpr = type.ResolveAsTypeTerminal (ec);
                        if (texpr == null)
                                return false;
@@ -4281,7 +4310,6 @@ namespace Mono.CSharp {
                                        return false;
                        }
                        ForeachHelperMethods hm = (ForeachHelperMethods) criteria;
-                       EmitContext ec = hm.ec;
 
                        // Check whether GetEnumerator is public
                        if ((mi.Attributes & MethodAttributes.Public) != MethodAttributes.Public)
@@ -4488,7 +4516,8 @@ namespace Mono.CSharp {
                        ig.Emit (OpCodes.Brfalse, end_try);
 
                        if (ec.InIterator)
-                               enumerator.EmitThis (ig);
+                               ig.Emit (OpCodes.Ldarg_0);
+                       
                        enumerator.EmitCall (ig, hm.get_current);
 
                        if (ec.InIterator){
@@ -4588,7 +4617,7 @@ namespace Mono.CSharp {
                                ig.MarkLabel (loop);
 
                                if (ec.InIterator)
-                                       ec.EmitThis ();
+                                       ig.Emit (OpCodes.Ldarg_0);
                                
                                copy.EmitThis (ig);
                                copy.EmitLoad (ig);
@@ -4657,7 +4686,8 @@ namespace Mono.CSharp {
                                }
 
                                if (ec.InIterator)
-                                       ec.EmitThis ();
+                                       ig.Emit (OpCodes.Ldarg_0);
+                               
                                copy.EmitThis (ig);
                                copy.EmitLoad (ig);
                                for (dim = 0; dim < rank; dim++){
index 72dd624496b39b152949c6d876db0465159cc6a2..8fd2e343b52db746e450b82e12f5614879afb2f9 100644 (file)
@@ -136,8 +136,6 @@ namespace Mono.CSharp {
 
                public Parameter.Modifier ParameterModifier (int pos)
                {
-                       int len = pi.Length;
-
                        if (last_arg_is_params && pos >= pi.Length - 1)
                                        return Parameter.Modifier.PARAMS;
                        else if (is_varargs && pos >= pi.Length)
@@ -482,10 +480,20 @@ namespace Mono.CSharp {
                                // buffer.
                                if ((value >= buffer_start) && (value < buffer_start + buffer_size)) {
                                        int byte_offset = value - buffer_start;
+
+                                       // pos is an index into a char
+                                       // buffer so it might be
+                                       // greater than the buffer
+                                       // length now, if the buffer
+                                       // contains multibyte chars
                                        pos = byte_offset;
-                                       // encoded characters can take more than 1 byte length
-                                       while (reader.CurrentEncoding.GetByteCount (buffer, 0, pos) > byte_offset)
+                                       
+                                       // encoded characters can take
+                                       // more than 1 byte length.
+                                       while ((pos > buffer.Length) ||
+                                              reader.CurrentEncoding.GetByteCount (buffer, 0, pos) > byte_offset) {
                                                pos--;
+                                       }
                                        
                                        return;
                                }
index 60394d45ef8eded5af2ece67ea4cab6310f43d05..84e5091873d8c71ce1390e4d033d3e56295efccb 100644 (file)
@@ -125,5 +125,11 @@ namespace Mono.CSharp
                {
                        throw new InvalidOperationException ();
                }
+
+               public override bool IsClsCompliaceRequired (DeclSpace ds)
+               {
+                       return true;
+               }
+
        }
 }
index 6b407125a5c0e0f3a68312a57ffd52fe6fe0f90c..2acf526722e78ef5140479788daf2b226b1d2317 100644 (file)
@@ -89,6 +89,7 @@ public partial class TypeManager {
        static public Type obsolete_attribute_type;
        static public Type conditional_attribute_type;
        static public Type in_attribute_type;
+       static public Type out_attribute_type;
        static public Type anonymous_method_type;
        static public Type cls_compliant_attribute_type;
        static public Type typed_reference_type;
@@ -510,7 +511,7 @@ public partial class TypeManager {
                return TypeHandle.GetMemberCache (t);
        }
 
-       public static MemberCache LookupParentInterfacesCache (Type t)
+       public static MemberCache LookupBaseInterfacesCache (Type t)
        {
                Type [] ifaces = t.GetInterfaces ();
 
@@ -747,7 +748,7 @@ public partial class TypeManager {
                        } 
 
                        //
-                       // We know that System.Object does not have children, and since its the parent of 
+                       // We know that System.Object does not have children, and since its the base of 
                        // all the objects, it always gets probbed for inner classes. 
                        //
                        if (top_level_type == "System.Object")
@@ -841,7 +842,7 @@ public partial class TypeManager {
                        @"Single|Double|Char|Decimal|Byte|SByte|Object|" +
                        @"Boolean|String|Void|Null)" +
                        @"(\W+|\b)", 
-                       new MatchEvaluator (CSharpNameMatch));
+                       new MatchEvaluator (CSharpNameMatch)).Replace ('+', '.');
        }       
        
        static String CSharpNameMatch (Match match) 
@@ -864,7 +865,10 @@ public partial class TypeManager {
        /// </summary>
        static public string GetFullNameSignature (MemberInfo mi)
        {
-               return mi.DeclaringType.FullName.Replace ('+', '.') + '.' + mi.Name;
+               // Unfortunately, there's no dynamic dispatch on the arguments of a function.
+               return (mi is MethodBase)
+                       ? GetFullNameSignature (mi as MethodBase) 
+                       : mi.DeclaringType.FullName.Replace ('+', '.') + '.' + mi.Name;
        }
                
        static public string GetFullNameSignature (MethodBase mb)
@@ -1133,6 +1137,7 @@ public partial class TypeManager {
                marshal_as_attr_type = CoreLookupType ("System.Runtime.InteropServices.MarshalAsAttribute");
                param_array_type     = CoreLookupType ("System.ParamArrayAttribute");
                in_attribute_type    = CoreLookupType ("System.Runtime.InteropServices.InAttribute");
+               out_attribute_type   = CoreLookupType ("System.Runtime.InteropServices.OutAttribute");
                typed_reference_type = CoreLookupType ("System.TypedReference");
                arg_iterator_type    = CoreLookupType ("System.ArgIterator");
                mbr_type             = CoreLookupType ("System.MarshalByRefObject");
@@ -1677,20 +1682,20 @@ public partial class TypeManager {
                return tc.Kind == Kind.Interface;
        }
 
-       public static bool IsSubclassOf (Type type, Type parent)
+       public static bool IsSubclassOf (Type type, Type base_type)
        {
                TypeParameter tparam = LookupTypeParameter (type);
-               TypeParameter pparam = LookupTypeParameter (parent);
+               TypeParameter pparam = LookupTypeParameter (base_type);
 
                if ((tparam != null) && (pparam != null)) {
                        if (tparam == pparam)
                                return true;
 
-                       return tparam.IsSubclassOf (parent);
+                       return tparam.IsSubclassOf (base_type);
                }
 
                do {
-                       if (type.Equals (parent))
+                       if (type.Equals (base_type))
                                return true;
 
                        type = type.BaseType;
@@ -1729,9 +1734,6 @@ public partial class TypeManager {
                }
 
                if (type.IsGenericInstance && parent.IsGenericInstance) {
-                       Type tdef = type.GetGenericTypeDefinition ();
-                       Type pdef = parent.GetGenericTypeDefinition ();
-
                        if (type.GetGenericTypeDefinition () != parent.GetGenericTypeDefinition ())
                                return false;
 
@@ -1764,12 +1766,12 @@ public partial class TypeManager {
        }
 
        //
-       // Checks whether `type' is a subclass or nested child of `parent'.
+       // Checks whether `type' is a subclass or nested child of `base_type'.
        //
-       public static bool IsNestedFamilyAccessible (Type type, Type parent)
+       public static bool IsNestedFamilyAccessible (Type type, Type base_type)
        {
                do {
-                       if (IsFamilyAccessible (type, parent))
+                       if (IsFamilyAccessible (type, base_type))
                                return true;
 
                        // Handle nested types.
@@ -2079,7 +2081,7 @@ public partial class TypeManager {
                        return true;
 
                foreach (Field field in tc.Fields) {
-                       if (field.FieldBuilder.IsStatic)
+                       if (field.FieldBuilder == null || field.FieldBuilder.IsStatic)
                                continue;
 
                        Type ftype = field.FieldBuilder.FieldType;
@@ -2174,20 +2176,20 @@ public partial class TypeManager {
                        t = TypeManager.array_type;
                
                if (t is TypeBuilder){
-                       Type[] parent_ifaces;
+                       Type [] base_ifaces;
                        
                        if (t.BaseType == null)
-                               parent_ifaces = NoTypes;
+                               base_ifaces = NoTypes;
                        else
-                               parent_ifaces = GetInterfaces (t.BaseType);
+                               base_ifaces = GetInterfaces (t.BaseType);
                        Type[] type_ifaces = (Type []) builder_to_ifaces [t];
                        if (type_ifaces == null)
                                type_ifaces = NoTypes;
 
-                       int parent_count = parent_ifaces.Length;
-                       Type[] result = new Type [parent_count + type_ifaces.Length];
-                       parent_ifaces.CopyTo (result, 0);
-                       type_ifaces.CopyTo (result, parent_count);
+                       int base_count = base_ifaces.Length;
+                       Type [] result = new Type [base_count + type_ifaces.Length];
+                       base_ifaces.CopyTo (result, 0);
+                       type_ifaces.CopyTo (result, base_count);
 
                        iface_cache [t] = result;
                        return result;
@@ -2226,7 +2228,7 @@ public partial class TypeManager {
                // as soon as we hit a non-TypeBuiler in the interface
                // chain, we could return, as the `Type.GetInterfaces'
                // will return all the interfaces implement by the type
-               // or its parents.
+               // or its bases.
                //
                do {
                        interfaces = GetInterfaces (t);
@@ -2585,6 +2587,8 @@ public partial class TypeManager {
                        if (invocation_type == null)
                                return false;
 
+                       Debug.Assert (IsNestedFamilyAccessible (invocation_type, m.DeclaringType));
+
                        if (is_static)
                                return true;
                        
@@ -2875,7 +2879,7 @@ public partial class TypeManager {
                        // works if we already used the cache in the first iteration of this loop.
                        //
                        // If we used the cache in any further iteration, we can still terminate the
-                       // loop since the cache always looks in all parent classes.
+                       // loop since the cache always looks in all base classes.
                        //
 
                        if (used_cache)
@@ -3097,7 +3101,7 @@ public sealed class TypeHandle : IMemberContainer {
        private string full_name;
        private bool is_interface;
        private MemberCache member_cache;
-       private MemberCache parent_cache;
+       private MemberCache base_cache;
 
        private TypeHandle (Type type)
        {
@@ -3105,9 +3109,9 @@ public sealed class TypeHandle : IMemberContainer {
                full_name = type.FullName != null ? type.FullName : type.Name;
                if (type.BaseType != null) {
                        BaseType = GetTypeHandle (type.BaseType);
-                       parent_cache = BaseType.MemberCache;
+                       base_cache = BaseType.MemberCache;
                } else if (type.IsInterface)
-                       parent_cache = TypeManager.LookupParentInterfacesCache (type);
+                       base_cache = TypeManager.LookupBaseInterfacesCache (type);
                this.is_interface = type.IsInterface || type.IsGenericParameter;
                this.member_cache = new MemberCache (this);
        }
@@ -3126,9 +3130,9 @@ public sealed class TypeHandle : IMemberContainer {
                }
        }
 
-       public MemberCache ParentCache {
+       public MemberCache BaseCache {
                get {
-                       return parent_cache;
+                       return base_cache;
                }
        }