Reporter | Vladimir Reshetnikov (nikov) |
---|---|
Created | Feb 16, 2012 4:21:26 AM |
Updated | Feb 17, 2012 6:19:22 PM |
Resolved | Feb 16, 2012 8:59:41 PM |
Priority | Normal |
Type | Bug |
Fix versions | Next |
State | Fixed |
Assignee | Evgeny Pasynkov (pasynkov) |
Subsystem | No subsystem |
Affected versions | No Affected versions |
Fixed in build | 6.5.1.4579 |
using System; class Program { static T Foo<T>(T x) { if(x is bool) { return (T) (object) true; } throw new InvalidOperationException(); } }
It is obvious that the expression is true and it cannot be further simplified.
If you apply QF suggested by ReSharper, then the code becomes not compilable:
using System; class Program { static T Foo<T>(T x) { if(x is bool) { return true; // error CS0029: Cannot implicitly convert type 'bool' to 'T' } throw new InvalidOperationException(); } }