Ticket #146 (assigned defect)
bug when adding an extension method that is an overload of a BCL class
| Reported by: | jonathandavid | Owned by: | jonathandavid |
|---|---|---|---|
| Priority: | medium | Milestone: | Cobra 0.9 |
| Component: | Cobra Compiler | Version: | 0.8.0 |
| Keywords: | extension methods | Cc: |
Description
Consider:
extend String
def split(chars as char*) as List<of String>
return ['dummy']
class Foo
def main is shared
print 'a:b'.split(@[c':']) # Prints ['dummy']
When the main method is executed, it looks as if the compiler is generating a call to my split(char*) extension method. This is wrong, because there is also a split(char[]) method in String that matches exactly the argument I'm passing.
I think the problem only occurs when adding an extension overload to a BCL class because the problem does not show up when I try to reproduce it using a class written in Cobra:
class Foo def bar(x as int[]) pass extend Foo def bar(x as int*) .bar(List<of int>(x).toArray) class Baz def main is shared Foo().bar(@[1, 2]) # correctly calls array version
Attachments
Change History
Note: See
TracTickets for help on using
tickets.




