Exemple #1
0
		public override List<MissingTypeSpecReference> ResolveMissingDependencies (MemberSpec caller)
		{
			var missing = returnType.ResolveMissingDependencies (this);
			foreach (var pt in parameters.Types) {
				var m = pt.GetMissingDependencies (this);
				if (m == null)
					continue;

				if (missing == null)
					missing = new List<MissingTypeSpecReference> ();

				missing.AddRange (m);
			}

			if (Arity > 0) {
				foreach (var tp in GenericDefinition.TypeParameters) {
					var m = tp.GetMissingDependencies (this);

					if (m == null)
						continue;

					if (missing == null)
						missing = new List<MissingTypeSpecReference> ();

					missing.AddRange (m);
				}
			}

			return missing;			
		}
Exemple #2
0
		bool OverloadResolver.IErrorHandler.TypeInferenceFailed (ResolveContext rc, MemberSpec best)
		{
			return false;
		}
		protected override bool CheckOverrideAgainstBase (MemberSpec base_member)
		{
			var ok = base.CheckOverrideAgainstBase (base_member);

			if (!CheckAccessModifiers (this, base_member)) {
				Error_CannotChangeAccessModifiers (this, base_member);
				ok = false;
			}

			return ok;
		}
Exemple #4
0
	static public string CSharpSignature (MemberSpec mb)
	{
		return mb.GetSignatureForError ();
	}
Exemple #5
0
		bool OverloadResolver.IErrorHandler.ArgumentMismatch (ResolveContext rc, MemberSpec best, Argument arg, int index)
		{
			Error_ConversionFailed (rc, best as MethodSpec, null);
			return true;
		}
Exemple #6
0
		protected void Error_CannotChangeAccessModifiers (MemberCore member, MemberSpec base_member)
		{
			var base_modifiers = base_member.Modifiers;

			// Remove internal modifier from types which are not internally accessible
			if ((base_modifiers & Modifiers.AccessibilityMask) == (Modifiers.PROTECTED | Modifiers.INTERNAL) &&
				!base_member.DeclaringType.MemberDefinition.IsInternalAsPublic (member.Module.DeclaringAssembly))
				base_modifiers = Modifiers.PROTECTED;

			Report.SymbolRelatedToPreviousError (base_member);
			Report.Error (507, member.Location,
				"`{0}': cannot change access modifiers when overriding `{1}' inherited member `{2}'",
				member.GetSignatureForError (),
				ModifiersExtensions.AccessibilityName (base_modifiers),
				base_member.GetSignatureForError ());
		}
Exemple #7
0
		public void SymbolRelatedToPreviousError (MemberSpec ms)
		{
			if (reporting_disabled > 0 || !printer.HasRelatedSymbolSupport)
				return;

			var mc = ms.MemberDefinition as MemberCore;
			while (ms is ElementTypeSpec) {
				ms = ((ElementTypeSpec) ms).Element;
				mc = ms.MemberDefinition as MemberCore;
			}

			if (mc != null) {
				SymbolRelatedToPreviousError (mc);
			} else {
				if (ms.DeclaringType != null)
					ms = ms.DeclaringType;

				var imported_type = ms.MemberDefinition as ImportedTypeDefinition;
				if (imported_type != null) {
					var iad = imported_type.DeclaringAssembly as ImportedAssemblyDefinition;
					SymbolRelatedToPreviousError (iad.Location, "");
				}
			}
		}
Exemple #8
0
 bool OverloadResolver.IErrorHandler.AmbiguousCandidates(ResolveContext ec, MemberSpec best, MemberSpec ambiguous)
 {
     return(false);
 }
Exemple #9
0
 bool OverloadResolver.IErrorHandler.ArgumentMismatch(ResolveContext rc, MemberSpec best, Argument arg, int index)
 {
     Error_ConversionFailed(rc, best as MethodSpec, null);
     return(true);
 }
Exemple #10
0
 static public string GetFullNameSignature(MemberSpec mi)
 {
     return(mi.GetSignatureForError());
 }
