@@ -1022,9 +1022,8 @@ FCIMPL5(FC_BOOL_RET, COMDelegate::BindToMethodInfo, Object* refThisUNSAFE, Objec
10221022FCIMPLEND
10231023
10241024// This method is called (in the late bound case only) once a target method has been decided on. All the consistency checks
1025- // (signature matching etc.) have been done at this point and the only major reason we could fail now is on security grounds
1026- // (someone trying to create a delegate over a method that's not visible to them for instance). This method will initialize the
1027- // delegate (wrapping it in a wrapper delegate if necessary). Upon return the delegate should be ready for invocation.
1025+ // (signature matching etc.) have been done at this point, this method will simply initialize the delegate, with any required
1026+ // wrapping. The delegate returned will be ready for invocation immediately.
10281027void COMDelegate::BindToMethod (DELEGATEREF *pRefThis,
10291028 OBJECTREF *pRefFirstArg,
10301029 MethodDesc *pTargetMethod,
@@ -1043,19 +1042,16 @@ void COMDelegate::BindToMethod(DELEGATEREF *pRefThis,
10431042 }
10441043 CONTRACTL_END;
10451044
1046- // We might have to wrap the delegate in a wrapper delegate depending on the the target method. The following local
1047- // keeps track of the real (i.e. non-wrapper ) delegate whether or not this is required .
1045+ // The delegate may be put into a wrapper delegate if our target method requires it. This local
1046+ // will always hold the real (un-wrapped ) delegate.
10481047 DELEGATEREF refRealDelegate = NULL ;
10491048 GCPROTECT_BEGIN (refRealDelegate);
10501049
1051- // If we didn't wrap the real delegate in a wrapper delegate then the real delegate is the one passed in.
1052- if (refRealDelegate == NULL )
1053- {
1054- if (NeedsWrapperDelegate (pTargetMethod))
1055- refRealDelegate = CreateWrapperDelegate (*pRefThis, pTargetMethod);
1056- else
1057- refRealDelegate = *pRefThis;
1058- }
1050+ // If needed, convert the delegate into a wrapper and get the real delegate within that.
1051+ if (NeedsWrapperDelegate (pTargetMethod))
1052+ refRealDelegate = CreateWrapperDelegate (*pRefThis, pTargetMethod);
1053+ else
1054+ refRealDelegate = *pRefThis;
10591055
10601056 pTargetMethod->EnsureActive ();
10611057
0 commit comments