RedundantCastIssue marks casts used for overload resolution as redundant. #118

Open
opened 2012-09-24 15:22:00 -05:00 by riviti · 0 comments
riviti commented 2012-09-24 15:22:00 -05:00 (Migrated from github.com)

The following test case shows the problem. The constructor variant causes a compilation error (CS0516) if the cast is removed. Second cast just shouldn't be shown since it is most likely an intentional cast in order to call F(object).

class TestClass
{
    public TestClass (object o)
    {
    }

    public TestClass (TestClass tc) : this(/*this cast*/(object)tc)
    {
    }

    void F (TestClass tc)
    {
        F (/*and this*/(object)tc);
    }

    void F (object tc)
    {
    }
}
The following test case shows the problem. The constructor variant causes a compilation error (CS0516) if the cast is removed. Second cast just shouldn't be shown since it is most likely an intentional cast in order to call F(object). ``` class TestClass { public TestClass (object o) { } public TestClass (TestClass tc) : this(/*this cast*/(object)tc) { } void F (TestClass tc) { F (/*and this*/(object)tc); } void F (object tc) { } } ```
This discussion has been locked. Commenting is limited to contributors.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-icsharpcode/NRefactory#118
No description provided.