private static OptionalTest <T> TryToGetResult <T>(ResultOrErrorTest <T> value) { // The "handleResult" lambda gets lifted into an anonymous method but it shouldn't be allowed to because // it relies on the generic type param T because there is an implicit cast from T on to OptionalTest<T> return(value.Match( handleError: error => OptionalTest <T> .Missing, handleResult: result => result )); }
public static void TestLambdaLifting() { var myValue = new ResultOrErrorTest <string>("WOOOO"); try { var result = Bridge2610.TryToGetResult(myValue); Assert.AreEqual("WOOOO", result.Value); } catch (Exception e) { Assert.Fail(e.Message); } }