| 1 | type SumType = AA | BB |
| 2 | |
| 3 | struct AA {} |
| 4 | |
| 5 | struct BB {} |
| 6 | |
| 7 | fn (a &AA) foo() int { |
| 8 | println('AA.foo()') |
| 9 | return 200 |
| 10 | } |
| 11 | |
| 12 | fn (b &BB) foo() int { |
| 13 | println('BB.foo()') |
| 14 | return 100 |
| 15 | } |
| 16 | |
| 17 | fn test_main() { |
| 18 | x := SumType(BB{}) |
| 19 | match x { |
| 20 | AA, BB { |
| 21 | ret := x.foo() |
| 22 | assert ret == 100 |
| 23 | return |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | assert false |
| 28 | } |
| 29 |