当前位置: 首页>>代码示例>>C#>>正文


C# BlockContext.GetSignatureForError方法代码示例

本文整理汇总了C#中Mono.CSharp.BlockContext.GetSignatureForError方法的典型用法代码示例。如果您正苦于以下问题:C# BlockContext.GetSignatureForError方法的具体用法?C# BlockContext.GetSignatureForError怎么用?C# BlockContext.GetSignatureForError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mono.CSharp.BlockContext的用法示例。


在下文中一共展示了BlockContext.GetSignatureForError方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DoResolve

		protected override bool DoResolve (BlockContext ec)
		{
			if (Expr == null) {
				if (ec.ReturnType == TypeManager.void_type)
					return true;

				if (ec.CurrentIterator != null) {
					Error_ReturnFromIterator (ec);
				} else {
					ec.Report.Error (126, loc,
						"An object of a type convertible to `{0}' is required for the return statement",
						ec.ReturnType.GetSignatureForError ());
				}

				return false;
			}

			Expr = Expr.Resolve (ec);

			AnonymousExpression am = ec.CurrentAnonymousMethod;
			if (am == null) {
				if (ec.ReturnType == TypeManager.void_type) {
					ec.Report.Error (127, loc,
						"`{0}': A return keyword must not be followed by any expression when method returns void",
						ec.GetSignatureForError ());
				}
			} else {
				if (am.IsIterator) {
					Error_ReturnFromIterator (ec);
					return false;
				}

				var l = am as AnonymousMethodBody;
				if (l != null && l.ReturnTypeInference != null && Expr != null) {
					l.ReturnTypeInference.AddCommonTypeBound (Expr.Type);
					return true;
				}
			}

			if (Expr == null)
				return false;

			if (Expr.Type != ec.ReturnType) {
				Expr = Convert.ImplicitConversionRequired (ec, Expr, ec.ReturnType, loc);

				if (Expr == null) {
					if (am != null) {
						ec.Report.Error (1662, loc,
							"Cannot convert `{0}' to delegate type `{1}' because some of the return types in the block are not implicitly convertible to the delegate return type",
							am.ContainerType, am.GetSignatureForError ());
					}
					return false;
				}
			}

			return true;			
		}
开发者ID:alisci01,项目名称:mono,代码行数:57,代码来源:statement.cs

示例2: DoResolve

		protected override bool DoResolve (BlockContext ec)
		{
			if (Expr == null) {
				if (ec.ReturnType == TypeManager.void_type)
					return true;
				
				ec.Report.Error (126, loc,
					"An object of a type convertible to `{0}' is required for the return statement",
					TypeManager.CSharpName (ec.ReturnType));
				return false;
			}

			if (ec.CurrentBlock.Toplevel.IsIterator) {
				ec.Report.Error (1622, loc, "Cannot return a value from iterators. Use the yield return " +
						  "statement to return a value, or yield break to end the iteration");
			}

			AnonymousExpression am = ec.CurrentAnonymousMethod;
			if (am == null && ec.ReturnType == TypeManager.void_type) {
				ec.Report.Error (127, loc, "`{0}': A return keyword must not be followed by any expression when method returns void",
					ec.GetSignatureForError ());
			}

			Expr = Expr.Resolve (ec);
			if (Expr == null)
				return false;

			if (ec.HasSet (ResolveContext.Options.InferReturnType)) {
				ec.ReturnTypeInference.AddCommonTypeBound (Expr.Type);
				return true;
			}

			if (Expr.Type != ec.ReturnType) {
				Expr = Convert.ImplicitConversionRequired (ec, Expr, ec.ReturnType, loc);

				if (Expr == null) {
					if (am != null) {
						ec.Report.Error (1662, loc,
							"Cannot convert `{0}' to delegate type `{1}' because some of the return types in the block are not implicitly convertible to the delegate return type",
							am.ContainerType, am.GetSignatureForError ());
					}
					return false;
				}
			}

			return true;			
		}
开发者ID:tgiphil,项目名称:mono,代码行数:47,代码来源:statement.cs


注:本文中的Mono.CSharp.BlockContext.GetSignatureForError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。