diff options
author | Raja R Harinath <harinath@hurrynot.org> | 2005-03-09 13:04:11 +0300 |
---|---|---|
committer | Raja R Harinath <harinath@hurrynot.org> | 2005-03-09 13:04:11 +0300 |
commit | cc3108d353f847b1d045ca94af201435a6a84343 (patch) | |
tree | a820355dcbe1402e564b224ba4e7d9377b3cb8e5 /mcs/errors/cs1618-2.cs | |
parent | 3961e2a2e41f2c5dc7d2487e8076787ff01cc510 (diff) |
Clean up a few partial-class semantics.
Fixes test-357.cs and cs1618-2.cs.
* cs-parser.jay (struct_declaration): Use 'current_class' as
parent of newly-created struct. Remove call to Register ().
Use 'pop_current_class' to complete handing the current struct.
(interface_declaration): Likewise.
(class_declaration): Likewise.
(enum_declaration): Use 'current_class' as parent of newly created
enum.
(delegate_declaration): Likewise.
(pop_current_class): New function. This is used to handle closing
up the 'current_class' and 'current_container', and pointing them
to the enclosing class/container.
(CSharpParser): Initialize 'current_class' too.
decl.cs (MemberCore): Add check for invariant: a partial
container is not a parsed entity, and thus does not enclose any
parsed members.
(DeclSpace.TypeResolveEmitContext): Expose 'type_resolve_ec'.
(DeclSpace.BaseTypeExpr): Use it.
(DeclSpace.LookupType): Add check for invariant.
* class.cs (TypeContainer): Add check for invariant: a nested
class should have the same NamespaceEntry as its enclosing class.
(TypeContainer.EmitFieldInitializers): Make virtual.
(TypeContainer.DefineDefaultConstructor): Adhere to invariant in
MemberCore.
(TypeContainer.Register): Remove.
(TypeContainer.DefineType): Set the 'ec' of a PartialContainer to
null. Use TypeResolveEmitContext for resolving base types and
interfaces. Move initialization of Parts.TypeBuilder here from
...
(TypeContainer.DefineNestedTypes): ... here.
(PartialContainer): Take a Namespace not a NamespaceEntry.
(PartialContainer.Create): Don't use Register. Call the
appropriate Add... function directly.
(ClassPart): Take both the PartialContainer and the enclosing
class as constructor arguments.
(ClassPart.EmitFieldInitializers): Override.
(ClassPart.PartFindNestedTypes): Remove.
(FieldBase.GetInitializerExpression): Resolve the initializer
expression in the emit context of the enclosing class.
* tree.cs (RootTypes): Remove Register ().
svn path=/trunk/mcs/; revision=41590
Diffstat (limited to 'mcs/errors/cs1618-2.cs')
-rw-r--r-- | mcs/errors/cs1618-2.cs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/mcs/errors/cs1618-2.cs b/mcs/errors/cs1618-2.cs new file mode 100644 index 00000000000..7a252f437ad --- /dev/null +++ b/mcs/errors/cs1618-2.cs @@ -0,0 +1,23 @@ +// cs1618: Cannot create delegate with 'System.Diagnostics.Debug.Assert(bool)' because it has a Conditional attribute +// Line: 8 + +namespace Foo { + using System.Diagnostics; + partial class Bar { + delegate void assert_t (bool condition); + assert_t assert = new assert_t (Debug.Assert); + } +} + +namespace Foo { + using System; + partial class Bar + { + public Bar () {} + static void Main () + { + if (new Bar ().assert == null) + throw new Exception ("Didn't resolve Debug.Assert?"); + } + } +} |