| 1 | // fixes https://github.com/vlang/v/issues/11485 based on code example by https://github.com/Wertzui123 |
| 2 | interface IExample { |
| 3 | } |
| 4 | |
| 5 | struct Example { |
| 6 | value string |
| 7 | } |
| 8 | |
| 9 | fn test_if_smartcast_likely() { |
| 10 | print_value(Example{ value: 'Hello' }) |
| 11 | } |
| 12 | |
| 13 | fn print_value(example IExample) { |
| 14 | if _likely_(example is Example) { |
| 15 | print('Value: ' + example.value) |
| 16 | } |
| 17 | } |
| 18 |