protected TypeContainer AddPartial (TypeContainer next_part, string name)
{
next_part.ModFlags |= Modifiers.PARTIAL;
TypeContainer tc = GetDefinition (name) as TypeContainer;
if (tc == null)
return AddTypeContainer (next_part);
if ((tc.ModFlags & Modifiers.PARTIAL) == 0) {
Report.SymbolRelatedToPreviousError (next_part);
Error_MissingPartialModifier (tc);
}
if (tc.Kind != next_part.Kind) {
Report.SymbolRelatedToPreviousError (tc);
Report.Error (261, next_part.Location,
"Partial declarations of `{0}' must be all classes, all structs or all interfaces",
next_part.GetSignatureForError ());
}
if ((tc.ModFlags & Modifiers.AccessibilityMask) != (next_part.ModFlags & Modifiers.AccessibilityMask) &&
((tc.ModFlags & Modifiers.DEFAULT_ACCESS_MODIFER) == 0 &&
(next_part.ModFlags & Modifiers.DEFAULT_ACCESS_MODIFER) == 0)) {
Report.SymbolRelatedToPreviousError (tc);
Report.Error (262, next_part.Location,
"Partial declarations of `{0}' have conflicting accessibility modifiers",
next_part.GetSignatureForError ());
}
if (tc.partial_parts == null)
tc.partial_parts = new List<TypeContainer> (1);
if ((next_part.ModFlags & Modifiers.DEFAULT_ACCESS_MODIFER) != 0) {
tc.ModFlags |= next_part.ModFlags & ~(Modifiers.DEFAULT_ACCESS_MODIFER | Modifiers.AccessibilityMask);
} else if ((tc.ModFlags & Modifiers.DEFAULT_ACCESS_MODIFER) != 0) {
tc.ModFlags &= ~(Modifiers.DEFAULT_ACCESS_MODIFER | Modifiers.AccessibilityMask);
tc.ModFlags |= next_part.ModFlags;
} else {
tc.ModFlags |= next_part.ModFlags;
}
tc.spec.Modifiers = tc.ModFlags;
if (next_part.attributes != null) {
if (tc.attributes == null)
tc.attributes = next_part.attributes;
else
tc.attributes.AddAttributes (next_part.attributes.Attrs);
}
next_part.PartialContainer = tc;
tc.partial_parts.Add (next_part);
return tc;
}