{
if (member.Kind == MemberKind.Operator) {
var dt = member.DeclaringType;
- switch (dt.BuiltinType) {
- case BuiltinTypeSpec.Type.String:
- case BuiltinTypeSpec.Type.Delegate:
- case BuiltinTypeSpec.Type.MulticastDelegate:
- // Some core types have user operators but they cannot be used as normal
- // user operators as they are predefined and therefore having different
- // rules (e.g. binary operators) by not setting the flag we hide them for
- // user conversions
- // TODO: Should I do this for all core types ?
- break;
- default:
- if (name == Operator.GetMetadataName (Operator.OpType.Implicit) || name == Operator.GetMetadataName (Operator.OpType.Explicit)) {
- state |= StateFlags.HasConversionOperator;
- } else {
- state |= StateFlags.HasUserOperator;
- }
- break;
+ //
+ // Some core types have user operators but they cannot be used like normal
+ // user operators as they are predefined and therefore having different
+ // rules (e.g. binary operators) by not setting the flag we hide them for
+ // user conversions
+ //
+ if (!BuiltinTypeSpec.IsPrimitiveType (dt)) {
+ switch (dt.BuiltinType) {
+ case BuiltinTypeSpec.Type.String:
+ case BuiltinTypeSpec.Type.Delegate:
+ case BuiltinTypeSpec.Type.MulticastDelegate:
+ break;
+ default:
+ if (name == Operator.GetMetadataName (Operator.OpType.Implicit) || name == Operator.GetMetadataName (Operator.OpType.Explicit)) {
+ state |= StateFlags.HasConversionOperator;
+ } else {
+ state |= StateFlags.HasUserOperator;
+ }
+
+ break;
+ }
}
}
--- /dev/null
+struct R
+{
+ public static bool operator < (R left, R right)
+ {
+ return true;
+ }
+
+ public static bool operator > (R left, R right)
+ {
+ return false;
+ }
+
+ public static implicit operator float(R r)
+ {
+ return 5;
+ }
+
+ public static implicit operator R(float f)
+ {
+ return new R ();
+ }
+}
+
+class C
+{
+ public static int Main ()
+ {
+ var r = new R ();
+ float f = 999f;
+
+ bool b = f < r;
+ if (!b)
+ return 1;
+
+ return 0;
+ }
+}
\ No newline at end of file
</method>
</type>
</test>
+ <test name="test-840.cs">
+ <type name="R">
+ <method name="Boolean op_LessThan(R, R)">
+ <size>2</size>
+ </method>
+ <method name="Boolean op_GreaterThan(R, R)">
+ <size>2</size>
+ </method>
+ <method name="Single op_Implicit(R)">
+ <size>6</size>
+ </method>
+ <method name="R op_Implicit(Single)">
+ <size>10</size>
+ </method>
+ </type>
+ <type name="C">
+ <method name="Int32 Main()">
+ <size>37</size>
+ </method>
+ <method name="Void .ctor()">
+ <size>7</size>
+ </method>
+ </type>
+ </test>
<test name="test-85.cs">
<type name="X">
<method name="Void .ctor()">