2010-04-29 Marek Safar <marek.safar@gmail.com>
[mono.git] / mcs / mcs / linq.cs
index a4b427e482b8231432c6052aff4b40383cab8c4d..6201b8336f1836a4613d2fe5eb36c698b4c13d08 100644 (file)
@@ -20,7 +20,7 @@ namespace Mono.CSharp.Linq
        //
        //
 
-       class QueryExpression : AQueryClause
+       public class QueryExpression : AQueryClause
        {
                public QueryExpression (Block block, AQueryClause query)
                        : base (null, null, query.Location)
@@ -56,7 +56,7 @@ namespace Mono.CSharp.Linq
                }
        }
 
-       abstract class AQueryClause : ShimExpression
+       public abstract class AQueryClause : ShimExpression
        {
                class QueryExpressionAccess : MemberAccess
                {
@@ -70,8 +70,8 @@ namespace Mono.CSharp.Linq
                        {
                        }
 
-                       protected override Expression Error_MemberLookupFailed (ResolveContext ec, Type container_type, Type qualifier_type,
-                               Type queried_type, string name, string class_name, MemberTypes mt, BindingFlags bf)
+                       protected override Expression Error_MemberLookupFailed (ResolveContext ec, TypeSpec container_type, TypeSpec qualifier_type,
+                               TypeSpec queried_type, string name, int arity, string class_name, MemberKind mt, BindingRestriction bf)
                        {
                                ec.Report.Error (1935, loc, "An implementation of `{0}' query expression pattern could not be found. " +
                                        "Are you missing `System.Linq' using directive or `System.Core.dll' assembly reference?",
@@ -94,27 +94,27 @@ namespace Mono.CSharp.Linq
                                return rmg;
                        }
 
-                       public bool AmbiguousCall (ResolveContext ec, MethodBase ambiguous)
+                       public bool AmbiguousCall (ResolveContext ec, MethodSpec ambiguous)
                        {
-                               ec.Report.SymbolRelatedToPreviousError ((MethodInfo) mg);
+                               ec.Report.SymbolRelatedToPreviousError (mg.BestCandidate);
                                ec.Report.SymbolRelatedToPreviousError (ambiguous);
                                ec.Report.Error (1940, loc, "Ambiguous implementation of the query pattern `{0}' for source type `{1}'",
                                        mg.Name, mg.InstanceExpression.GetSignatureForError ());
                                return true;
                        }
 
-                       public bool NoExactMatch (ResolveContext ec, MethodBase method)
+                       public bool NoExactMatch (ResolveContext ec, MethodSpec method)
                        {
-                               AParametersCollection pd = TypeManager.GetParameterData (method);
-                               Type source_type = pd.ExtensionMethodType;
+                               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 (TypeManager.GetTypeArguments (source_type));
+                                               TypeInferenceContext tic = new TypeInferenceContext (source_type.TypeArguments);
                                                tic.OutputTypeInference (ec, a.Expr, source_type);
                                                if (tic.FixAllTypes (ec)) {
-                                                       source_type = TypeManager.DropGenericTypeArguments (source_type).MakeGenericType (tic.InferredTypeArguments);
+                                                       source_type = source_type.GetDefinition ().MakeGenericType (tic.InferredTypeArguments);
                                                }
                                        }
 
@@ -125,7 +125,7 @@ namespace Mono.CSharp.Linq
                                        }
                                }
 
-                               if (!TypeManager.IsGenericMethod (method))
+                               if (!method.IsGeneric)
                                        return false;
 
                                if (mg.Name == "SelectMany") {
@@ -230,7 +230,7 @@ namespace Mono.CSharp.Linq
        //
        // A query clause with an identifier (range variable)
        //
-       abstract class ARangeVariableQueryClause : AQueryClause
+       public abstract class ARangeVariableQueryClause : AQueryClause
        {
                sealed class RangeAnonymousTypeParameter : AnonymousTypeParameter
                {
@@ -251,12 +251,12 @@ namespace Mono.CSharp.Linq
                {
                }
 
-               protected static Expression CreateRangeVariableType (ToplevelBlock block, IMemberContext context, SimpleMemberName name, Expression init)
+               protected static Expression CreateRangeVariableType (ToplevelBlock block, TypeContainer container, SimpleMemberName name, Expression init)
                {
                        var args = new List<AnonymousTypeParameter> (2);
                        args.Add (new AnonymousTypeParameter (block.Parameters [0]));
                        args.Add (new RangeAnonymousTypeParameter (init, name));
-                       return new NewAnonymousType (args, context.CurrentTypeDefinition, name.Location);
+                       return new NewAnonymousType (args, container, name.Location);
                }
        }
 
@@ -273,7 +273,7 @@ namespace Mono.CSharp.Linq
                        if (expr == null)
                                return null;
 
-                       if (TypeManager.IsDynamicType (expr.Type) || expr.Type == TypeManager.void_type) {
+                       if (expr.Type == InternalType.Dynamic || expr.Type == TypeManager.void_type) {
                                ec.Report.Error (1979, expr.Location,
                                        "Query expression with a source or join sequence of type `{0}' is not allowed",
                                        TypeManager.CSharpName (expr.Type));
@@ -319,7 +319,7 @@ namespace Mono.CSharp.Linq
                }
        }
 
-       class GroupBy : AQueryClause
+       public class GroupBy : AQueryClause
        {
                Expression element_selector;
                ToplevelBlock element_block;
@@ -364,7 +364,7 @@ namespace Mono.CSharp.Linq
                }
        }
 
-       class Join : ARangeVariableQueryClause
+       public class Join : ARangeVariableQueryClause
        {
                readonly SimpleMemberName lt;
                ToplevelBlock inner_selector, outer_selector;
@@ -400,7 +400,7 @@ namespace Mono.CSharp.Linq
                                result_selector_expr = next.Expr;
                                next = next.next;
                        } else {
-                               result_selector_expr = CreateRangeVariableType (block, ec.MemberContext, into_variable,
+                               result_selector_expr = CreateRangeVariableType (block, ec.MemberContext.CurrentMemberDefinition.Parent, into_variable,
                                        new SimpleName (into_variable.Value, into_variable.Location));
                        }
 
@@ -429,7 +429,7 @@ namespace Mono.CSharp.Linq
                }
        }
 
-       class GroupJoin : Join
+       public class GroupJoin : Join
        {
                readonly SimpleMemberName into;
 
@@ -450,7 +450,7 @@ namespace Mono.CSharp.Linq
                }
        }
 
