@@ -530,22 +530,21 @@ let ComputeConstrainedCallInfo g amap m (objArgs,minfo:MethInfo) =
530530/// Adjust the 'this' pointer before making a call
531531/// Take the address of a struct, and coerce to an interface/base/constraint type if necessary
532532let TakeObjAddrForMethodCall g amap ( minfo : MethInfo ) isMutable m objArgs f =
533- let ccallInfo = ComputeConstrainedCallInfo g amap m ( objArgs, minfo)
534- let mustTakeAddress =
535- ( minfo.IsStruct && not minfo.IsExtensionMember) // don't take the address of a struct when passing to an extension member
536- ||
537- ( match ccallInfo with
538- | Some _ -> true
539- | None -> false )
533+ let ccallInfo = ComputeConstrainedCallInfo g amap m ( objArgs, minfo)
534+
540535 let wrap , objArgs =
541536 match objArgs with
542- | [ objArgExpr] ->
537+ | [ objArgExpr] ->
538+ let hasCallInfo = ccallInfo.IsSome
539+ let mustTakeAddress =
540+ ( minfo.IsStruct && not minfo.IsExtensionMember) // don't take the address of a struct when passing to an extension member
541+ || hasCallInfo
543542 let objArgTy = tyOfExpr g objArgExpr
544- let wrap , objArgExpr' = mkExprAddrOfExpr g mustTakeAddress ( Option.isSome ccallInfo ) isMutable objArgExpr None m
543+ let wrap , objArgExpr' = mkExprAddrOfExpr g mustTakeAddress hasCallInfo isMutable objArgExpr None m
545544
546545 // Extension members and calls to class constraints may need a coercion for their object argument
547546 let objArgExpr ' =
548- if Option.isNone ccallInfo && // minfo.IsExtensionMember && minfo.IsStruct &&
547+ if not hasCallInfo && // minfo.IsExtensionMember && minfo.IsStruct &&
549548 not ( TypeDefinitelySubsumesTypeNoCoercion 0 g amap m minfo.ApparentEnclosingType objArgTy) then
550549 mkCoerceExpr( objArgExpr', minfo.ApparentEnclosingType, m, objArgTy)
551550 else
@@ -554,7 +553,7 @@ let TakeObjAddrForMethodCall g amap (minfo:MethInfo) isMutable m objArgs f =
554553 wrap,[ objArgExpr']
555554
556555 | _ ->
557- ( fun x -> x ) , objArgs
556+ id , objArgs
558557 let e , ety = f ccallInfo objArgs
559558 wrap e, ety
560559
@@ -579,7 +578,7 @@ let BuildILMethInfoCall g amap m isProp (minfo:ILMethInfo) valUseFlags minst dir
579578 let ilMethRef = minfo.ILMethodRef
580579 let newobj = ctor && ( match valUseFlags with NormalValUse -> true | _ -> false )
581580 let exprTy = if ctor then minfo.ApparentEnclosingType else minfo.GetFSharpReturnTy( amap, m, minst)
582- let retTy = ( if not ctor && ( ilMethRef.ReturnType = ILType.Void) then [] else [ exprTy])
581+ let retTy = if not ctor && ilMethRef.ReturnType = ILType.Void then [] else [ exprTy]
583582 let isDllImport = minfo.IsDllImport g
584583 Expr.Op( TOp.ILCall( useCallvirt, isProtected, valu, newobj, valUseFlags, isProp, isDllImport, ilMethRef, minfo.DeclaringTypeInst, minst, retTy),[], args, m),
585584 exprTy
@@ -604,9 +603,7 @@ let BuildFSharpMethodApp g m (vref: ValRef) vexp vexprty (args: Exprs) =
604603 (( args, vexprty), arities) ||> List.mapFold ( fun ( args , fty ) arity ->
605604 match arity, args with
606605 | ( 0 | 1 ),[] when typeEquiv g ( domainOfFunTy g fty) g.unit_ ty -> mkUnit g m, ( args, rangeOfFunTy g fty)
607- | 0 ,( arg:: argst) ->
608-
609-
606+ | 0 ,( arg:: argst) ->
610607 warning( InternalError( sprintf " Unexpected zero arity, args = %s " ( Layout.showL ( Layout.sepListL ( Layout.rightL ( Layout.TaggedTextOps.tagText " ;" )) ( List.map exprL args))), m));
611608 arg, ( argst, rangeOfFunTy g fty)
612609 | 1 ,( arg :: argst) -> arg, ( argst, rangeOfFunTy g fty)
@@ -673,9 +670,8 @@ let TryImportProvidedMethodBaseAsLibraryIntrinsic (amap:Import.ImportMap, m:rang
673670 | _ ->
674671 match amap.g.knownFSharpCoreModules.TryGetValue( declaringEntity.LogicalName) with
675672 | true , modRef ->
676- match modRef.ModuleOrNamespaceType.AllValsByLogicalName |> Seq.tryPick ( fun ( KeyValue ( _ , v )) -> if v.CompiledName = methodName then Some v else None) with
677- | Some v -> Some ( mkNestedValRef modRef v)
678- | None -> None
673+ modRef.ModuleOrNamespaceType.AllValsByLogicalName
674+ |> Seq.tryPick ( fun ( KeyValue ( _ , v )) -> if v.CompiledName = methodName then Some ( mkNestedValRef modRef v) else None)
679675 | _ -> None
680676 else
681677 None
@@ -693,13 +689,12 @@ let TryImportProvidedMethodBaseAsLibraryIntrinsic (amap:Import.ImportMap, m:rang
693689// objArgs: the 'this' argument, if any
694690// args: the arguments, if any
695691let BuildMethodCall tcVal g amap isMutable m isProp minfo valUseFlags minst objArgs args =
696-
697692 let direct = IsBaseCall objArgs
698693
699694 TakeObjAddrForMethodCall g amap minfo isMutable m objArgs ( fun ccallInfo objArgs ->
700- let allArgs = ( objArgs @ args)
695+ let allArgs = objArgs @ args
701696 let valUseFlags =
702- if ( direct && ( match valUseFlags with NormalValUse -> true | _ -> false ) ) then
697+ if direct && ( match valUseFlags with NormalValUse -> true | _ -> false ) then
703698 VSlotDirectCall
704699 else
705700 match ccallInfo with
@@ -722,7 +717,7 @@ let BuildMethodCall tcVal g amap isMutable m isProp minfo valUseFlags minst objA
722717 // these calls are provided by the runtime and should not be called from the user code
723718 if isArrayTy g enclTy then
724719 let tpe = TypeProviderError( FSComp.SR.tcRuntimeSuppliedMethodCannotBeUsedInUserCode( minfo.DisplayName), providedMeth.TypeProviderDesignation, m)
725- error ( tpe)
720+ error tpe
726721 let valu = isStructTy g enclTy
727722 let isCtor = minfo.IsConstructor
728723 if minfo.IsClassConstructor then
@@ -747,7 +742,7 @@ let BuildMethodCall tcVal g amap isMutable m isProp minfo valUseFlags minst objA
747742 elif isFunTy g enclTy then [ domainOfFunTy g enclTy; rangeOfFunTy g enclTy ] // provided expressions can call Invoke
748743 else minfo.DeclaringTypeInst
749744 let actualMethInst = minst
750- let retTy = ( if not isCtor && ( ilMethRef.ReturnType = ILType.Void) then [] else [ exprTy])
745+ let retTy = if not isCtor && ( ilMethRef.ReturnType = ILType.Void) then [] else [ exprTy]
751746 let noTailCall = false
752747 let expr = Expr.Op( TOp.ILCall( useCallvirt, isProtected, valu, isNewObj, valUseFlags, isProp, noTailCall, ilMethRef, actualTypeInst, actualMethInst, retTy),[], allArgs, m)
753748 expr, exprTy
@@ -1191,7 +1186,7 @@ module ProvidedMethodCalls =
11911186 |> Array.map ( fun pty -> eraseSystemType ( amap, m, pty))
11921187 let paramVars =
11931188 erasedParamTys
1194- |> Array.mapi ( fun i erasedParamTy -> erasedParamTy.PApply(( fun ty -> ProvidedVar.Fresh( " arg" + i.ToString(), ty)), m))
1189+ |> Array.mapi ( fun i erasedParamTy -> erasedParamTy.PApply(( fun ty -> ProvidedVar.Fresh( " arg" + i.ToString(), ty)), m))
11951190
11961191
11971192 // encode "this" as the first ParameterExpression, if applicable
0 commit comments