Example #1
0
 /**
  * Takes a guarded invocation, and ensures its method and guard conform to the type of the call
  * descriptor, using all type conversions allowed by the linker's services. This method is used by
  * Nashorn's linkers as a last step before returning guarded invocations. Most of the code used to
  * produce the guarded invocations does not make an effort to coordinate types of the methods, and
  * so a final type adjustment before a guarded invocation is returned to the aggregating linker is
  * the responsibility of the linkers themselves.
  *
  * @param inv the guarded invocation that needs to be type-converted. Can be null.
  * @param linkerServices the linker services object providing the type conversions.
  * @param desc the call site descriptor to whose method type the invocation needs to conform.
  * @return the type-converted guarded invocation. If input is null, null is returned. If the input
  *     invocation already conforms to the requested type, it is returned unchanged.
  */
 static GuardedInvocation asTypeSafeReturn(
     final GuardedInvocation inv,
     final LinkerServices linkerServices,
     final CallSiteDescriptor desc) {
   return inv == null ? null : inv.asTypeSafeReturn(linkerServices, desc.getMethodType());
 }