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

RSRP-297914: QF 'Cast qualifier' forgets to substitute type arguments

$
0
0
Reporter Vladimir Reshetnikov (nikov) Vladimir Reshetnikov (nikov)
Created Apr 27, 2012 8:16:13 AM
Updated Apr 27, 2012 8:16:13 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;

sealed class C<T> : IComparable<T>
{
    static void Main()
    {
        var c = new C<int>();
        var x = c.CompareTo(1); // Apply QF
    }

    int IComparable<T>.CompareTo(T other)
    {
        return 0;
    }
}


Actual:

using System;

sealed class C<T> : IComparable<T>
{
    static void Main()
    {
        var c = new C<int>();
        var x = ((IComparable<T>)c).CompareTo(1); // error CS0030: Cannot convert type 'C<int>' to 'System.IComparable<T>'
    }

    int IComparable<T>.CompareTo(T other)
    {
        return 0;
    }
}


Expected:

using System;

sealed class C<T> : IComparable<T>
{
    static void Main()
    {
        var c = new C<int>();
        var x = ((IComparable<int>)c).CompareTo(1); // OK
    }


    int IComparable<T>.CompareTo(T other)
    {
        return 0;
    }
}

Viewing all articles
Browse latest Browse all 106942

Trending Articles



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