| 1 | // Regression test for issue #18320. |
| 2 | struct CustomStruct { |
| 3 | pub: |
| 4 | a int |
| 5 | b string |
| 6 | } |
| 7 | |
| 8 | interface BaseInterface { |
| 9 | a int |
| 10 | } |
| 11 | |
| 12 | fn callback[T](ctx BaseInterface, cb fn (T)) { |
| 13 | $if T is BaseInterface { |
| 14 | cb(ctx) |
| 15 | } |
| 16 | } |
| 17 | |
| 18 | fn main() { |
| 19 | custom := CustomStruct{ |
| 20 | a: 5 |
| 21 | b: 'test' |
| 22 | } |
| 23 | callback(custom, fn (ctx CustomStruct) { |
| 24 | println(ctx) |
| 25 | }) |
| 26 | } |
| 27 |