|
|
@@ -944,7 +944,7 @@ namespace Mono.CSharp {
|
|
|
|
|
|
c = new Constructor (constructor_parent, MemberName.Name, mods,
|
|
|
Parameters.EmptyReadOnlyParameters,
|
|
|
- new ConstructorBaseInitializer (null, Location),
|
|
|
+ new GeneratedBaseInitializer (Location),
|
|
|
Location);
|
|
|
|
|
|
AddConstructor (c);
|
|
|
@@ -1302,6 +1302,9 @@ namespace Mono.CSharp {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // Avoid attributes check when parent is not set
|
|
|
+ TypeResolveEmitContext.TestObsoleteMethodUsage = false;
|
|
|
+
|
|
|
if (base_type != null) {
|
|
|
// FIXME: I think this should be ...ResolveType (Parent.EmitContext).
|
|
|
// However, if Parent == RootContext.Tree.Types, its NamespaceEntry will be null.
|
|
|
@@ -1328,8 +1331,17 @@ namespace Mono.CSharp {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- if (ptype != null)
|
|
|
+ if (ptype != null) {
|
|
|
TypeBuilder.SetParent (ptype);
|
|
|
+ }
|
|
|
+
|
|
|
+ // Attribute is undefined at the begining of corlib compilation
|
|
|
+ if (TypeManager.obsolete_attribute_type != null) {
|
|
|
+ TypeResolveEmitContext.TestObsoleteMethodUsage = GetObsoleteAttribute () == null;
|
|
|
+ if (ptype != null && TypeResolveEmitContext.TestObsoleteMethodUsage) {
|
|
|
+ CheckObsoleteType (base_type);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
// add interfaces that were not added at type creation
|
|
|
if (iface_exprs != null) {
|
|
|
@@ -1417,7 +1429,7 @@ namespace Mono.CSharp {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- CurrentType = current_type.Type;
|
|
|
+ CurrentType = current_type.ResolveType (ec);
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
@@ -2596,18 +2608,6 @@ namespace Mono.CSharp {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- protected override void VerifyObsoleteAttribute()
|
|
|
- {
|
|
|
- CheckUsageOfObsoleteAttribute (TypeBuilder.BaseType);
|
|
|
-
|
|
|
- if (ifaces == null)
|
|
|
- return;
|
|
|
-
|
|
|
- foreach (Type iface in ifaces) {
|
|
|
- CheckUsageOfObsoleteAttribute (iface);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
//
|
|
|
// IMemberContainer
|
|
|
//
|
|
|
@@ -3371,6 +3371,10 @@ namespace Mono.CSharp {
|
|
|
return parameter_info;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ public override EmitContext EmitContext {
|
|
|
+ get { return ds.EmitContext; }
|
|
|
+ }
|
|
|
|
|
|
public ToplevelBlock Block {
|
|
|
get {
|
|
|
@@ -3903,17 +3907,6 @@ namespace Mono.CSharp {
|
|
|
get { return "M:"; }
|
|
|
}
|
|
|
|
|
|
- protected override void VerifyObsoleteAttribute()
|
|
|
- {
|
|
|
- base.VerifyObsoleteAttribute ();
|
|
|
-
|
|
|
- if (parameter_types == null)
|
|
|
- return;
|
|
|
-
|
|
|
- foreach (Type type in parameter_types) {
|
|
|
- CheckUsageOfObsoleteAttribute (type);
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
public class SourceMethod : ISourceMethod
|
|
|
@@ -4393,11 +4386,6 @@ namespace Mono.CSharp {
|
|
|
return ec;
|
|
|
}
|
|
|
|
|
|
- public ObsoleteAttribute GetObsoleteAttribute ()
|
|
|
- {
|
|
|
- return GetObsoleteAttribute (ds);
|
|
|
- }
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// Returns true if method has conditional attribute and the conditions is not defined (method is excluded).
|
|
|
/// </summary>
|
|
|
@@ -4538,7 +4526,7 @@ namespace Mono.CSharp {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- public void Emit (EmitContext ec)
|
|
|
+ public virtual void Emit (EmitContext ec)
|
|
|
{
|
|
|
if (base_constructor != null){
|
|
|
ec.Mark (loc, false);
|
|
|
@@ -4557,6 +4545,21 @@ namespace Mono.CSharp {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ class GeneratedBaseInitializer: ConstructorBaseInitializer {
|
|
|
+ public GeneratedBaseInitializer (Location loc):
|
|
|
+ base (null, loc)
|
|
|
+ {
|
|
|
+ }
|
|
|
+
|
|
|
+ public override void Emit(EmitContext ec)
|
|
|
+ {
|
|
|
+ bool old = ec.TestObsoleteMethodUsage;
|
|
|
+ ec.TestObsoleteMethodUsage = false;
|
|
|
+ base.Emit (ec);
|
|
|
+ ec.TestObsoleteMethodUsage = old;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public class ConstructorThisInitializer : ConstructorInitializer {
|
|
|
public ConstructorThisInitializer (ArrayList argument_list, Location l) :
|
|
|
base (argument_list, l)
|
|
|
@@ -4759,7 +4762,7 @@ namespace Mono.CSharp {
|
|
|
|
|
|
if ((ModFlags & Modifiers.STATIC) == 0){
|
|
|
if (Parent.Kind == Kind.Class && Initializer == null)
|
|
|
- Initializer = new ConstructorBaseInitializer (null, Location);
|
|
|
+ Initializer = new GeneratedBaseInitializer (Location);
|
|
|
|
|
|
|
|
|
//
|
|
|
@@ -4793,7 +4796,7 @@ namespace Mono.CSharp {
|
|
|
}
|
|
|
}
|
|
|
if (Initializer != null) {
|
|
|
- if (GetObsoleteAttribute () != null || Parent.GetObsoleteAttribute (Parent) != null)
|
|
|
+ if (GetObsoleteAttribute () != null || Parent.GetObsoleteAttribute () != null)
|
|
|
ec.TestObsoleteMethodUsage = false;
|
|
|
|
|
|
Initializer.Emit (ec);
|
|
|
@@ -4895,11 +4898,6 @@ namespace Mono.CSharp {
|
|
|
return new EmitContext (Parent, Location, ig_, null, ModFlags, true);
|
|
|
}
|
|
|
|
|
|
- public ObsoleteAttribute GetObsoleteAttribute ()
|
|
|
- {
|
|
|
- return GetObsoleteAttribute (Parent);
|
|
|
- }
|
|
|
-
|
|
|
public bool IsExcluded(EmitContext ec)
|
|
|
{
|
|
|
return false;
|
|
|
@@ -5224,7 +5222,7 @@ namespace Mono.CSharp {
|
|
|
else
|
|
|
ec = method.CreateEmitContext (container, null);
|
|
|
|
|
|
- if (method.GetObsoleteAttribute () != null || container.GetObsoleteAttribute (container) != null)
|
|
|
+ if (method.GetObsoleteAttribute () != null || container.GetObsoleteAttribute () != null)
|
|
|
ec.TestObsoleteMethodUsage = false;
|
|
|
|
|
|
Attributes OptAttributes = method.OptAttributes;
|
|
|
@@ -5348,8 +5346,9 @@ namespace Mono.CSharp {
|
|
|
ec.InUnsafe = InUnsafe;
|
|
|
Type = Type.ResolveAsTypeTerminal (ec);
|
|
|
ec.InUnsafe = old_unsafe;
|
|
|
-
|
|
|
- member_type = Type == null ? null : Type.Type;
|
|
|
+ if (Type != null) {
|
|
|
+ member_type = Type.Type;
|
|
|
+ }
|
|
|
}
|
|
|
return member_type;
|
|
|
}
|
|
|
@@ -5478,7 +5477,7 @@ namespace Mono.CSharp {
|
|
|
if (iface_texpr == null)
|
|
|
return false;
|
|
|
|
|
|
- InterfaceType = iface_texpr.Type;
|
|
|
+ InterfaceType = iface_texpr.ResolveType (ec);
|
|
|
|
|
|
if (!InterfaceType.IsInterface) {
|
|
|
Report.Error (538, Location, "'{0}' in explicit interface declaration is not an interface", TypeManager.CSharpName (InterfaceType));
|
|
|
@@ -5505,6 +5504,8 @@ namespace Mono.CSharp {
|
|
|
if (MemberType == null)
|
|
|
return false;
|
|
|
|
|
|
+ CheckObsoleteType (Type);
|
|
|
+
|
|
|
if ((Parent.ModFlags & Modifiers.SEALED) != 0 &&
|
|
|
(ModFlags & (Modifiers.VIRTUAL|Modifiers.ABSTRACT)) != 0) {
|
|
|
Report.Error (549, Location, "New virtual member `{0}' is declared in a sealed class `{1}'",
|
|
|
@@ -5591,10 +5592,6 @@ namespace Mono.CSharp {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- protected override void VerifyObsoleteAttribute()
|
|
|
- {
|
|
|
- CheckUsageOfObsoleteAttribute (MemberType);
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
//
|
|
|
@@ -5806,9 +5803,11 @@ namespace Mono.CSharp {
|
|
|
if (ec == null)
|
|
|
throw new InternalErrorException ("FieldMember.Define called too early");
|
|
|
|
|
|
- if (MemberType == null)
|
|
|
+ if (MemberType == null || Type == null)
|
|
|
return false;
|
|
|
|
|
|
+ CheckObsoleteType (Type);
|
|
|
+
|
|
|
if (MemberType == TypeManager.void_type) {
|
|
|
Report.Error (1547, Location, "Keyword 'void' cannot be used in this context");
|
|
|
return false;
|
|
|
@@ -6237,7 +6236,6 @@ namespace Mono.CSharp {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public abstract ObsoleteAttribute GetObsoleteAttribute ();
|
|
|
public abstract Type[] ParameterTypes { get; }
|
|
|
public abstract Type ReturnType { get; }
|
|
|
public abstract EmitContext CreateEmitContext(TypeContainer tc, ILGenerator ig);
|
|
|
@@ -6352,10 +6350,6 @@ namespace Mono.CSharp {
|
|
|
get { throw new InvalidOperationException ("Unexpected attempt to get doc comment from " + this.GetType () + "."); }
|
|
|
}
|
|
|
|
|
|
- protected override void VerifyObsoleteAttribute()
|
|
|
- {
|
|
|
- }
|
|
|
-
|
|
|
}
|
|
|
|
|
|
//
|
|
|
@@ -6586,7 +6580,7 @@ namespace Mono.CSharp {
|
|
|
|
|
|
public override ObsoleteAttribute GetObsoleteAttribute ()
|
|
|
{
|
|
|
- return method.GetObsoleteAttribute (method.ds);
|
|
|
+ return method.GetObsoleteAttribute ();
|
|
|
}
|
|
|
|
|
|
public override string GetSignatureForError()
|
|
|
@@ -7292,7 +7286,7 @@ namespace Mono.CSharp {
|
|
|
|
|
|
public override ObsoleteAttribute GetObsoleteAttribute ()
|
|
|
{
|
|
|
- return method.GetObsoleteAttribute (method.Parent);
|
|
|
+ return method.GetObsoleteAttribute ();
|
|
|
}
|
|
|
|
|
|
public override string[] ValidAttributeTargets {
|