Member predicate DelegateDataFlow::DelegateFlowSink::getARuntimeTarget

Gets an actual run-time target of this delegate call in the given call context, if any. The call context records the last call required to resolve the target, if any. Example:

public int M(Func<string, int> f, string x) {
  return f(x);
}

void M2() {
  M(x => x.Length, y);

  M(_ => 42, z);

  Func<int, bool> isZero = x => x == 0;
  isZero(10);
}
  • The call on line 2 can be resolved to either x => x.Length (line 6) or _ => 42 (line 8) in the call contexts from lines 7 and 8, respectively.
  • The call on line 11 can be resolved to x => x == 0 (line 10) in an empty call context (the call is locally resolvable).

Note that only the last call required is taken into account, hence if M above is redefined as follows:

public int M(Func<string, int> f, string x) {
  return M2(f, x);
}

public int M2(Func<string, int> f, string x) {
  return f(x);
}

void M2() {
  M(x => x.Length, y);

  M(_ => 42, z);

  Func<int, bool> isZero = x => x == 0;
  isZero(10);
}

then the call context from line 2 is the call context for all possible delegates resolved on line 6.

Callable getARuntimeTarget(CallContext context)