@@ -414,7 +414,8 @@ and private ConvExprCore cenv (env : QuotationTranslationEnv) (expr: Expr) : QP.
414414let mkR = ConvUnionCaseRef cenv ucref m
415415let tyargsR = ConvTypes cenv env m tyargs
416416let argsR = ConvExprs cenv env args
417- QP.mkSum( mkR, tyargsR, argsR)
417+ QP.mkUnion( mkR, tyargsR, argsR)
418+
418419
419420| TOp.Tuple tupInfo, tyargs,_ ->
420421let tyR = ConvType cenv env m( mkAnyTupledTy cenv.g tupInfo tyargs)
@@ -428,10 +429,7 @@ and private ConvExprCore cenv (env : QuotationTranslationEnv) (expr: Expr) : QP.
428429 QP.mkRecdMk( rgtypR, tyargsR, argsR)
429430
430431| TOp.UnionCaseFieldGet( ucref, n), tyargs,[ e] ->
431- let tyargsR = ConvTypes cenv env m tyargs
432- let tcR , s = ConvUnionCaseRef cenv ucref m
433- let projR = ( tcR, s, n)
434- QP.mkSumFieldGet( projR, tyargsR, ConvExpr cenv env e)
432+ ConvUnionFieldGet cenv env m ucref n tyargs e
435433
436434| TOp.ValFieldGetAddr(_ rfref),_ tyargs,_ ->
437435 wfail( Error( FSComp.SR.crefQuotationsCantContainAddressOf(), m))
@@ -443,11 +441,12 @@ and private ConvExprCore cenv (env : QuotationTranslationEnv) (expr: Expr) : QP.
443441 wfail( Error( FSComp.SR.crefQuotationsCantContainStaticFieldRef(), m))
444442
445443| TOp.ValFieldGet( rfref), tyargs, args->
446- ConvRFieldGet cenv env m rfref tyargs args
444+ ConvClassOrRecdFieldGet cenv env m rfref tyargs args
447445
448- | TOp.TupleFieldGet( tupInfo, n), tyargs,[ e] when not ( evalTupInfoIsStruct tupInfo) ->
449- let tyR = ConvType cenv env m( mkRefTupledTy cenv.g tyargs)
450- QP.mkTupleGet( tyR, n, ConvExpr cenv env e)
446+ | TOp.TupleFieldGet( tupInfo, n), tyargs,[ e] ->
447+ let eR = ConvLValueExpr cenv env e
448+ let tyR = ConvType cenv env m( mkAnyTupledTy cenv.g tupInfo tyargs)
449+ QP.mkTupleGet( tyR, n, eR)
451450
452451| TOp.ILAsm(([ I_ ldfld(_,_, fspec) ]
453452| [ I_ ldfld(_,_, fspec); AI_ nop]
@@ -606,10 +605,17 @@ and ConvLdfld cenv env m (fspec: ILFieldSpec) enclTypeArgs args =
606605let argsR = ConvLValueArgs cenv env args
607606 QP.mkFieldGet( ( parentTyconR, fspec.Name), tyargsR, argsR)
608607
609- and ConvRFieldGet cenv env m rfref tyargs args =
610- EmitDebugInfoIfNecessary cenv env m( ConvRFieldGetCore cenv env m rfref tyargs args)
608+ and ConvUnionFieldGet cenv env m ucref n tyargs e =
609+ let tyargsR = ConvTypes cenv env m tyargs
610+ let tcR , s = ConvUnionCaseRef cenv ucref m
611+ let projR = ( tcR, s, n)
612+ let eR = ConvLValueExpr cenv env e
613+ QP.mkUnionFieldGet( projR, tyargsR, eR)
614+
615+ and ConvClassOrRecdFieldGet cenv env m rfref tyargs args =
616+ EmitDebugInfoIfNecessary cenv env m( ConvClassOrRecdFieldGetCore cenv env m rfref tyargs args)
611617
612- and private ConvRFieldGetCore cenv env m rfref tyargs args =
618+ and private ConvClassOrRecdFieldGetCore cenv env m rfref tyargs args =
613619let tyargsR = ConvTypes cenv env m tyargs
614620let argsR = ConvLValueArgs cenv env args
615621let (( parentTyconR , fldOrPropName ) as projR ) = ConvRecdFieldRef cenv rfref m
@@ -665,7 +671,8 @@ and ConvLValueExprCore cenv env expr =
665671| Expr.Op( op, tyargs, args, m) ->
666672match op, args, tyargswith
667673| TOp.LValueOp( LGetAddr, vref),_,_ -> ConvValReffalse cenv env m vref[]
668- | TOp.ValFieldGetAddr( rfref),_,_ -> ConvRFieldGet cenv env m rfref tyargs args
674+ | TOp.ValFieldGetAddr( rfref),_,_ -> ConvClassOrRecdFieldGet cenv env m rfref tyargs args
675+ | TOp.UnionCaseFieldGetAddr( ucref, n),[ e],_ -> ConvUnionFieldGet cenv env m ucref n tyargs e
669676| TOp.ILAsm([ I_ ldflda( fspec) ],_ rtys),_,_ -> ConvLdfld cenv env m fspec tyargs args
670677| TOp.ILAsm([ I_ ldsflda( fspec) ],_ rtys),_,_ -> ConvLdfld cenv env m fspec tyargs args
671678| TOp.ILAsm(([ I_ ldelema(_ ro,_ isNativePtr, shape,_ tyarg) ] ),_), ( arr:: idxs), [ elemty] ->
@@ -846,26 +853,32 @@ and ConvDecisionTree cenv env tgs typR x =
846853match dfltOptwith
847854| Some d-> ConvDecisionTree cenv env tgs typR d
848855| None-> wfail( Error( FSComp.SR.crefQuotationsCantContainThisPatternMatch(), m))
856+
849857let converted =
850858( csl, acc) ||> List.foldBack( fun ( TCase ( discrim , dtree )) acc ->
859+
851860match discrimwith
852861| DecisionTreeTest.UnionCase( ucref, tyargs) ->
853- let e1R = ConvExpr cenv env e1
862+ let e1R = ConvLValueExpr cenv env e1
854863let ucR = ConvUnionCaseRef cenv ucref m
855864let tyargsR = ConvTypes cenv env m tyargs
856- QP.mkCond( QP.mkSumTagTest( ucR, tyargsR, e1R), ConvDecisionTree cenv env tgs typR dtree, acc)
865+ QP.mkCond( QP.mkUnionCaseTagTest( ucR, tyargsR, e1R), ConvDecisionTree cenv env tgs typR dtree, acc)
866+
857867| DecisionTreeTest.Const( Const.Booltrue ) ->
858868let e1R = ConvExpr cenv env e1
859869 QP.mkCond( e1R, ConvDecisionTree cenv env tgs typR dtree, acc)
870+
860871| DecisionTreeTest.Const( Const.Boolfalse ) ->
861872let e1R = ConvExpr cenv env e1
862873// Note, reverse the branches
863874 QP.mkCond( e1R, acc, ConvDecisionTree cenv env tgs typR dtree)
875+
864876| DecisionTreeTest.Const c->
865877let ty = tyOfExpr cenv.g e1
866878let eq = mkCallEqualsOperator cenv.g m ty e1( Expr.Const( c, m, ty))
867879let eqR = ConvExpr cenv env eq
868880 QP.mkCond( eqR, ConvDecisionTree cenv env tgs typR dtree, acc)
881+
869882| DecisionTreeTest.IsNull->
870883// Decompile cached isinst tests
871884match e1with
@@ -880,13 +893,17 @@ and ConvDecisionTree cenv env tgs typR x =
880893let eq = mkCallEqualsOperator cenv.g m ty e1( Expr.Const( Const.Zero, m, ty))
881894let eqR = ConvExpr cenv env eq
882895 QP.mkCond( eqR, ConvDecisionTree cenv env tgs typR dtree, acc)
896+
883897| DecisionTreeTest.IsInst(_ srcty, tgty) ->
884898let e1R = ConvExpr cenv env e1
885899 QP.mkCond( QP.mkTypeTest( ConvType cenv env m tgty, e1R), ConvDecisionTree cenv env tgs typR dtree, acc)
900+
886901| DecisionTreeTest.ActivePatternCase_ -> wfail( InternalError( " DecisionTreeTest.ActivePatternCase test in quoted expression" , m))
902+
887903| DecisionTreeTest.ArrayLength_ -> wfail( Error( FSComp.SR.crefQuotationsCantContainArrayPatternMatching(), m))
888904)
889905 EmitDebugInfoIfNecessary cenv env m converted
906+
890907| TDSuccess( args, n) ->
891908let ( TTarget ( vars , rhs , _ )) = tgs.[ n]
892909// TAST stores pattern bindings in reverse order for some reason