https://bugzilla.novell.com/show_bug.cgi?id=415375
Summary: CS0019 erroneously reported for equality comparison
between object type value and generic type value with
"class" reference constraint
Product: Mono: Compilers
Version: 2.0
Platform: x86-64
OS/Version: openSUSE 10.3
Status: NEW
Severity: Normal
Priority: P5 - None
Component: C#
AssignedTo: [email protected]
ReportedBy: [EMAIL PROTECTED]
QAContact: [email protected]
Found By: ---
Given the following code:
public class Inner<T> where T : class {
public static void Compare(object obj, T value) {
if (obj != value) { }
}
}
Actual result:
error CS0019: Operator `!=' cannot be applied to operands of type `object' and
`T'
Expected result:
Compiles successfully
Supporting evidence:
csc.exe compiles with no error
(ECMA reference pulled from another bug)
ECMA 334 section 14.9.6 (Reference type equality operators)
"Otherwise, if either A or B is a type parameter that is not known to be a
reference type (ยง25.7), then no reference type equality operator is
applicable."
This appears to be applicable, and since T has the class constraint, it is
known to be a reference type.
Also, this doesn't even work which seems even stranger since both the arguments
are theoretically the same:
public class ThisClass {}
public class Inner<T> where T : ThisClass {
public static void Compare(ThisClass obj, T value) {
if (obj != value) { }
}
}
--
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.
_______________________________________________
mono-bugs maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-bugs