[233] Mixup of local variables and types when using static members
Hi,
Resharper produces wrong error messages with the following code :
public class Singleton
{
private static Singleton singleton= new Singleton();
private Singleton()
{
}
public static Singleton Instance
{
get
{
return Singleton.singleton;
}
}
}
public class Client
{
public void Foo()
{
Singleton Singleton= Singleton.Instance; // Resharper reports errors, because local variable and type are mixed up
}
public void Foo2()
{
Singleton Singleton2= Singleton.Instance; // ok
}
}
Regards,
Uwe
Please sign in to leave a comment.
Hi Uwe,
Why shouldn't it report errors in the situation you describe? I expect it would.
Thanks,
Craig
Hi Craig,
just because it is not an error. The compiler can determine from the context whether 'Singleton' is the local variable or the type.
Regards,
Uwe
Hi Uwe,
I added a tracker request for that:
http://www.intellij.net/tracker/resharper/viewSCR?publicId=22363
It will be great if next time you do this yourself. The problem will be
easier to track for both you and me.
Friendly,
Dmitry
Uwe Hammermeister wrote:
--
Dmitry Lomov
Senior Software Developer
JetBrains Inc.
http://www.jetbrains.com
"Develop With Pleasure!"