Redundand casts generated

It seems very weird, but after upgrading to build 160 I've noticed that sometimes
redundand casts apear in the code. I mean they appear by themselves. I'm
pretty sure I didn't write (Font) in the following code:

e.Graphics.DrawString("Blah!", (Font)new Font("Verdana", 8), SystemBrushes.ControlText,
0, 0);

Resharper highlights (Font) as redundand cast, but I have no idea where it
came from! I didn't yet found the sequence that leads to this problem, but
it looks very weird. Probably, knowing what has been changed in this area,
you can find the bug yourself.

Sincerely,
Ilya Ryzhenkov



4 comments
Comment actions Permalink

ehm, pardon my stupidity, but why is it not redundand you think?

0
Comment actions Permalink

ehm..I discovered stupidity...I didn't read your post well..doh

0
Comment actions Permalink

We have an idea what the reason can be but cannot reproduce this but. It
would be very helpful if you will find some steps to reproduce it.

Valentin Kipiatkov
Chief Scientist, Vice President of Product Development
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

It seems very weird, but after upgrading to build 160 I've noticed
that sometimes redundand casts apear in the code. I mean they appear
by themselves. I'm pretty sure I didn't write (Font) in the following
code:

e.Graphics.DrawString("Blah!", (Font)new Font("Verdana", 8),
SystemBrushes.ControlText, 0, 0);

Resharper highlights (Font) as redundand cast, but I have no idea
where it came from! I didn't yet found the sequence that leads to this
problem, but it looks very weird. Probably, knowing what has been
changed in this area, you can find the bug yourself.

Sincerely,
Ilya Ryzhenkov




0
Comment actions Permalink

Hello Valentin,

See #5944 and comment to it. It happens when I move types to files. Sometimes
it gives exception, sometimes just generates redundant casts, sometimes works
just fine. Note, that in the provided example extracting "new Font(...)"
expression to variable fixes both problems - moving to file works fine and
generates no redundant casts. Probably, there is a problem with 'new' expression.

VK> We have an idea what the reason can be but cannot reproduce this
VK> but. It would be very helpful if you will find some steps to
VK> reproduce it.
VK>
VK> Valentin Kipiatkov
VK> Chief Scientist, Vice President of Product Development
VK> JetBrains, Inc
VK> http://www.jetbrains.com
VK> "Develop with pleasure!"
>> It seems very weird, but after upgrading to build 160 I've noticed
>> that sometimes redundand casts apear in the code. I mean they appear
>> by themselves. I'm pretty sure I didn't write (Font) in the following
>> code:
>>
>> e.Graphics.DrawString("Blah!", (Font)new Font("Verdana", 8),
>> SystemBrushes.ControlText, 0, 0);
>>
>> Resharper highlights (Font) as redundand cast, but I have no idea
>> where it came from! I didn't yet found the sequence that leads to
>> this problem, but it looks very weird. Probably, knowing what has
>> been changed in this area, you can find the bug yourself.
>>
>> Sincerely,
>> Ilya Ryzhenkov
Sincerely,
Ilya Ryzhenkov



0

Please sign in to leave a comment.