I can support indexers (properties with parameters) in my bridge. So these tests pass:

def test_property_overload_resolution
o = System::PropertyOverloads.new
o[4] = 42
o['5'] = 43
assert_equal 42, o[4]
assert_equal 43, o[5]
assert_equal 42, o['4']
assert_equal 43, o['5']
end

given these properties written in C++:

property int default[int] {
int get(int index) { return _values[index]; }
void set(int index, int value) { _values[index] = value; }
}
property int default[String^] {
int get(String^ index) { return _values[Convert::ToInt32(index)]; }
void set(String^ index, int value) { _values[Convert::ToInt32(index)] = value; }
}

I was writing some corner case tests to validate my new fastproperty code generator (for non-overloaded properties, I bind directly to the method to avoid a runtime lookup) when I came across this interesting oddity:

static property int OverloadedProperty {
int get() { return 1; }
}
static property int OverloadedProperty[int] {
int get(int x) { return _overloadedValue; }
void set(int x, int value) { _overloadedValue = value; }
}

Note that in C++ I can overload non-default properties (I don’t think you can do this in C# or VB). The CLR, of course, supports this but it appears that the languages don’t.

I’m not really sure how to support this case in Ruby:

PropertyTests.OverloadedProperty[]

It resolves into a call to OverloadedProperty, followed by a call to the [] method on the object that was returned by OverloadedProperty.

I don’t think there are cases in the libraries that require this, nor can I think of a good reason why I should support this case.

What do y’all think?