@@ -2786,32 +2786,30 @@ and GenNewArray cenv cgbuf eenv (elems: Expr list, elemTy, m) sequel =
27862786 GenNewArraySimple cenv cgbuf eenv ( elems, elemTy, m) sequel
27872787
27882788and GenCoerce cenv cgbuf eenv ( e , tgty , m , srcty ) sequel =
2789- let g = cenv.g
2790- // Is this an upcast?
2791- if TypeRelations.TypeDefinitelySubsumesTypeNoCoercion 0 g cenv.amap m tgty srcty &&
2792- // Do an extra check - should not be needed
2793- TypeRelations.TypeFeasiblySubsumesType 0 g cenv.amap m tgty TypeRelations.NoCoerce srcty then
2794- begin
2795- if ( isInterfaceTy g tgty) then (
2796- GenExpr cenv cgbuf eenv SPSuppress e Continue
2797- let ilToTy = GenType cenv.amap m eenv.tyenv tgty
2798- // Section "III.1.8.1.3 Merging stack states" of ECMA-335 implies that no unboxing
2799- // is required, but we still push the coerced type on to the code gen buffer.
2800- CG.EmitInstrs cgbuf ( pop 1 ) ( Push [ ilToTy]) []
2801- GenSequel cenv eenv.cloc cgbuf sequel
2802- ) else (
2803- GenExpr cenv cgbuf eenv SPSuppress e sequel
2804- )
2805- end
2806- else
2807- GenExpr cenv cgbuf eenv SPSuppress e Continue
2808- if not ( isObjTy g srcty) then
2809- let ilFromTy = GenType cenv.amap m eenv.tyenv srcty
2810- CG.EmitInstrs cgbuf ( pop 1 ) ( Push [ g.ilg.typ_ Object]) [ I_ box ilFromTy ]
2811- if not ( isObjTy g tgty) then
2812- let ilToTy = GenType cenv.amap m eenv.tyenv tgty
2813- CG.EmitInstrs cgbuf ( pop 1 ) ( Push [ ilToTy]) [ I_ unbox_ any ilToTy ]
2814- GenSequel cenv eenv.cloc cgbuf sequel
2789+ let g = cenv.g
2790+ // Is this an upcast?
2791+ if TypeRelations.TypeDefinitelySubsumesTypeNoCoercion 0 g cenv.amap m tgty srcty &&
2792+ // Do an extra check - should not be needed
2793+ TypeRelations.TypeFeasiblySubsumesType 0 g cenv.amap m tgty TypeRelations.NoCoerce srcty
2794+ then
2795+ if isInterfaceTy g tgty then
2796+ GenExpr cenv cgbuf eenv SPSuppress e Continue
2797+ let ilToTy = GenType cenv.amap m eenv.tyenv tgty
2798+ // Section "III.1.8.1.3 Merging stack states" of ECMA-335 implies that no unboxing
2799+ // is required, but we still push the coerced type on to the code gen buffer.
2800+ CG.EmitInstrs cgbuf ( pop 1 ) ( Push [ ilToTy]) []
2801+ GenSequel cenv eenv.cloc cgbuf sequel
2802+ else
2803+ GenExpr cenv cgbuf eenv SPSuppress e sequel
2804+ else
2805+ GenExpr cenv cgbuf eenv SPSuppress e Continue
2806+ if not ( isObjTy g srcty) then
2807+ let ilFromTy = GenType cenv.amap m eenv.tyenv srcty
2808+ CG.EmitInstrs cgbuf ( pop 1 ) ( Push [ g.ilg.typ_ Object]) [ I_ box ilFromTy ]
2809+ if not ( isObjTy g tgty) then
2810+ let ilToTy = GenType cenv.amap m eenv.tyenv tgty
2811+ CG.EmitInstrs cgbuf ( pop 1 ) ( Push [ ilToTy]) [ I_ unbox_ any ilToTy ]
2812+ GenSequel cenv eenv.cloc cgbuf sequel
28152813
28162814and GenReraise cenv cgbuf eenv ( rtnty , m ) sequel =
28172815 let ilReturnTy = GenType cenv.amap m eenv.tyenv rtnty
0 commit comments