using Mono.CompilerServices.SymbolWriter;
using System.Runtime.CompilerServices;
-#if NET_2_1
+#if MOBILE
using XmlElement = System.Object;
#else
using System.Xml;
return s + parameters.GetSignatureForDocumentation ();
}
- public virtual void PrepareEmit ()
+ public override void PrepareEmit ()
{
+ base.PrepareEmit ();
parameters.ResolveDefaultValues (this);
}
return ms;
}
+#if DEBUG
+ int counter = 100000;
+#endif
+
public MethodSpec MakeGenericMethod (IMemberContext context, params TypeSpec[] targs)
{
if (targs == null)
inflated.constraints = TypeParameterSpec.InflateConstraints (inflator, constraints ?? GenericDefinition.TypeParameters);
inflated.state |= StateFlags.PendingMakeMethod;
+#if DEBUG
+ inflated.ID += counter;
+ counter += 100000;
+#endif
// if (inflated.parent == null)
// inflated.parent = parent;
public override void ApplyAttributeBuilder (Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa)
{
if (a.Target == AttributeTargets.ReturnValue) {
- if (return_attributes == null)
- return_attributes = new ReturnParameter (this, MethodBuilder, Location);
-
- return_attributes.ApplyAttributeBuilder (a, ctor, cdata, pa);
+ CreateReturnBuilder ().ApplyAttributeBuilder (a, ctor, cdata, pa);
return;
}
return new EmitContext (this, ig, MemberType, sourceMethod);
}
+ ReturnParameter CreateReturnBuilder ()
+ {
+ return return_attributes ?? (return_attributes = new ReturnParameter (this, MethodBuilder, Location));
+ }
+
public override bool Define ()
{
if (!base.Define ())
explicit_name = null;
} else {
- MethodData = new MethodData (this, ModFlags, flags, this, base_method);
+ MethodData = new MethodData (this, ModFlags, flags, this);
if (!MethodData.Define (Parent.PartialContainer, GetFullName (MemberName)))
return false;
Module.PredefinedAttributes.DebuggerStepThrough.EmitAttribute (MethodBuilder);
if (ReturnType.BuiltinType == BuiltinTypeSpec.Type.Dynamic) {
- return_attributes = new ReturnParameter (this, MethodBuilder, Location);
- Module.PredefinedAttributes.Dynamic.EmitAttribute (return_attributes.Builder);
+ Module.PredefinedAttributes.Dynamic.EmitAttribute (CreateReturnBuilder ().Builder);
} else if (ReturnType.HasDynamicElement) {
- return_attributes = new ReturnParameter (this, MethodBuilder, Location);
- Module.PredefinedAttributes.Dynamic.EmitAttribute (return_attributes.Builder, ReturnType, Location);
+ Module.PredefinedAttributes.Dynamic.EmitAttribute (CreateReturnBuilder ().Builder, ReturnType, Location);
+ }
+
+ if (ReturnType.HasNamedTupleElement) {
+ Module.PredefinedAttributes.TupleElementNames.EmitAttribute (CreateReturnBuilder ().Builder, ReturnType, Location);
}
if (OptAttributes != null)
}
}
- if (type_expr != null)
+ //
+ // Optimization but it also covers cases where we cannot check
+ // constraints because method is captured into generated class
+ // and type parameters context is now different
+ //
+ if (type_expr != null && !IsCompilerGenerated)
ConstraintChecker.Check (this, member_type, type_expr.Location);
base.Emit ();
}
if (base_override.IsGeneric) {
- ObsoleteAttribute oa;
foreach (var base_tp in base_tparams) {
- oa = base_tp.BaseType.GetAttributeObsolete ();
- if (oa != null) {
- AttributeTester.Report_ObsoleteMessage (oa, base_tp.BaseType.GetSignatureForError (), Location, Report);
- }
+ base_tp.BaseType.CheckObsoleteness (this, Location);
if (base_tp.InterfacesDefined != null) {
foreach (var iface in base_tp.InterfacesDefined) {
- oa = iface.GetAttributeObsolete ();
- if (oa != null) {
- AttributeTester.Report_ObsoleteMessage (oa, iface.GetSignatureForError (), Location, Report);
- }
+ iface.CheckObsoleteness (this, Location);
}
}
}
p.Name = md_p.Name;
p.DefaultValue = md_p.DefaultValue;
if (md_p.OptAttributes != null) {
- if (p.OptAttributes == null) {
- p.OptAttributes = md_p.OptAttributes;
- } else {
- p.OptAttributes.Attrs.AddRange (md_p.OptAttributes.Attrs);
- }
+ Attributes.AttachFromPartial (p, md_p);
}
}
// If we use a "this (...)" constructor initializer, then
// do not emit field initializers, they are initialized in the other constructor
//
- if (!(Initializer is ConstructorThisInitializer))
+ if (!(Initializer is ConstructorThisInitializer)) {
+ var errors = Compiler.Report.Errors;
Parent.PartialContainer.ResolveFieldInitializers (bc);
+ if (errors != Compiler.Report.Errors)
+ return;
+ }
if (!IsStatic) {
if (Initializer == null && Parent.PartialContainer.Kind == MemberKind.Class) {
if (debug_builder == null)
return;
+#if !FULL_AOT_RUNTIME
var token = ConstructorBuilder.GetToken ();
int t = token.Token;
#if STATIC
#endif
debug_builder.DefineMethod (file, t);
+#endif
}
#region IMethodData Members
protected Modifiers modifiers;
protected MethodAttributes flags;
protected TypeSpec declaring_type;
- protected MethodSpec parent_method;
SourceMethodBuilder debug_builder;
string full_name;
this.method = method;
}
- public MethodData (InterfaceMemberBase member,
- Modifiers modifiers, MethodAttributes flags,
- IMethodData method,
- MethodSpec parent_method)
- : this (member, modifiers, flags, method)
- {
- this.parent_method = parent_method;
- }
-
public bool Define (TypeDefinition container, string method_full_name)
{
PendingImplementation pending = container.PendingImplementations;
}
}
}
+
+ if (!NamedTupleSpec.CheckOverrideName (member.MemberType, implementing.ReturnType)) {
+ container.Compiler.Report.Error (8141, method.Location,
+ "The tuple element names in the signature type of member `{0}' must match the tuple element names of interface member `{1}''",
+ member.GetSignatureForError (), implementing.GetSignatureForError ());
+ }
+
+ var p_member = method as IParametersMember;
+ var p_implementing = implementing as IParametersMember;
+ if (p_member != null && p_implementing != null && !NamedTupleSpec.CheckOverrideName (p_member, p_implementing)) {
+ container.Compiler.Report.Error (8141, method.Location,
+ "The tuple element names in the signature type of member `{0}' must match the tuple element names of interface member `{1}''",
+ member.GetSignatureForError (), implementing.GetSignatureForError ());
+ }
}
}
} else {
}
} else {
//
- // Setting implementin to null inside this block will trigger a more
+ // Setting implementing to null inside this block will trigger a more
// verbose error reporting for missing interface implementations
//
if (implementing.DeclaringType.IsInterface) {
if (debug_builder == null)
return;
+#if !FULL_AOT_RUNTIME
var token = builder.GetToken ();
int t = token.Token;
#if STATIC
#endif
debug_builder.DefineMethod (file, t);
+#endif
}
}
}
if (a.Target == AttributeTargets.ReturnValue) {
- if (return_attributes == null)
- return_attributes = new ReturnParameter (this, method_data.MethodBuilder, Location);
-
+ CreateReturnBuilder ();
return_attributes.ApplyAttributeBuilder (a, ctor, cdata, pa);
return;
}
throw new NotSupportedException ();
}
+ ReturnParameter CreateReturnBuilder ()
+ {
+ return return_attributes ?? (return_attributes = new ReturnParameter (this, method_data.MethodBuilder, Location));
+ }
+
public virtual void Emit (TypeDefinition parent)
{
method_data.Emit (parent);
Module.PredefinedAttributes.DebuggerHidden.EmitAttribute (method_data.MethodBuilder);
if (ReturnType.BuiltinType == BuiltinTypeSpec.Type.Dynamic) {
- return_attributes = new ReturnParameter (this, method_data.MethodBuilder, Location);
- Module.PredefinedAttributes.Dynamic.EmitAttribute (return_attributes.Builder);
+ Module.PredefinedAttributes.Dynamic.EmitAttribute (CreateReturnBuilder ().Builder);
} else if (ReturnType.HasDynamicElement) {
- return_attributes = new ReturnParameter (this, method_data.MethodBuilder, Location);
- Module.PredefinedAttributes.Dynamic.EmitAttribute (return_attributes.Builder, ReturnType, Location);
+ Module.PredefinedAttributes.Dynamic.EmitAttribute (CreateReturnBuilder ().Builder, ReturnType, Location);
+ }
+
+ if (ReturnType.HasNamedTupleElement) {
+ Module.PredefinedAttributes.TupleElementNames.EmitAttribute (CreateReturnBuilder ().Builder, ReturnType, Location);
}
if (OptAttributes != null)
else if (OperatorType == OpType.Implicit)
Parent.MemberCache.CheckExistingMembersOverloads (this, GetMetadataName (OpType.Explicit), parameters);
- TypeSpec declaring_type = Parent.CurrentType;
+ TypeSpec declaring_type = Parent.PartialContainer.CurrentType;
TypeSpec return_type = MemberType;
TypeSpec first_arg_type = ParameterTypes [0];