IronLanguages / main

Work for this repo has moved to https://github.com/IronLanguages/ironpython2
1.16k stars 350 forks source link

type builder adds set_Item/get_Item twice for the interface type #621

Open ironpythonbot opened 9 years ago

ironpythonbot commented 9 years ago

namespace NS {
public interface I {
int this[int arg] { get; set; }
}
public class C : I  {
int I.this[int arg] {
get { Console.WriteLine("get"); return arg; }
set { Console.WriteLine("set"); }
}
}
}

import clr
clr.AddReference("c")
from NS import *
x = C()
f = I.set_Item
print f. * doc *
f(x, 1, 2)

expected: print 'set'
actual behavior:
set_Item(self, int arg, int value)
set_Item(self, int arg, int value)
Traceback (most recent call last):
File Tests\interop\y.py, line 10, in Initialize
TypeError: set_Item() takes exactly 3 arguments (3 given)

THIS TEST AFFECTS Main\Languages\IronPython\Tests\interop\derivation\test_property_override.py TOO.

Work Item Details

Original CodePlex Issue: Issue 23889 Status: Active Reason Closed: Unassigned Assigned to: Unassigned Reported on: Jul 28, 2009 at 12:05 AM Reported by: dfugate Updated on: Feb 22, 2013 at 2:12 AM Updated by: jdhardy Custom value: Reported internally at Microsoft. Test: test_indexer.py CreatedDate: 12/26/2007 NewInternalID: 409707 OldInternalID: 363289 AreaPath: IronPython.NET Interop

Plaintext Attachments

CodePlex Issue #23889 Plain Text Attachments

ironpythonbot commented 9 years ago

On 2011-01-28 05:09:08 UTC, rjnienaber commented:

I changed the IronPython code to the following:

from NS import * x = C() f = I.Item f(x, 1)

And this is the output on 2.6.2 and 2.7b1 on .NET 4.0.30319.1:

Traceback (most recent call last): File "testcase-23889.py", line 40, in TypeError: indexer# is not callable

The set_Item doesn't get added twice but we still get an error. Also when I use the 'dir' function on 'I', I get the following:

['Item', 'doc', 'getitem', 'repr', 'setitem']

It seems like 'Item' should be omitted and just 'getitem' and 'setitem' should be present.