Reporter | Vladimir Reshetnikov (nikov) |
---|---|
Created | Feb 16, 2012 4:21:26 AM |
Updated | Feb 16, 2012 4:21:26 AM |
Priority | Normal |
Type | Bug |
Fix versions | No Fix versions |
State | Submitted |
Assignee | Unassigned |
Subsystem | No subsystem |
Affected versions | No Affected versions |
Fixed in build | No Fixed in build |
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(); } }