Priority
Major
Type
Bug 
State
Can't Reproduce 
Assignee
Eugene Pasynkov 
Subsystem
Code Analysis 
Affected versions
Fixed in
Fixed in build
Next build 
Build
337
  • Submitted by   Dan Händevik
    3 years ago (29 Jan 2007 13:57)
  • Updated by Dan Händevik
    2 years ago (20 Jun 2007 20:42)
  • Jira: RSRP-34947
    (history, comments)

RSRP-34947

"Type cast is redundant" warning on generic methods when it isn't

0
I have a generic method
void MyMethod<T>(T item) {
...
}

To call a generic method, I can either supply the types on the method signature like
MyMethod<FieldInfo>(x);

or if the parameters contains all type parameters this will allow us to skip the type definition like below
FieldInfo e = new FileInfo();
MyMethod(e);

If I on the other hand wants to pass null to the method I can write it as below
MyMethod<FileInfo>(null);

or
MyMethod(null as FileInfo);


but when I use the last version I get the "Type cast is redundant" warning from R#.

I can't use MyMethod(null) (as R# suggests) since this don't cover all type parameters...

Regards
/Dan

Issue was closed
Comments (0)
 
History (0)
 
Links
 
Issue has no comments