@@ -78,69 +78,68 @@ module Nullable =
7878open System
7979
8080[< CompiledName ( "ToUInt8 ")>]
81- let inline uint8 ( x : Nullable < _ >) = if x .HasValuethen Nullable ( Operators.bytex .Value ) else Nullable ()
81+ let inline uint8 ( value : Nullable < _ >) = if value .HasValuethen Nullable ( Operators.bytevalue .Value ) else Nullable ()
8282
8383[< CompiledName ( "ToInt8 ")>]
84- let inline int8 ( x : Nullable < _ >) = if x .HasValuethen Nullable ( Operators.sbytex .Value ) else Nullable ()
84+ let inline int8 ( value : Nullable < _ >) = if value .HasValuethen Nullable ( Operators.sbytevalue .Value ) else Nullable ()
8585
8686[< CompiledName ( "ToByte ")>]
87- let inline byte ( x : Nullable < _ >) = if x .HasValuethen Nullable ( Operators.bytex .Value ) else Nullable ()
87+ let inline byte ( value : Nullable < _ >) = if value .HasValuethen Nullable ( Operators.bytevalue .Value ) else Nullable ()
8888
8989[< CompiledName ( "ToSByte ")>]
90- let inline sbyte ( x : Nullable < _ >) = if x .HasValuethen Nullable ( Operators.sbytex .Value ) else Nullable ()
90+ let inline sbyte ( value : Nullable < _ >) = if value .HasValuethen Nullable ( Operators.sbytevalue .Value ) else Nullable ()
9191
9292[< CompiledName ( "ToInt16 ")>]
93- let inline int16 ( x : Nullable < _ >) = if x .HasValuethen Nullable ( Operators.int16x .Value ) else Nullable ()
93+ let inline int16 ( value : Nullable < _ >) = if value .HasValuethen Nullable ( Operators.int16value .Value ) else Nullable ()
9494
9595[< CompiledName ( "ToUInt16 ")>]
96- let inline uint16 ( x : Nullable < _ >) = if x .HasValuethen Nullable ( Operators.uint16x .Value ) else Nullable ()
96+ let inline uint16 ( value : Nullable < _ >) = if value .HasValuethen Nullable ( Operators.uint16value .Value ) else Nullable ()
9797
9898[< CompiledName ( "ToInt ")>]
99- let inline int ( x : Nullable < _ >) = if x .HasValuethen Nullable ( Operators.intx .Value ) else Nullable ()
99+ let inline int ( value : Nullable < _ >) = if value .HasValuethen Nullable ( Operators.intvalue .Value ) else Nullable ()
100100
101101[< CompiledName ( "ToEnum ")>]
102- let inline enum ( x : Nullable < int32 >) = if x .HasValuethen Nullable ( Operators.enumx .Value ) else Nullable ()
102+ let inline enum ( value : Nullable < int32 >) = if value .HasValuethen Nullable ( Operators.enumvalue .Value ) else Nullable ()
103103
104104[< CompiledName ( "ToInt32 ")>]
105- let inline int32 ( x : Nullable < _ >) = if x .HasValuethen Nullable ( Operators.int32x .Value ) else Nullable ()
105+ let inline int32 ( value : Nullable < _ >) = if value .HasValuethen Nullable ( Operators.int32value .Value ) else Nullable ()
106106
107107[< CompiledName ( "ToUInt32 ")>]
108- let inline uint32 ( x : Nullable < _ >) = if x .HasValuethen Nullable ( Operators.uint32x .Value ) else Nullable ()
108+ let inline uint32 ( value : Nullable < _ >) = if value .HasValuethen Nullable ( Operators.uint32value .Value ) else Nullable ()
109109
110110[< CompiledName ( "ToInt64 ")>]
111- let inline int64 ( x : Nullable < _ >) = if x .HasValuethen Nullable ( Operators.int64x .Value ) else Nullable ()
111+ let inline int64 ( value : Nullable < _ >) = if value .HasValuethen Nullable ( Operators.int64value .Value ) else Nullable ()
112112
113113[< CompiledName ( "ToUInt64 ")>]
114- let inline uint64 ( x : Nullable < _ >) = if x .HasValuethen Nullable ( Operators.uint64x .Value ) else Nullable ()
114+ let inline uint64 ( value : Nullable < _ >) = if value .HasValuethen Nullable ( Operators.uint64value .Value ) else Nullable ()
115115
116116[< CompiledName ( "ToFloat32 ")>]
117- let inline float32 ( x : Nullable < _ >) = if x .HasValuethen Nullable ( Operators.float32x .Value ) else Nullable ()
117+ let inline float32 ( value : Nullable < _ >) = if value .HasValuethen Nullable ( Operators.float32value .Value ) else Nullable ()
118118
119119[< CompiledName ( "ToFloat ")>]
120- let inline float ( x : Nullable < _ >) = if x .HasValuethen Nullable ( Operators.floatx .Value ) else Nullable ()
120+ let inline float ( value : Nullable < _ >) = if value .HasValuethen Nullable ( Operators.floatvalue .Value ) else Nullable ()
121121
122122[< CompiledName ( "ToSingle ")>]
123- let inline single ( x : Nullable < _ >) = if x .HasValuethen Nullable ( Operators.float32x .Value ) else Nullable ()
123+ let inline single ( value : Nullable < _ >) = if value .HasValuethen Nullable ( Operators.float32value .Value ) else Nullable ()
124124
125125[< CompiledName ( "ToDouble ")>]
126- let inline double ( x : Nullable < _ >) = if x .HasValuethen Nullable ( Operators.floatx .Value ) else Nullable ()
126+ let inline double ( value : Nullable < _ >) = if value .HasValuethen Nullable ( Operators.floatvalue .Value ) else Nullable ()
127127
128128[< CompiledName ( "ToIntPtr ")>]
129- let inline nativeint ( x : Nullable < _ >) = if x .HasValuethen Nullable ( Operators.nativeintx .Value ) else Nullable ()
129+ let inline nativeint ( value : Nullable < _ >) = if value .HasValuethen Nullable ( Operators.nativeintvalue .Value ) else Nullable ()
130130
131131[< CompiledName ( "ToUIntPtr ")>]
132- let inline unativeint ( x : Nullable < _ >) = if x .HasValuethen Nullable ( Operators.unativeintx .Value ) else Nullable ()
132+ let inline unativeint ( value : Nullable < _ >) = if value .HasValuethen Nullable ( Operators.unativeintvalue .Value ) else Nullable ()
133133
134134[< CompiledName ( "ToDecimal ")>]
135- let inline decimal ( x : Nullable < _ >) = if x .HasValuethen Nullable ( Operators.decimalx .Value ) else Nullable ()
135+ let inline decimal ( value : Nullable < _ >) = if value .HasValuethen Nullable ( Operators.decimalvalue .Value ) else Nullable ()
136136
137137[< CompiledName ( "ToChar ")>]
138- let inline char ( x : Nullable < _ >) = if x .HasValuethen Nullable ( Operators.charx .Value ) else Nullable ()
138+ let inline char ( value : Nullable < _ >) = if value .HasValuethen Nullable ( Operators.charvalue .Value ) else Nullable ()
139139
140140namespace Microsoft.FSharp.Linq.RuntimeHelpers
141141
142142open System
143- open System.Linq
144143open System.Collections.Generic
145144open System.Linq.Expressions
146145open System.Reflection
@@ -165,7 +164,6 @@ module LeafExpressionConverter =
165164// The following is recognized as a LINQ 'member initialization pattern' in a quotation.
166165let MemberInitializationHelper ( _x : 'T ) : 'T = raise ( NotSupportedException "This function should not be called directly ")
167166
168-
169167// The following is recognized as a LINQ 'member initialization pattern' in a quotation.
170168let NewAnonymousObjectHelper ( _x : 'T ) : 'T = raise ( NotSupportedException "This function should not be called directly ")
171169
@@ -180,7 +178,9 @@ module LeafExpressionConverter =
180178
181179let bindingFlags = BindingFlags.Public ||| BindingFlags.NonPublic
182180let instanceBindingFlags = BindingFlags.Instance ||| BindingFlags.Public ||| BindingFlags.NonPublic ||| BindingFlags.DeclaredOnly
181+
183182let isNamedType ( typ : Type ) = not ( typ.IsArray || typ.IsByRef || typ.IsPointer )
183+
184184let equivHeadTypes ( ty1 : Type ) ( ty2 : Type ) =
185185isNamedType ( ty1 ) &&
186186if ty1.IsGenericType then
@@ -189,6 +189,7 @@ module LeafExpressionConverter =
189189ty1.Equals ( ty2 )
190190
191191let isFunctionType typ = equivHeadTypes typ ( typeof <( int -> int )>)
192+
192193let getFunctionType typ =
193194if not ( isFunctionType typ ) then invalidArg "typ " "cannot convert recursion except for function types "
194195let tyargs = typ.GetGenericArguments ()
@@ -422,24 +423,6 @@ module LeafExpressionConverter =
422423with
423424| :? KeyNotFoundException-> invalidOp( " The variable '" + v.Name+ " ' was not found in the translation context'" )
424425
425-
426- #if WORKAROUND_ FSHARP_ 2_ 0_ BUG
427- | :? KeyNotFoundExceptionwhen v.Name= " this" ->
428- let message =
429- " Encountered unxpected variable named 'this'. This might happen because" +
430- " quotations used in queries can’t contain references to let-bound values in classes unless the quotation literal occurs in an instance member." +
431- " If this is the case, workaround by replacing references to implicit fields with references to" +
432- " local variables, e.g. rewrite\r\n " +
433- " type Foo() =\r\n " +
434- " let x = 1\r\n " +
435- " let bar() = (methodhandleof (fun -> x))\r\n " +
436- " as:\r\n " +
437- " type Foo() =\r\n " +
438- " let x = 1\r\n " +
439- " let bar() = let x = x in (methodhandleof (fun -> x))\r\n " ;
440-
441- NotSupportedException( message) |> raise
442- #endif
443426| DerivedPatterns.AndAlso( x1, x2) -> Expression.AndAlso( ConvExprToLinqInContext env x1, ConvExprToLinqInContext env x2) |> asExpr
444427| DerivedPatterns.OrElse( x1, x2) -> Expression.OrElse( ConvExprToLinqInContext env x1, ConvExprToLinqInContext env x2) |> asExpr
445428| Patterns.Value( x, ty) -> Expression.Constant( x, ty) |> asExpr
@@ -659,8 +642,7 @@ module LeafExpressionConverter =
659642let argsP = ConvExprsToLinq env args
660643 Expression.Call( ConvObjArg env objOpt None, minfo, argsP) |> asExpr
661644
662- #if NO_ CURRIED_ FUNCTION_ OPTIMIZATIONS
663- #else
645+ #if ! NO_ CURRIED_ FUNCTION_ OPTIMIZATIONS
664646// f x1 x2 x3 x4 --> InvokeFast4
665647| Patterns.Application( Patterns.Application( Patterns.Application( Patterns.Application( f, arg1), arg2), arg3), arg4) ->
666648// TODO: amortize this computation based on f.Type
@@ -722,8 +704,7 @@ module LeafExpressionConverter =
722704let argsR = ConvExprsToLinq env args
723705 Expression.Call(( null : Expression), methInfo, argsR) |> asExpr
724706
725- #if NO_ PATTERN_ MATCHING_ IN_ INPUT_ LANGUAGE
726- #else
707+ #if ! NO_ PATTERN_ MATCHING_ IN_ INPUT_ LANGUAGE
727708| Patterns.UnionCaseTest( e, unionCaseInfo) ->
728709let methInfo = Reflection.FSharpValue.PreComputeUnionTagMemberInfo( unionCaseInfo.DeclaringType, showAll)
729710let obj = ConvExprToLinqInContext env e