+2008-03-17 Marek Safar <marek.safar@gmail.com>
+
+ * class.cs, decl.cs, delegate.cs: Do protected modifier check on each member
+
+ * symbolwriter.cs: Fixed.
+
2008-03-17 Marek Safar <marek.safar@gmail.com>
* anonymous.cs, driver.cs: Reset anonymous types counters.
public override bool Define ()
{
+ CheckProtectedModifier ();
+
if (compiler_generated != null) {
foreach (CompilerGeneratedClass c in compiler_generated) {
if (!c.Define ())
}
if ((m.ModFlags & Modifiers.PROTECTED) != 0) {
- Report.Error (1057, m.Location, "`{0}': Static classes cannot contain protected members", m.GetSignatureForError ());
+ m.CheckProtectedModifier ();
continue;
}
"Structs cannot contain explicit parameterless constructors");
return false;
}
-
- if ((ModFlags & Modifiers.PROTECTED) != 0) {
- Report.Error (666, Location, "`{0}': new protected member declared in struct", GetSignatureForError ());
- return false;
- }
}
- if ((Parent.ModFlags & Modifiers.SEALED) != 0 && (ModFlags & Modifiers.PROTECTED) != 0) {
- Report.Warning (628, 4, Location, "`{0}': new protected member declared in sealed class", GetSignatureForError ());
- }
+ CheckProtectedModifier ();
return true;
}
protected virtual bool CheckBase ()
{
- if ((ModFlags & Modifiers.PROTECTED) != 0 && Parent.PartialContainer.Kind == Kind.Struct) {
- Report.Error (666, Location, "`{0}': new protected member declared in struct", GetSignatureForError ());
- return false;
- }
-
- if (Report.WarningLevel >= 4 &&
- ((Parent.ModFlags & Modifiers.SEALED) != 0) &&
- ((ModFlags & Modifiers.PROTECTED) != 0) &&
- ((ModFlags & Modifiers.OVERRIDE) == 0) && (Name != "Finalize")) {
- Report.Warning (628, 4, Location, "`{0}': new protected member declared in sealed class", GetSignatureForError ());
- }
- return true;
+ CheckProtectedModifier ();
+
+ return true;
}
protected virtual bool DoDefine ()
public string FullName {
get {
if (TypeArguments != null)
- return Name + "<" + TypeArguments + ">";
+ return Name + "<" + TypeArguments.ToString () + ">";
else
return Name;
}
}
return true;
- }
+ }
+
+ public void CheckProtectedModifier ()
+ {
+ if ((ModFlags & Modifiers.PROTECTED) == 0)
+ return;
+
+ if (Parent.PartialContainer.Kind == Kind.Struct) {
+ Report.Error (666, Location, "`{0}': Structs cannot contain protected members",
+ GetSignatureForError ());
+ return;
+ }
+
+ if ((Parent.ModFlags & Modifiers.STATIC) != 0) {
+ Report.Error (1057, Location, "`{0}': Static classes cannot contain protected members",
+ GetSignatureForError ());
+ return;
+ }
+
+ if (((Parent.ModFlags & Modifiers.SEALED) != 0) &&
+ ((ModFlags & Modifiers.OVERRIDE) == 0) && (Name != "Finalize")) {
+ Report.Warning (628, 4, Location, "`{0}': new protected member declared in sealed class",
+ GetSignatureForError ());
+ return;
+ }
+ }
public abstract bool Define ();
return false;
}
+ CheckProtectedModifier ();
+
if (RootContext.StdLib && (ret_type == TypeManager.arg_iterator_type || ret_type == TypeManager.typed_reference_type)) {
Method.Error1599 (Location, ret_type);
return false;
private static SymbolWriterImpl symwriter;
- protected class SymbolWriterImpl : MonoSymbolWriter {
+ class SymbolWriterImpl : MonoSymbolWriter {
delegate int GetILOffsetFunc (ILGenerator ig);
delegate Guid GetGuidFunc (ModuleBuilder mb);