Exemple #11
0
 static public string CSharpSignature(MemberSpec mb)
 {
     return(mb.GetSignatureForError());
 }
Exemple #12
0
		protected override bool CheckOverrideAgainstBase (MemberSpec base_member)
		{
			var ok = base.CheckOverrideAgainstBase (base_member);

			//
			// Check base property accessors conflict
			//
			var base_prop = (PropertySpec) base_member;
			if (Get == null) {
				if ((ModFlags & Modifiers.SEALED) != 0 && base_prop.HasGet && !base_prop.Get.IsAccessible (this)) {
					// TODO: Should be different error code but csc uses for some reason same
					Report.SymbolRelatedToPreviousError (base_prop);
					Report.Error (545, Location,
						"`{0}': cannot override because `{1}' does not have accessible get accessor",
						GetSignatureForError (), base_prop.GetSignatureForError ());
					ok = false;
				}
			} else {
				if (!base_prop.HasGet) {
					if (ok) {
						Report.SymbolRelatedToPreviousError (base_prop);
						Report.Error (545, Get.Location,
							"`{0}': cannot override because `{1}' does not have an overridable get accessor",
							Get.GetSignatureForError (), base_prop.GetSignatureForError ());
						ok = false;
					}
				} else if (Get.HasCustomAccessModifier || base_prop.HasDifferentAccessibility) {
					if (!base_prop.Get.IsAccessible (this)) {
						// Same as csc but it should be different error code
						Report.Error (115, Get.Location, "`{0}' is marked as an override but no accessible `get' accessor found to override",
							GetSignatureForError ());
						ok = false;
					} else if (!CheckAccessModifiers (Get, base_prop.Get)) {
						Error_CannotChangeAccessModifiers (Get, base_prop.Get);
						ok = false;
					}
				}
			}

			if (Set == null) {
				if (base_prop.HasSet) {
					if ((ModFlags & Modifiers.SEALED) != 0 && !base_prop.Set.IsAccessible (this)) {
						// TODO: Should be different error code but csc uses for some reason same
						Report.SymbolRelatedToPreviousError (base_prop);
						Report.Error (546, Location,
							"`{0}': cannot override because `{1}' does not have accessible set accessor",
							GetSignatureForError (), base_prop.GetSignatureForError ());
						ok = false;
					}

					if ((ModFlags & Modifiers.AutoProperty) != 0) {
						Report.Error (8080, Location, "`{0}': Auto-implemented properties must override all accessors of the overridden property",
							GetSignatureForError ());
						ok = false;
					}
				}
			} else {
				if (!base_prop.HasSet) {
					if (ok) {
						Report.SymbolRelatedToPreviousError (base_prop);
						Report.Error (546, Set.Location,
							"`{0}': cannot override because `{1}' does not have an overridable set accessor",
							Set.GetSignatureForError (), base_prop.GetSignatureForError ());
						ok = false;
					}
				} else if (Set.HasCustomAccessModifier || base_prop.HasDifferentAccessibility) {
					if (!base_prop.Set.IsAccessible (this)) {
						// Same as csc but it should be different error code
						Report.Error (115, Set.Location, "`{0}' is marked as an override but no accessible `set' accessor found to override",
							GetSignatureForError ());
						ok = false;
					} else if (!CheckAccessModifiers (Set, base_prop.Set)) {
						Error_CannotChangeAccessModifiers (Set, base_prop.Set);
						ok = false;
					}
				}
			}

			if ((Set == null || !Set.HasCustomAccessModifier) && (Get == null || !Get.HasCustomAccessModifier)) {
				if (!CheckAccessModifiers (this, base_prop)) {
					Error_CannotChangeAccessModifiers (this, base_prop);
					ok = false;
				}
			}

			return ok;
		}
Exemple #13
0
 public override List <MissingTypeSpecReference> ResolveMissingDependencies(MemberSpec caller)
 {
     return(memberType.ResolveMissingDependencies(this));
 }
