}
}
- static CSharp.Operator.OpType ConvertBinaryToUserOperator (Operator op)
+ public static CSharp.Operator.OpType ConvertBinaryToUserOperator (Operator op)
{
switch (op) {
case Operator.Addition:
Right = Unwrap.CreateUnwrapped (Right);
UnwrapRight = Right as Unwrap;
}
+
+ if (Left.Type.BuiltinType == BuiltinTypeSpec.Type.Decimal) {
+ var decimal_operators = MemberCache.GetUserOperator (Left.Type, Binary.ConvertBinaryToUserOperator (Binary.Oper), false);
+
+ Arguments args = new Arguments (2);
+ args.Add (new Argument (Left));
+ args.Add (new Argument (Right));
+
+ const OverloadResolver.Restrictions restr = OverloadResolver.Restrictions.ProbingOnly |
+ OverloadResolver.Restrictions.NoBaseMembers | OverloadResolver.Restrictions.BaseMembersIncluded;
+
+ var res = new OverloadResolver (decimal_operators, restr, loc);
+ UserOperator = res.ResolveOperator (rc, ref args);
+ }
}
type = Binary.Type;
--- /dev/null
+using System;
+
+public struct MoneyValue
+{
+ private readonly decimal _amount;
+
+ public MoneyValue (decimal amount)
+ {
+ _amount = amount;
+ }
+
+ public static implicit operator decimal (MoneyValue moneyValue)
+ {
+ return moneyValue._amount;
+ }
+}
+
+public class Program
+{
+ static void Main ()
+ {
+ var nullMoneyValue = (MoneyValue?) null;
+ var moneyValue = new MoneyValue (123);
+
+ var crashApplication = nullMoneyValue < moneyValue;
+
+ Console.WriteLine("All OK");
+ }
+}
</method>
</type>
</test>
+ <test name="gtest-644.cs">
+ <type name="MoneyValue">
+ <method name="System.Decimal op_Implicit(MoneyValue)" attrs="2198">
+ <size>16</size>
+ </method>
+ <method name="Void .ctor(Decimal)" attrs="6278">
+ <size>9</size>
+ </method>
+ </type>
+ <type name="Program">
+ <method name="Void Main()" attrs="145">
+ <size>75</size>
+ </method>
+ <method name="Void .ctor()" attrs="6278">
+ <size>7</size>
+ </method>
+ </type>
+ </test>
<test name="gtest-anontype-01.cs">
<type name="Test">
<method name="Int32 Main()" attrs="150">