False positive for error when using dynamic with operator overloading

Hi,

I came across this bug in Visual Studio a while ago and then forgot about it only to see it is still not fixed. R# seems to be highlighting code as an error under certain circumstances even though the code compiles and runs without problems. I have attached a snip of the problem as well as some code below that reproduces it. Disabling R# fixes this showing that it is the problem.

class Program {
     class Base {
          public static dynamic operator +(Base b1, Base b2){
               return new Child();
          }
     }
     class Child : Base {}

     static void Main(){
          var c1 = new Child();
          var c2 = new Child();

          c1 = c1 + c2; // ok
          c1 += c2 // false error
     }
}

John.



Attachment(s):
code.png

Please sign in to leave a comment.