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

RSRP-294462: Extract method created incorrect code

$
0
0
Reporter Vladimir Reshetnikov (nikov) Vladimir Reshetnikov (nikov)
Created Apr 14, 2012 2:41:01 AM
Updated Apr 16, 2012 9:11:26 PM
Priority Normal
Type Bug
Fix versions No Fix versions
State Submitted
Assignee Sergey Shkredov (serjic.shkredov)
Subsystem No subsystem
Affected versions No Affected versions
Fixed in build No Fixed in build
http://www.rsdn.ru/forum/jetbrains/4694501.1.aspx

private static bool Foo()
{
    bool result;

    // selection start
    if (Bar() == null)
        return false;
    else
        result = true;
    // selection end

    return result;
}

private static object Bar() { return null; }


After 'Extract method':


private static bool Foo()
{
    bool result;

    result = Result();
    if (result == null) // Expression is always false
        return false;

    return result;
}

private static bool Result()
{
    bool result;
    if (Bar() == null)
        return null; // error CS0037: Cannot convert null to 'bool' because it is a non-nullable value type
    else
        result = true;
    return result; // Expression is always true
}

private static object Bar() { return null; }

Viewing all articles
Browse latest Browse all 106942

Trending Articles



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