Below code compiles in VS2015.2, but after upgrade to VS2015.3 it fails with error CS0019: Operator '==' cannot be applied to operands of type 'Registration<Something>' and 'Something'.
  public class Class1
  {
      public Class1()
      {
          var a = new Registration<Something>();
          var x = a == Something.Bad; // this line fails in VS2015.3
      }
  }
  public struct Registration<T> where T:struct
  {
      public static implicit operator T?(Registration<T> registration)
      {
          return null;
      }
  }
  public enum Something
  {
      Good,
      Bad
  }
I can not find any notice about such a change in the changelog for update 3. Can someone tell me, why this happens? And which is the correct behavior?
EDIT: Combination of implicit conversion, equality operator and nullables... and enums. This only seems to fail when T is an enum.
Looks like a bug. We're tracking this as https://github.com/dotnet/roslyn/issues/13380
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With