Incorrect "Expression is always false" suggestion in 5.1.1707
The following code produce an incorrect "Expression is always false" suggestion in R# 5.1.1707.19 on the "if (obj == null)" line.
struct Test
{
public override bool Equals(object obj)
{
if (obj == null)
return false;
return base.Equals(obj);
}
}
This is incorrect, because even though the object itself is a struct there is nothing stopping "obj" from being null. Another symptom of the same problem is that this line:
new Test().Equals(null);
reports a "Possible null assignment to entity marked with 'NotNull' attribute" warning.
I think the meaning of the [NotNull] attribute has blurred a bit between "shouldn't be null" and "couldn't be null" here. If, as I understand, it means "shouldn't be null" then R# should not use it for the "expression is always true/false" warnings.
Please sign in to leave a comment.
Hello evgeny0,
This should be fixed in the latest nightly build of ReSharper 5.1. Thank you!
Andrey Serebryansky
Support Engineer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"
It still happens in build 1713.5.
Hello,
I've created a bug-report in our tracker: http://youtrack.jetbrains.net/issue/RSRP-183294.
Thank you!
Andrey Serebryansky
Support Engineer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"
Thank you, confirmed fixed in 5.1.1714.