[Mono-list] Possible mcs bug: CS0019 detected for comparable instances

Miguel de Icaza miguel@ximian.com
19 Oct 2003 16:11:33 -0400


Hello,

> I'm trying to port an application I'm developing at work. Over there we use
> Microsoft .Net SDK.
> When I tried to compile it in mono I got:
> 
> 	error CS0019: Operator != cannot be applied to operands of type `xxx' and 
> `yyy'

>From my reading of the ECMA spec, this is a bug in the Microsoft C#
compiler. 

Section 14.9.6 "Reference type equality operators" states that there
must be a standard implicit conversion from the type of either operand
to the type of the other operand.  

Miguel

> I've narrowed down the problem and the smallest program which reproduces the
> error is the following one:
> 
> using System;
> namespace Test {
> 	public class Test {
> 		public static void Main(string[] args) {
> 			BaseClass baseRef = new DerivedClass();
> 			ITest interfaceRef = (ITest)baseRef;
> 			Console.WriteLine("Is this wrong? {0}", (interfaceRef!=baseRef));
> 		}
> 	}
> 
> 	public interface ITest {}
> 
> 	public class BaseClass {}
> 
> 	public class DerivedClass: BaseClass, ITest {}
> }
>