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

RSRP-287687: Extract method creates too many constraints

$
0
0
Reporter Vladimir Reshetnikov (nikov) Vladimir Reshetnikov (nikov)
Created Jan 10, 2012 10:51:02 PM
Updated Jan 10, 2012 11:06:50 PM
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.Collections.Generic;

class A
{
    static void Foo<T, S, U>(T x)
        where T : IList<S>
        where S : IList<U>
    {
        var y = x.Count; // Extract method from x.Count
    }
}


Actual:

using System.Collections.Generic;

class A
{
    static void Foo<T, S, U>(T x)
        where T : IList<S>
        where S : IList<U>
    {
        var y = Count<T, S, U>(x);
    }

    private static int Count<T, S, U>(T x)
        where T : IList<S>
        where S : IList<U>
        where T : IList<S>
        where S : IList<U>
        where T : IList<S>
        where S : IList<U> // error CS0409: A constraint clause has already been specified for type parameter 'T'. All of the constraints for a type parameter must be specified in a single where clause.
    {
        return x.Count;
    }
}


Expected:


using System.Collections.Generic;

class A
{
    static void Foo<T, S, U>(T x)
        where T : IList<S>
        where S : IList<U>
    {
        var y = Count<T, S>(x);
    }

    private static int Count<T, S>(T x)
        where T : IList<S>
    {
        return x.Count;
    }
}

Viewing all articles
Browse latest Browse all 106942

Trending Articles