File tree 1 file changed +20
-6
lines changed
1 file changed +20
-6
lines changed Original file line number Diff line number Diff line change @@ -8423,12 +8423,26 @@ namespace ProviderImplementation.ProvidedTypes
8423
8423
8424
8424
// convert TupleGet to the chain of PropertyGet calls (only for generated types)
8425
8425
| TupleGet(e, i) when isGenerated ->
8426
- let rec mkGet ty i (e: Expr) =
8427
- let pi, restOpt = Reflection.FSharpValue.PreComputeTuplePropertyInfo(ty, i)
8428
- let propGet = Expr.PropertyGetUnchecked(e, pi)
8429
- match restOpt with
8430
- | None -> propGet
8431
- | Some (restTy, restI) -> mkGet restTy restI propGet
8426
+ let rec mkGet (ty : Type) i (e: Expr) =
8427
+ if ty.IsValueType then
8428
+ let get index =
8429
+ let fields = ty.GetFields() |> Array.sortBy (fun fi -> fi.Name)
8430
+ if index >= fields.Length then
8431
+ invalidArg "index" (sprintf "The tuple index '%d' was out of range for tuple type %s" index ty.Name)
8432
+ fields.[index]
8433
+ let tupleEncField = 7
8434
+ let fget = Expr.FieldGetUnchecked(e, get i)
8435
+ if i < tupleEncField then
8436
+ fget
8437
+ else
8438
+ let etys = ty.GetGenericArguments()
8439
+ mkGet etys.[tupleEncField] (i - tupleEncField) fget
8440
+ else
8441
+ let pi, restOpt = Reflection.FSharpValue.PreComputeTuplePropertyInfo(ty, i)
8442
+ let propGet = Expr.PropertyGetUnchecked(e, pi)
8443
+ match restOpt with
8444
+ | None -> propGet
8445
+ | Some (restTy, restI) -> mkGet restTy restI propGet
8432
8446
simplifyExpr (mkGet e.Type i (simplifyExpr e))
8433
8447
#endif
8434
8448
You can’t perform that action at this time.
0 commit comments