@@ -2418,7 +2418,6 @@ module QuotationOfResizeArrayIteration =
24182418module TestAutoQuoteAtStaticMethodCalls =
24192419open Microsoft.FSharp .Quotations
24202420
2421-
24222421type C () =
24232422static let cleanup ( s : string ) = s.Replace( " " , " " ) .Replace( " \n " , " " ) .Replace( " \r " , " " )
24242423static member Plot ( [<ReflectedDefinition>] x : Expr < 'T >) =
@@ -2613,6 +2612,92 @@ module TestAutoQuoteAtInstanceMethodCalls =
26132612
26142613 testItAll()
26152614
2615+ module TestsForUsingReflectedDefinitionArgumentsAsFirstClassValues =
2616+ open Microsoft.FSharp .Quotations
2617+ open System.Linq .Expressions
2618+ open System
2619+
2620+ type FirstClassTests () =
2621+ static member PlotRawExpr ( [<ReflectedDefinition>] x : Expr ) = x.ToString()
2622+ static member PlotExpr ( [<ReflectedDefinition>] x : Expr < 'T >) = x.ToString()
2623+ static member PlotExprOverloadedByType ( [<ReflectedDefinition>] x : Expr < int >) = x.ToString()
2624+ static member PlotExprOverloadedByType ( [<ReflectedDefinition>] x : Expr < string >) = x.ToString()
2625+ static member PlotExprOverloadedByShape ( x : int ) = x.ToString()
2626+ static member PlotExprOverloadedByShape ( [<ReflectedDefinition>] x : Expr < int >) = x.ToString()
2627+ static member PlotLinq ( x : Expression < Func < int , 'T >>) = x.ToString()
2628+ static member PlotLinqOverloadedByType ( x : Expression < Func < int , 'T >>) = x.ToString()
2629+ static member PlotLinqOverloadedByType ( x : Expression < Func < string , 'T >>) = x.ToString()
2630+ static member PlotLinqOverloadedByShape ( x : Func < int , 'T >) = x.ToString()
2631+ static member PlotLinqOverloadedByShape ( x : Expression < Func < int , 'T >>) = x.ToString()
2632+
2633+ //open Microsoft.FSharp.Quotations
2634+ //let f (x:Expr<'T>) = x.ToString()
2635+
2636+ ( FirstClassTests.PlotLinq: Expression< Func< int, int>> -> string) // doesn't quote implicit var
2637+ ( FirstClassTests.PlotLinq: ( int-> int) -> string) // doesn't quote implicit var
2638+
2639+ let callLinqWithoutAutoConv ( ef : Expression < Func < int , int >>) = FirstClassTests.PlotLinq ef
2640+ let callLinqWithAutoConv ( f : int -> int ) = FirstClassTests.PlotLinq( fun x -> f x) // needs eta-expansion
2641+
2642+ let callLinqOverloadedByTypeWithoutAutoConvInt ( ef : Expression < Func < int , int >>) = FirstClassTests.PlotLinqOverloadedByType ef
2643+ let callLinqOverloadedByTypeWithoutAutoConvString ( ef : Expression < Func < string , int >>) = FirstClassTests.PlotLinqOverloadedByType ef
2644+ let callLinqOverloadedByTypeWithAutoConvInt ( f : int -> int ) = FirstClassTests.PlotLinqOverloadedByType( fun x -> f x)
2645+ let callLinqOverloadedByTypeWithAutoConvString ( f : string -> int ) = FirstClassTests.PlotLinqOverloadedByType( fun x -> f x)
2646+
2647+ let callLinqOverloadedByShapeWithoutAutoConv ( ef : Expression < Func < int , int >>) = FirstClassTests.PlotLinqOverloadedByShape ef
2648+ // EXPECTED AND CONSISTENT: let callLinqOverloadedByShapeWithAutoConv (f: int -> int) = C.PlotLinqOverloadedByShape (fun x -> f x)
2649+
2650+ let callExprWithoutAutoConv ( ef : Expr < int >) = FirstClassTests.PlotExpr<@ % ef@>
2651+ let callExprWithAutoConv ( ef : int ) = FirstClassTests.PlotExpr ef
2652+
2653+ let callExprOverloadedWithoutAutoConvA ( ef : Expr < int >) = FirstClassTests.PlotExprOverloadedByType<@ % ef@>
2654+ let callExprOverloadedWithoutAutoConvB ( ef : Expr < int >) = FirstClassTests.PlotExprOverloadedByType ef
2655+ let callExprOverloadedWithAutoConv ( ef : int ) = FirstClassTests.PlotExprOverloadedByType ef
2656+
2657+ let callExprOverloadedByShapeWithoutAutoConvA ( ef : Expr < int >) = FirstClassTests.PlotExprOverloadedByShape<@ % ef@>
2658+ let callExprOverloadedByShapeWithoutAutoConvB ( ef : Expr < int >) = FirstClassTests.PlotExprOverloadedByShape ef
2659+ // EXPECTED AND CONSISTENT: let callExprOverloadedByShapeWithAutoConv (ef: int) = C.PlotExprOverloadedByShape ef
2660+
2661+ ( FirstClassTests.PlotLinq: ( int-> int) -> string) // auto- - though not very useful
2662+ ( FirstClassTests.PlotLinq: Expression< Func< int, int>> -> string) // doesn't auto-quote implicit var
2663+ ( FirstClassTests.PlotLinqOverloadedByType: ( int-> int) -> string) // auto- - though not very useful
2664+ ( FirstClassTests.PlotLinqOverloadedByType: ( int-> string) -> string) // auto- - though not very useful
2665+ ( FirstClassTests.PlotLinqOverloadedByType: Expression< Func< int, int>> -> string) // doesn't auto-quote implicit var
2666+ ( FirstClassTests.PlotLinqOverloadedByShape: Expression< Func< int, int>> -> string) // doesn't auto-quote implicit var
2667+ // EXPECTED AND CONSISTENT: (C.PlotLinqOverloadedByShape : (int -> int) -> string) // auto- - though not very useful
2668+
2669+ ( FirstClassTests.PlotRawExpr: Expr-> string) // doesn't auto-quote implicit var
2670+ ( FirstClassTests.PlotRawExpr: obj-> string) // does auto-quote implicit var
2671+ ( FirstClassTests.PlotExpr: Expr< int> -> string) // doesn't auto-quote implicit var
2672+ ( FirstClassTests.PlotExpr: int-> string) // does auto-quote implicit var
2673+ ( FirstClassTests.PlotExprOverloadedByType: Expr< int> -> string) // doesn't auto-quote implicit var
2674+ ( FirstClassTests.PlotExprOverloadedByType: int-> string) // does auto-quote implicit var
2675+ ( FirstClassTests.PlotExprOverloadedByType: string-> string) // does auto-quote implicit var
2676+ ( FirstClassTests.PlotExprOverloadedByShape: Expr< int> -> string) // doesn't auto-quote implicit var
2677+ // EXPECTED AND CONSISTENT: (C.PlotExprOverloadedByShape : int -> string) // does auto-quote implicit var
2678+
2679+
2680+ FirstClassTests.PlotExpr1
2681+ FirstClassTests.PlotExpr<@ 1 @>
2682+ FirstClassTests.PlotExprOverloadedByType1
2683+ FirstClassTests.PlotExprOverloadedByType<@ 1 @>
2684+ FirstClassTests.PlotExprOverloadedByType" a"
2685+ FirstClassTests.PlotExprOverloadedByType<@ " a" @>
2686+ // EXPECTED AND CONSISTENT: 1 |> FirstClassTests.PlotExprOverloadedByShape
2687+ FirstClassTests.PlotExprOverloadedByShape<@ 1 @>
2688+
2689+
2690+ 1 |> FirstClassTests.PlotExpr
2691+ <@ 1 @> |> FirstClassTests.PlotExpr
2692+ 1 |> FirstClassTests.PlotExprOverloadedByType
2693+ <@ 1 @> |> FirstClassTests.PlotExprOverloadedByType
2694+ " a" |> FirstClassTests.PlotExprOverloadedByType
2695+ <@ " a" @> |> FirstClassTests.PlotExprOverloadedByType
2696+ // EXPECTED AND CONSISTENT: 1 |> FirstClassTests.PlotExprOverloadedByShape
2697+ <@ 1 @> |> FirstClassTests.PlotExprOverloadedByShape
2698+
2699+
2700+
26162701let aa =
26172702if not failures.IsEmptythen ( printfn" Test Failed, failures =%A " failures; exit1 )
26182703else ( stdout.WriteLine" Test Passed" ;