Exemple #1
0
            public bool NoExactMatch(ParseContext ec, MethodBase method)
            {
                var pd         = TypeManager.GetParameterData(method);
                var sourceType = pd.ExtensionMethodType;

                if (sourceType != null)
                {
                    var a = Arguments[0];

                    if (TypeManager.IsGenericType(sourceType) && TypeManager.ContainsGenericParameters(sourceType))
                    {
                        var tic = new TypeInferenceContext(sourceType.GetGenericArguments());
                        tic.OutputTypeInference(ec, a.Value, sourceType);
                        if (tic.FixAllTypes(ec))
                        {
                            sourceType = TypeManager.DropGenericTypeArguments(sourceType).MakeGenericType(tic.InferredTypeArguments);
                        }
                    }

                    if (!TypeManager.ImplicitConversionExists(ec, a.Value, sourceType))
                    {
                        ec.ReportError(
                            1936,
                            string.Format(
                                "An implementation of `{0}' query expression pattern for source type `{1}' could not be found",
                                MethodGroup.Name,
                                TypeManager.GetCSharpName(a.Value.Type)),
                            Span);

                        return(true);
                    }
                }

                if (!method.IsGenericMethod)
                {
                    return(false);
                }

                if (MethodGroup.Name == "SelectMany")
                {
                    ec.ReportError(
                        1943,
                        string.Format(
                            "An expression type is incorrect in a subsequent 'from' clause in a query expression with source type '{0}'.",
                            Arguments[0].GetSignatureForError()),
                        Span);
                }
                else
                {
                    ec.ReportError(
                        1942,
                        string.Format(
                            "An expression type in '{0}' clause is incorrect. Type inference failed in the call to '{1}'.",
                            MethodGroup.Name.ToLower(),
                            MethodGroup.Name),
                        Span);
                }

                return(true);
            }
Exemple #2
0
            public bool NoExactMatch(ResolveContext ec, MethodBase method)
            {
                AParametersCollection pd = TypeManager.GetParameterData(method);
                Type source_type         = pd.ExtensionMethodType;

                if (source_type != null)
                {
                    Argument a = arguments [0];

                    if (TypeManager.IsGenericType(source_type) && TypeManager.ContainsGenericParameters(source_type))
                    {
#if GMCS_SOURCE
                        TypeInferenceContext tic = new TypeInferenceContext(TypeManager.GetTypeArguments(source_type));
                        tic.OutputTypeInference(ec, a.Expr, source_type);
                        if (tic.FixAllTypes(ec))
                        {
                            source_type = TypeManager.DropGenericTypeArguments(source_type).MakeGenericType(tic.InferredTypeArguments);
                        }
#else
                        throw new NotSupportedException();
#endif
                    }

                    if (!Convert.ImplicitConversionExists(ec, a.Expr, source_type))
                    {
                        ec.Report.Error(1936, loc, "An implementation of `{0}' query expression pattern for source type `{1}' could not be found",
                                        mg.Name, TypeManager.CSharpName(a.Type));
                        return(true);
                    }
                }

                if (!TypeManager.IsGenericMethod(method))
                {
                    return(false);
                }

                if (mg.Name == "SelectMany")
                {
                    ec.Report.Error(1943, loc,
                                    "An expression type is incorrect in a subsequent `from' clause in a query expression with source type `{0}'",
                                    arguments [0].GetSignatureForError());
                }
                else
                {
                    ec.Report.Error(1942, loc,
                                    "An expression type in `{0}' clause is incorrect. Type inference failed in the call to `{1}'",
                                    mg.Name.ToLower(), mg.Name);
                }

                return(true);
            }
Exemple #3
0
            bool OverloadResolver.IErrorHandler.TypeInferenceFailed(ResolveContext rc, MemberSpec best)
            {
                var      ms          = (MethodSpec)best;
                TypeSpec source_type = ms.Parameters.ExtensionMethodType;

                if (source_type != null)
                {
                    Argument a = arguments[0];

                    if (TypeManager.IsGenericType(source_type) && InflatedTypeSpec.ContainsTypeParameter(source_type))
                    {
                        TypeInferenceContext tic = new TypeInferenceContext(source_type.TypeArguments);
                        tic.OutputTypeInference(rc, a.Expr, source_type);
                        if (tic.FixAllTypes(rc))
                        {
                            source_type = source_type.GetDefinition().MakeGenericType(rc, tic.InferredTypeArguments);
                        }
                    }

                    if (!Convert.ImplicitConversionExists(rc, a.Expr, source_type))
                    {
                        rc.Report.Error(1936, loc, "An implementation of `{0}' query expression pattern for source type `{1}' could not be found",
                                        best.Name, a.Type.GetSignatureForError());
                        return(true);
                    }
                }

                if (best.Name == "SelectMany")
                {
                    rc.Report.Error(1943, loc,
                                    "An expression type is incorrect in a subsequent `from' clause in a query expression with source type `{0}'",
                                    arguments[0].GetSignatureForError());
                }
                else
                {
                    rc.Report.Error(1942, loc,
                                    "An expression type in `{0}' clause is incorrect. Type inference failed in the call to `{1}'",
                                    best.Name.ToLowerInvariant(), best.Name);
                }

                return(true);
            }