Exemple #14
0
 bool OverloadResolver.IErrorHandler.TypeInferenceFailed(ResolveContext rc, MemberSpec best)
 {
     return(false);
 }
Exemple #15
0
		protected override MemberSpec FindBaseMember (out MemberSpec bestCandidate, ref bool overrides)
		{
			// Is never override
			bestCandidate = null;
			return null;
		}
Exemple #16
0
		public List<MissingTypeSpecReference> GetMissingDependencies (MemberSpec caller)
		{
			if ((state & (StateFlags.MissingDependency | StateFlags.MissingDependency_Undetected)) == 0)
				return null;

			state &= ~StateFlags.MissingDependency_Undetected;

			var imported = definition as ImportedDefinition;
			List<MissingTypeSpecReference> missing;
			if (imported != null) {
				missing = ResolveMissingDependencies (caller);
			} else if (this is ElementTypeSpec) {
				missing = ((ElementTypeSpec) this).Element.GetMissingDependencies (caller);
			} else {
				missing = null;
			}

			if (missing != null) {
				state |= StateFlags.MissingDependency;
			}

			return missing;
		}
Exemple #17
0
		//
		// Performs various checks on the MethodInfo `mb' regarding the modifier flags
		// that have been defined.
		//
		protected virtual bool CheckOverrideAgainstBase (MemberSpec base_member)
		{
			bool ok = true;

			if ((base_member.Modifiers & (Modifiers.ABSTRACT | Modifiers.VIRTUAL | Modifiers.OVERRIDE)) == 0) {
				Report.SymbolRelatedToPreviousError (base_member);
				Report.Error (506, Location,
					"`{0}': cannot override inherited member `{1}' because it is not marked virtual, abstract or override",
					 GetSignatureForError (), TypeManager.CSharpSignature (base_member));
				ok = false;
			}

			// Now we check that the overriden method is not final	
			if ((base_member.Modifiers & Modifiers.SEALED) != 0) {
				Report.SymbolRelatedToPreviousError (base_member);
				Report.Error (239, Location, "`{0}': cannot override inherited member `{1}' because it is sealed",
							  GetSignatureForError (), TypeManager.CSharpSignature (base_member));
				ok = false;
			}

			var base_member_type = ((IInterfaceMemberSpec) base_member).MemberType;
			if (!TypeSpecComparer.Override.IsEqual (MemberType, base_member_type)) {
				Report.SymbolRelatedToPreviousError (base_member);
				if (this is PropertyBasedMember) {
					Report.Error (1715, Location, "`{0}': type must be `{1}' to match overridden member `{2}'",
						GetSignatureForError (), base_member_type.GetSignatureForError (), base_member.GetSignatureForError ());
				} else {
					Report.Error (508, Location, "`{0}': return type must be `{1}' to match overridden member `{2}'",
						GetSignatureForError (), base_member_type.GetSignatureForError (), base_member.GetSignatureForError ());
				}
				ok = false;
			}

			return ok;
		}
Exemple #18
0
		public abstract List<MissingTypeSpecReference> ResolveMissingDependencies (MemberSpec caller);
Exemple #19
0
 bool OverloadResolver.IErrorHandler.NoArgumentMatch(ResolveContext rc, MemberSpec best)
 {
     Error_ConversionFailed(rc, best as MethodSpec, null);
     return(true);
 }
Exemple #20
0
			bool OverloadResolver.IErrorHandler.AmbiguousCandidates (ResolveContext ec, MemberSpec best, MemberSpec ambiguous)
			{
				ec.Report.SymbolRelatedToPreviousError (best);
				ec.Report.Warning (278, 2, loc,
					"`{0}' contains ambiguous implementation of `{1}' pattern. Method `{2}' is ambiguous with method `{3}'",
					expr.Type.GetSignatureForError (), "enumerable",
					best.GetSignatureForError (), ambiguous.GetSignatureForError ());

				ambiguous_getenumerator_name = true;
				return true;
			}
Exemple #21
0
	static public string GetFullNameSignature (MemberSpec mi)
	{
		return mi.GetSignatureForError ();
	}
