@@ -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 ccallInfowith
538- | Some_ -> true
539- | None-> false )
533+ let ccallInfo = ComputeConstrainedCallInfo g amap m( objArgs, minfo)
534+
540535let wrap , objArgs =
541536match objArgswith
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
543542let objArgTy = tyOfExpr g objArgExpr
544- let wrap , objArgExpr' = mkExprAddrOfExpr g mustTakeAddress( Option.isSome ccallInfo ) isMutable objArgExpr None m
543+ let wrap , objArgExpr' = mkExprAddrOfExpr g mustTakeAddresshasCallInfo isMutable objArgExpr None m
545544
546545// Extension members and calls to class constraints may need a coercion for their object argument
547546let objArgExpr ' =
548- if Option.isNone ccallInfo && // minfo.IsExtensionMember && minfo.IsStruct &&
547+ if not hasCallInfo && // minfo.IsExtensionMember && minfo.IsStruct &&
549548not ( TypeDefinitelySubsumesTypeNoCoercion0 g amap m minfo.ApparentEnclosingType objArgTy) then
550549 mkCoerceExpr( objArgExpr', minfo.ApparentEnclosingType, m, objArgTy)
551550else
@@ -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
558557let 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
579578let ilMethRef = minfo.ILMethodRef
580579let newobj = ctor&& ( match valUseFlagswith NormalValUse-> true | _ -> false )
581580let exprTy = if ctorthen minfo.ApparentEnclosingTypeelse 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.Voidthen [] else [ exprTy]
583582let 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 ->
605604match arity, argswith
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| _ ->
674671match amap.g.knownFSharpCoreModules.TryGetValue( declaringEntity.LogicalName) with
675672| true , modRef->
676- match modRef.ModuleOrNamespaceType.AllValsByLogicalName|> Seq.tryPick( fun ( KeyValue ( _ , v )) -> if v.CompiledName= methodNamethen Some velse 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= methodNamethen Some( mkNestedValRef modRef v) else None)
679675| _ -> None
680676else
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-
697692let 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
701696let valUseFlags =
702- if ( direct&& ( match valUseFlagswith NormalValUse-> true | _ -> false ) )then
697+ if direct&& ( match valUseFlagswith NormalValUse-> true | _ -> false ) then
703698 VSlotDirectCall
704699else
705700match ccallInfowith
@@ -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
723718if isArrayTy g enclTythen
724719let tpe = TypeProviderError( FSComp.SR.tcRuntimeSuppliedMethodCannotBeUsedInUserCode( minfo.DisplayName), providedMeth.TypeProviderDesignation, m)
725- error( tpe)
720+ error tpe
726721let valu = isStructTy g enclTy
727722let isCtor = minfo.IsConstructor
728723if minfo.IsClassConstructorthen
@@ -747,7 +742,7 @@ let BuildMethodCall tcVal g amap isMutable m isProp minfo valUseFlags minst objA
747742elif isFunTy g enclTythen [ domainOfFunTy g enclTy; rangeOfFunTy g enclTy] // provided expressions can call Invoke
748743else minfo.DeclaringTypeInst
749744let 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]
751746let noTailCall = false
752747let 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))
11921187let 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