Exemple #4
0
			bool OverloadResolver.IErrorHandler.TypeInferenceFailed (ResolveContext rc, MemberSpec best)
			{
				var ms = (MethodSpec) best;
				TypeSpec source_type = ms.Parameters.ExtensionMethodType;
				if (source_type != null) {
					Argument a = arguments[0];

					if (TypeManager.IsGenericType (source_type) && TypeManager.ContainsGenericParameters (source_type)) {
						TypeInferenceContext tic = new TypeInferenceContext (source_type.TypeArguments);
						tic.OutputTypeInference (rc, a.Expr, source_type);
						if (tic.FixAllTypes (rc)) {
							source_type = source_type.GetDefinition ().MakeGenericType (tic.InferredTypeArguments);
						}
					}

					if (!Convert.ImplicitConversionExists (rc, a.Expr, source_type)) {
						rc.Report.Error (1936, loc, "An implementation of `{0}' query expression pattern for source type `{1}' could not be found",
							best.Name, TypeManager.CSharpName (a.Type));
						return true;
					}
				}

				if (best.Name == "SelectMany") {
					rc.Report.Error (1943, loc,
						"An expression type is incorrect in a subsequent `from' clause in a query expression with source type `{0}'",
						arguments[0].GetSignatureForError ());
				} else {
					rc.Report.Error (1942, loc,
						"An expression type in `{0}' clause is incorrect. Type inference failed in the call to `{1}'",
						best.Name.ToLowerInvariant (), best.Name);
				}

				return true;
			}
Exemple #5
0
			public bool NoExactMatch (EmitContext ec, MethodBase method)
			{
#if GMCS_SOURCE				
				AParametersCollection pd = TypeManager.GetParameterData (method);
				Type source_type = pd.ExtensionMethodType;
				if (source_type != null) {
					Argument a = (Argument) Arguments [0];

					if (source_type.IsGenericType && source_type.ContainsGenericParameters) {
						TypeInferenceContext tic = new TypeInferenceContext (source_type.GetGenericArguments ());
						tic.OutputTypeInference (ec, a.Expr, source_type);
						if (tic.FixAllTypes ()) {
							source_type = source_type.GetGenericTypeDefinition ().MakeGenericType (tic.InferredTypeArguments);
						}
					}

					if (!Convert.ImplicitConversionExists (ec, a.Expr, source_type)) {
						Report.Error (1936, loc, "An implementation of `{0}' query expression pattern for source type `{1}' could not be found",
							mg.Name, TypeManager.CSharpName (a.Type));
						return true;
					}
				}

				if (!method.IsGenericMethod)
					return false;

				if (mg.Name == "SelectMany") {
					Report.Error (1943, loc,
						"An expression type is incorrect in a subsequent `from' clause in a query expression with source type `{0}'",
						((Argument) Arguments [0]).GetSignatureForError ());
				} else {
					Report.Error (1942, loc,
						"An expression type in `{0}' clause is incorrect. Type inference failed in the call to `{1}'",
						mg.Name.ToLower (), mg.Name);
				}
				return true;
#else
				return false;
#endif
			}
Exemple #6
0
            public bool NoExactMatch(ResolveContext ec, MethodSpec method)
            {
                var pd = method.Parameters;
                TypeSpec source_type = pd.ExtensionMethodType;
                if (source_type != null) {
                    Argument a = arguments [0];

                    if (TypeManager.IsGenericType (source_type) && TypeManager.ContainsGenericParameters (source_type)) {
                        TypeInferenceContext tic = new TypeInferenceContext (source_type.TypeArguments);
                        tic.OutputTypeInference (ec, a.Expr, source_type);
                        if (tic.FixAllTypes (ec)) {
                            source_type = source_type.GetDefinition ().MakeGenericType (tic.InferredTypeArguments);
                        }
                    }

                    if (!Convert.ImplicitConversionExists (ec, a.Expr, source_type)) {
                        ec.Report.Error (1936, loc, "An implementation of `{0}' query expression pattern for source type `{1}' could not be found",
                            mg.Name, TypeManager.CSharpName (a.Type));
                        return true;
                    }
                }

                if (!method.IsGeneric)
                    return false;

                if (mg.Name == "SelectMany") {
                    ec.Report.Error (1943, loc,
                        "An expression type is incorrect in a subsequent `from' clause in a query expression with source type `{0}'",
                        arguments [0].GetSignatureForError ());
                } else {
                    ec.Report.Error (1942, loc,
                        "An expression type in `{0}' clause is incorrect. Type inference failed in the call to `{1}'",
                        mg.Name.ToLower (), mg.Name);
                }

                return true;
            }