Exemple #22
0
			bool OverloadResolver.IErrorHandler.ArgumentMismatch (ResolveContext rc, MemberSpec best, Argument arg, int index)
			{
				return false;
			}
Exemple #23
0
		bool OverloadResolver.IErrorHandler.AmbiguousCandidates (ResolveContext ec, MemberSpec best, MemberSpec ambiguous)
		{
			return false;
		}
Exemple #24
0
			bool OverloadResolver.IErrorHandler.NoArgumentMatch (ResolveContext rc, MemberSpec best)
			{
				return false;
			}
Exemple #25
0
		bool OverloadResolver.IErrorHandler.NoArgumentMatch (ResolveContext rc, MemberSpec best)
		{
			Error_ConversionFailed (rc, best as MethodSpec, null);
			return true;
		}
Exemple #26
0
        //
        // Get a prefix from member type for XML documentation (used
        // to formalize cref target name).
        //
        static string GetMemberDocHead(MemberSpec type)
        {
            if (type is FieldSpec)
                return "F:";
            if (type is MethodSpec)
                return "M:";
            if (type is EventSpec)
                return "E:";
            if (type is PropertySpec)
                return "P:";
            if (type is TypeSpec)
                return "T:";

            return "!:";
        }
Exemple #27
0
		/// <summary>
		/// Gets base method and its return type
		/// </summary>
		protected virtual MemberSpec FindBaseMember (out MemberSpec bestCandidate)
		{
			return MemberCache.FindBaseMember (this, out bestCandidate);
		}
Exemple #28
0
        static string GetParametersFormatted(MemberSpec mi)
        {
            var pm = mi as IParametersMember;
            if (pm == null || pm.Parameters.IsEmpty)
                return string.Empty;

            AParametersCollection parameters = pm.Parameters;
            /*
            if (parameters == null || parameters.Count == 0)
                return String.Empty;
            */
            StringBuilder sb = new StringBuilder ();
            sb.Append ('(');
            for (int i = 0; i < parameters.Count; i++) {
            //				if (is_setter && i + 1 == parameters.Count)
            //					break; // skip "value".
                if (i > 0)
                    sb.Append (',');
                TypeSpec t = parameters.Types [i];
                sb.Append (GetSignatureForDoc (t));
            }
            sb.Append (')');
            return sb.ToString ();
        }
		protected override bool CheckOverrideAgainstBase (MemberSpec base_member)
		{
			var ok = base.CheckOverrideAgainstBase (base_member);

			//
			// Check base property accessors conflict
			//
			var base_prop = (PropertySpec) base_member;
			if (Get != null) {
				if (!base_prop.HasGet) {
					if (ok) {
						Report.SymbolRelatedToPreviousError (base_prop);
						Report.Error (545, Get.Location,
							"`{0}': cannot override because `{1}' does not have an overridable get accessor",
							Get.GetSignatureForError (), base_prop.GetSignatureForError ());
						ok = false;
					}
				} else if (Get.HasCustomAccessModifier || base_prop.HasDifferentAccessibility) {
					if (!CheckAccessModifiers (Get, base_prop.Get)) {
						Error_CannotChangeAccessModifiers (Get, base_prop.Get);
						ok = false;
					}
				}
			}

			if (Set != null) {
				if (!base_prop.HasSet) {
					if (ok) {
						Report.SymbolRelatedToPreviousError (base_prop);
						Report.Error (546, Set.Location,
							"`{0}': cannot override because `{1}' does not have an overridable set accessor",
							Set.GetSignatureForError (), base_prop.GetSignatureForError ());
						ok = false;
					}
				} else if (Set.HasCustomAccessModifier || base_prop.HasDifferentAccessibility) {
					if (!CheckAccessModifiers (Set, base_prop.Set)) {
						Error_CannotChangeAccessModifiers (Set, base_prop.Set);
						ok = false;
					}
				}
			}

			if ((Set == null || !Set.HasCustomAccessModifier) && (Get == null || !Get.HasCustomAccessModifier)) {
				if (!CheckAccessModifiers (this, base_prop)) {
					Error_CannotChangeAccessModifiers (this, base_prop);
					ok = false;
				}
			}

			return ok;
		}
