return s + parameters.GetSignatureForDocumentation ();
}
+ public override void PrepareEmit ()
+ {
+ base.PrepareEmit ();
+ parameters.ResolveDefaultValues (this);
+ }
+
public MethodSpec Spec {
get { return spec; }
}
#endregion
- public virtual void PrepareEmit ()
+ public override void PrepareEmit ()
{
+ base.PrepareEmit ();
+
var mb = MethodData.DefineMethodBuilder (Parent);
if (CurrentTypeParameters != null) {
}
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);
}
}
}
// Using container location because the interface can be implemented
// by base class
- container.Compiler.Report.Error (425, container.Location,
+ var tp = (tparams [i].MemberDefinition as MemberCore) ?? container;
+ container.Compiler.Report.Error (425, tp.Location,
"The constraints for type parameter `{0}' of method `{1}' must match the constraints for type parameter `{2}' of interface method `{3}'. Consider using an explicit interface implementation instead",
tparams[i].GetSignatureForError (), method.GetSignatureForError (),
base_tparams[i].GetSignatureForError (), baseMethod.GetSignatureForError ());
// This is used to track the Entry Point,
//
var settings = Compiler.Settings;
- if (settings.NeedsEntryPoint && MemberName.Name == "Main" && (settings.MainClass == null || settings.MainClass == Parent.TypeBuilder.FullName)) {
+ if (settings.NeedsEntryPoint && MemberName.Name == "Main" && !IsPartialDefinition && (settings.MainClass == null || settings.MainClass == Parent.TypeBuilder.FullName)) {
if (IsEntryPoint ()) {
if (Parent.DeclaringAssembly.EntryPoint == null) {
if (Parent.IsGenericOrParentIsGeneric || MemberName.IsGeneric) {
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);
}
}
"`{0}': Struct constructors cannot call base constructors", caller_builder.GetSignatureForError ());
return this;
}
- } else {
- //
- // It is legal to have "this" initializers that take no arguments
- // in structs
- //
- // struct D { public D (int a) : this () {}
- //
- if (ec.CurrentType.IsStruct && argument_list == null)
- return this;
}
base_ctor = ConstructorLookup (ec, type, ref argument_list, loc);
protected override bool CheckBase ()
{
if ((ModFlags & Modifiers.STATIC) != 0) {
- if (!parameters.IsEmpty) {
- Report.Error (132, Location, "`{0}': The static constructor must be parameterless",
- GetSignatureForError ());
- return false;
- }
-
if ((caching_flags & Flags.MethodOverloadsExist) != 0)
Parent.MemberCache.CheckExistingMembersOverloads (this, parameters);
if ((caching_flags & Flags.MethodOverloadsExist) != 0)
Parent.MemberCache.CheckExistingMembersOverloads (this, parameters);
- if (Parent.PartialContainer.Kind == MemberKind.Struct && parameters.IsEmpty) {
- Report.Error (568, Location,
- "Structs cannot contain explicit parameterless constructors");
- return false;
- }
-
CheckProtectedModifier ();
return true;
}
}
+ if ((ModFlags & Modifiers.EXTERN) != 0 && Initializer != null) {
+ Report.Error (8091, Location, "`{0}': Contructors cannot be extern and have a constructor initializer",
+ GetSignatureForError ());
+ }
+
var ca = ModifiersExtensions.MethodAttr (ModFlags) | MethodAttributes.RTSpecialName | MethodAttributes.SpecialName;
ConstructorBuilder = Parent.TypeBuilder.DefineConstructor (
// 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) {
Implicit,
Explicit,
+ // Pattern matching
+ Is,
+
// Just because of enum
TOP
};
names [(int) OpType.LessThanOrEqual] = new string [] { "<=", "op_LessThanOrEqual" };
names [(int) OpType.Implicit] = new string [] { "implicit", "op_Implicit" };
names [(int) OpType.Explicit] = new string [] { "explicit", "op_Explicit" };
+ names [(int) OpType.Is] = new string[] { "is", "op_Is" };
}
public Operator (TypeDefinition parent, OpType type, FullNamedExpression ret_type, Modifiers mod_flags, ParametersCompiled parameters,
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];