Quantcast
Channel: YouTrackReSharper (RSRP) - Bug and Issue Tracker
Viewing all articles
Browse latest Browse all 106942

RSRP-288341: Do not show 'Expression is always true' in this context

$
0
0
Reporter Vladimir Reshetnikov (nikov) 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();
    }
}

Viewing all articles
Browse latest Browse all 106942

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>