Why does the following fail to infer R
:
static R Foo<R>(Func<Action<R>, R> call) { ... }
While pretty much the 'same', works:
static R Foo<R>(Func<Action, R> call) { ... }
Usage:
var i = Foo(ec => -1);
Ways the first sample 'must' be called to compile:
var i = Foo<int>(ec => -1);
-- or --
var i = Foo((Action<int> ec) => -1);
Thoughts: As can be seen in the second snippet, R
is already determined by the return type of the 'lambda'. Why can't the same apply to the first? Even with usage of ec
(which should be another compiler hint), it fails to infer.