-       class Let : ARangeVariableQueryClause
+       public class Let : ARangeVariableQueryClause
        {
                public Let (ToplevelBlock block, TypeContainer container, SimpleMemberName identifier, Expression expr)
                        : base (block, CreateRangeVariableType (block, container, identifier, expr))
@@ -462,7 +462,7 @@ namespace Mono.CSharp.Linq
                }
        }
 
-       class Select : AQueryClause
+       public class Select : AQueryClause
        {
                public Select (ToplevelBlock block, Expression expr, Location loc)
                        : base (block, expr, loc)
@@ -488,7 +488,7 @@ namespace Mono.CSharp.Linq
                }
        }
 
-       class SelectMany : ARangeVariableQueryClause
+       public class SelectMany : ARangeVariableQueryClause
        {
                SimpleMemberName lt;
 
@@ -510,7 +510,7 @@ namespace Mono.CSharp.Linq
                                result_selector_expr = next.Expr;
                                next = next.next;
                        } else {
-                               result_selector_expr = CreateRangeVariableType (block, ec.MemberContext, lt, new SimpleName (lt.Value, lt.Location));
+                               result_selector_expr = CreateRangeVariableType (block, ec.MemberContext.CurrentMemberDefinition.Parent, lt, new SimpleName (lt.Value, lt.Location));
                        }
 
                        LambdaExpression result_selector = new LambdaExpression (lt.Location);
@@ -525,7 +525,7 @@ namespace Mono.CSharp.Linq
                }
        }
 
-       class Where : AQueryClause
+       public class Where : AQueryClause
        {
                public Where (ToplevelBlock block, BooleanExpression expr, Location loc)
                        : base (block, expr, loc)
@@ -537,7 +537,7 @@ namespace Mono.CSharp.Linq
                }
        }
 
-       class OrderByAscending : AQueryClause
+       public class OrderByAscending : AQueryClause
        {
                public OrderByAscending (ToplevelBlock block,Expression expr)
                        : base (block, expr, expr.Location)
@@ -549,7 +549,7 @@ namespace Mono.CSharp.Linq
                }
        }
 
-       class OrderByDescending : AQueryClause
+       public class OrderByDescending : AQueryClause
        {
                public OrderByDescending (ToplevelBlock block, Expression expr)
                        : base (block, expr, expr.Location)
@@ -561,7 +561,7 @@ namespace Mono.CSharp.Linq
                }
        }
 
-       class ThenByAscending : OrderByAscending
+       public class ThenByAscending : OrderByAscending
        {
                public ThenByAscending (ToplevelBlock block, Expression expr)
                        : base (block, expr)
@@ -573,7 +573,7 @@ namespace Mono.CSharp.Linq
                }
        }
 
-       class ThenByDescending : OrderByDescending
+       public class ThenByDescending : OrderByDescending
        {
                public ThenByDescending (ToplevelBlock block, Expression expr)
                        : base (block, expr)
@@ -609,7 +609,7 @@ namespace Mono.CSharp.Linq
                                Identifier = identifier.Value;
                        }
 
-                       public static void Reset ()
+                       public new static void Reset ()
                        {
                                Counter = 0;
                        }