|
Revision 2089, 0.5 KB
(checked in by Chuck.Esterbrook, 3 years ago)
|
|
Fixed: The method resolution against a method overloaded by generic parameter vs. non-generic parameter, does not always choose the correct method.
reported-by:gauthier
|
-
Property svn:eol-style set to
native
|
| Line | |
|---|
| 1 | class Thing |
|---|
| 2 | pass |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | class X |
|---|
| 6 | |
|---|
| 7 | # overload method by generic vs. non-generic: |
|---|
| 8 | |
|---|
| 9 | def foo as Object |
|---|
| 10 | return 1 |
|---|
| 11 | |
|---|
| 12 | def foo<of T> as T |
|---|
| 13 | where T must be Thing |
|---|
| 14 | return Thing() to T |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | class P |
|---|
| 18 | |
|---|
| 19 | def main |
|---|
| 20 | assert .a == 1 |
|---|
| 21 | assert (.b to dynamic) inherits Thing |
|---|
| 22 | |
|---|
| 23 | def a as Object? |
|---|
| 24 | return X().foo |
|---|
| 25 | |
|---|
| 26 | def b as Thing |
|---|
| 27 | return X().foo<of Thing> # <-- this is the big test |
|---|
| 28 | # the method resolution must favor the generic method |
|---|
| 29 | # we can tell if it chose the non-generic method because its |
|---|
| 30 | # return type is not compatible with this method's return type |
|---|