2018 R1.1 and overloaded delegates

I’m having trouble adding event handlers to overloaded events in 2018 R1.1 and I think it’s some sort of weird code-caching compiler issue.

I have something like this:

ClassA
   Event SomeEvent(x as ClassD)
ClassB
   Event SomeEvent(x as ClassE)

Class Foo
  Method Foobar(parm as classA, x as ClassD)
  Method Foobar(parm as classB, x as ClassE)

...
  Constructor
       dim a as new ClassA
       AddHandler a.SomeEvent, WeekAddressOf Foobar

The compiler is giving me the error “There is more than one item with this name and it’s not clear to which this refers” with Foobar highlighted.

I can work around it by renaming my methods to FoobarA and FoobarB, but what’s weird is that it’s inconsistent - in some places in my code I can use overloaded Methods just fine, and in other cases I can’t.

Anyone else seeing this?

I think it’s because the two Foobar methods have the same number of parameters, so the AddHandler doesn’t know which one to link to

but they don’t have the same delegate signature, which seems like it should work…

This sometimes shows up when there are zero matches.

Think this should get some attention, is there a FB ?

Yes

[quote=389755:@Michael Diehr]I’m having trouble adding event handlers to overloaded events in 2018 R1.1 and I think it’s some sort of weird code-caching compiler issue.

I have something like this:

ClassA
   Event SomeEvent(x as ClassD)
ClassB
   Event SomeEvent(x as ClassE)

Class Foo
  Method Foobar(parm as classA, x as ClassD)
  Method Foobar(parm as classB, x as ClassE)

...
  Constructor
       dim a as new ClassA
       AddHandler a.SomeEvent, WeekAddressOf Foobar

The compiler is giving me the error “There is more than one item with this name and it’s not clear to which this refers” with Foobar highlighted.

I can work around it by renaming my methods to FoobarA and FoobarB, but what’s weird is that it’s inconsistent - in some places in my code I can use overloaded Methods just fine, and in other cases I can’t.

Anyone else seeing this?[/quote]
What’s are relationships between ClassA & Class B, and Class D & E.

I’ve submitted a simple test program: <https://xojo.com/issue/52344>

The compiler is good about handling overloaded methods in other scenarios, so it seems like this should work fine here. If it’s not a bug, then please consider it a feature request.

Testing older versions, this problem is not new (I see it in RealStudio 2011R3, Xojo 2014 R2.1 ) so maybe it’s just something that has never worked?

Norman pointed out this is an old issue: <https://xojo.com/issue/26123>