Project
ReSharper
Priority
Critical
Type
Bug
Fix versions
5.0
State
Fixed
Assignee
Olga Lobacheva
Subsystem
PSI
Affected versions
No Affected versions
Fixed in build
5.0.1625.39  
  • Created by   Yuri Astrakhan
    2 years ago (19 Feb 2009 21:42)
  • Updated by   Olga Lobacheva
    18 months ago (14 Jul 2010 18:54)
  • Jira: RSRP-96237
    (history, comments)
 
RSRP-96237 Needed cast is marked as unneeded and removed
0
Issue is visible to: All Users
  The issue is visible to the selected user group only
While discussing http://www.jetbrains.net/jira/browse/RSRP-96119 I found this bug:
The cast must be there to call the Foo.Method instead of FooExtension.Method

using System;

class MainClass
{
    public static void Run()
    {
        var f = new Foo2();
        f.Method(1);
        ((Foo)f).Method(1);
    }
}

static class FooExtensions
{
    public static void Method(this Foo foo, int param1)
    {
        Console.WriteLine("FooExtensions.Method");
    }
}

class Foo
{
    public void Method(long param1) { Console.WriteLine("Foo.Method"); }
}

class Foo1 : Foo
{
    public new Action Method = () => Console.WriteLine("Foo1.Method");
}

class Foo2 : Foo1
{
    new public void Method() { Console.WriteLine("Foo2.Method"); }
}
Comments (1)
 
History
 
Linked Issues (?)
 
TeamCity Changes (1)
 
Vladimir Reshetnikov
  Vladimir Reshetnikov
21 Feb 2009 19:41
2 years ago
Probably the same problem as in RSRP-96221: hiding works wrong.
In long hierarchies, hidden members still can hide other members.