Open ironpythonbot opened 9 years ago
On 2011-02-07 06:37:11 UTC, rjnienaber commented:
Still seems broken in 2.6.2 and 2.7b1 on .NET Version: 4.0.30319.1: ipy26 testcase-23945.py
9 20 ipy27 testcase-23945.py
9 20 ipy testcase-23945.py
9 20
On 2011-02-07 06:37:33 UTC, rjnienaber commented:
Added testcase.
COperator10 below has a virtual operator op_Add. The python C derives from COperator10, and implement op_Add as * add * . I expect it works.
-- c.cs --
using System.Runtime.CompilerServices;
namespace NS {
public class COperator10 {
int _value;
public COperator10(int val) { _value = val; }
public int Value {
get { return _value; }
}
[SpecialName]
public virtual COperator10 op_Add(COperator10 other) {
return new COperator10(this.Value + other.Value);
}
}
public partial class Callback {
public static COperator10 On(COperator10 arg1, COperator10 arg2) {
return arg1.op_Add(arg2);
}
}
}
-- z.py --
import clr
clr.AddReference("c")
from NS import *
class C(COperator10):
def add(self, other):
return C(self.Value * other.Value)
x = C(4)
y = C(5)
z = Callback.On(x, y)
print z.Value
Works if I define op_Add instead, but it break "x + y"
The issue seems we need to have a symbol conversion here (op_Add to \ add ** ):
public virtual COperator10 op_Add(COperator10 operator1)
{
// This item is obfuscated and can not be translated.
object obj2;
if (!UserTypeOps.TryGetNonInheritedMethodHelper(this. * class * , this, new SymbolId(symbol_op_Add), out obj2))
{
return base.op_Add(operator1);
}
object fromObject = site$0.Invoke(DefaultContext.Default, obj2, operator1);
if (fromObject is COperator10)
{
goto Label_0048;
}
return (COperator10) Converter.ConvertToReferenceType(fromObject, typeof(COperator10).TypeHandle);
}
should be op_Addition, not op_Add
Work Item Details
Original CodePlex Issue: Issue 23945 Status: Active Reason Closed: Unassigned Assigned to: Unassigned Reported on: Jul 28, 2009 at 12:14 AM Reported by: dfugate Updated on: Feb 22, 2013 at 2:12 AM Updated by: jdhardy Custom value: Reported internally at Microsoft. Test: test_special_method.py CreatedDate: 2/4/2008 NewInternalID: 409771 OldInternalID: 374187 AreaPath: IronPython.NET Interop
Plaintext Attachments
CodePlex Issue #23945 Plain Text Attachments