Exemple #30
0
 static void Report419(MemberCore mc, string member_name, MemberSpec [] mis, Report Report)
 {
     Report.Warning (419, 3, mc.Location,
         "Ambiguous reference in cref attribute `{0}'. Assuming `{1}' but other overloads including `{2}' have also matched",
         member_name,
         TypeManager.GetFullNameSignature (mis [0]),
         TypeManager.GetFullNameSignature (mis [1]));
 }
Exemple #31
0
		protected override bool CheckOverrideAgainstBase (MemberSpec base_member)
		{
			bool res = base.CheckOverrideAgainstBase (base_member);

			//
			// Check that the permissions are not being changed
			//
			if (!CheckAccessModifiers (this, base_member)) {
				Error_CannotChangeAccessModifiers (this, base_member);
				res = false;
			}

			return res;
		}
Exemple #32
0
		//
		// Get a prefix from member type for XML documentation (used
		// to formalize cref target name).
		//
		static string GetMemberDocHead (MemberSpec type)
		{
			if (type is FieldSpec)
				return "F:";
			if (type is MethodSpec)
				return "M:";
			if (type is EventSpec)
				return "E:";
			if (type is PropertySpec)
				return "P:";
			if (type is TypeSpec)
				return "T:";

			throw new NotImplementedException (type.GetType ().ToString ());
		}
Exemple #33
0
		protected override MemberSpec FindBaseMember (out MemberSpec bestCandidate, ref bool overrides)
		{
			// Operator cannot be override
			bestCandidate = null;
			return null;
		}
Exemple #34
0
		public override List<MissingTypeSpecReference> ResolveMissingDependencies (MemberSpec caller)
		{
			var missing = base.ResolveMissingDependencies (caller);

			foreach (var pt in parameters.Types) {
				var m = pt.GetMissingDependencies (caller);
				if (m == null)
					continue;

				if (missing == null)
					missing = new List<MissingTypeSpecReference> ();

				missing.AddRange (m);
			}

			return missing;
		}
Exemple #35
0
		protected static bool CheckAccessModifiers (MemberCore this_member, MemberSpec base_member)
		{
			var thisp = this_member.ModFlags & Modifiers.AccessibilityMask;
			var base_classp = base_member.Modifiers & Modifiers.AccessibilityMask;

			if ((base_classp & (Modifiers.PROTECTED | Modifiers.INTERNAL)) == (Modifiers.PROTECTED | Modifiers.INTERNAL)) {
				//
				// It must be at least "protected"
				//
				if ((thisp & Modifiers.PROTECTED) == 0) {
					return false;
				}

				//
				// when overriding protected internal, the method can be declared
				// protected internal only within the same assembly or assembly
				// which has InternalsVisibleTo
				//
				if ((thisp & Modifiers.INTERNAL) != 0) {
					return base_member.DeclaringType.MemberDefinition.IsInternalAsPublic (this_member.Module.DeclaringAssembly);
				}

				//
				// protected overriding protected internal inside same assembly
				// requires internal modifier as well
				//
				if (base_member.DeclaringType.MemberDefinition.IsInternalAsPublic (this_member.Module.DeclaringAssembly)) {
					return false;
				}

				return true;
			}

			return thisp == base_classp;
		}
Exemple #36
0
		public override List<MissingTypeSpecReference> ResolveMissingDependencies (MemberSpec caller)
		{
			return memberType.ResolveMissingDependencies (this);
		}
Exemple #37
0
		/// <summary>
		/// Gets base method and its return type
		/// </summary>
		protected virtual MemberSpec FindBaseMember (out MemberSpec bestCandidate, ref bool overrides)
		{
			return MemberCache.FindBaseMember (this, out bestCandidate, ref overrides);
		}
Exemple #38
0
 public abstract List <MissingTypeSpecReference> ResolveMissingDependencies(MemberSpec caller);