src/test/01-Basic/243-func-closest-match.ck
raw| 1 | // test that when calling overloaded function, it calls the one |
| 2 | // with the "closer" signature, as determine by distance to parent |
| 3 | // types; in this case, SinOsc is "closer" to UGen than to Object |
| 4 | |
| 5 | fun int foo( Object obj ) |
| 6 | { |
| 7 | return 1; |
| 8 | } |
| 9 | |
| 10 | fun int foo( UGen obj ) |
| 11 | { |
| 12 | return 2; |
| 13 | } |
| 14 | |
| 15 | // a SinOsc which is an UGen, which in turn is an Object |
| 16 | SinOsc bar; |
| 17 | |
| 18 | // which to call? |
| 19 | if( foo( bar ) == 2 ) <<< "success" >>>; |