v2 / vlib / v / tests / selector_as_cast_test.v
26 lines · 21 sloc · 296 bytes · 0c9d0762c7652994233d696978815ff69085844c
Raw
1struct Foo {
2 expr SumType
3}
4
5struct Bar {
6 expr SumType
7}
8
9type SumType = Foo | string | Bar
10type SumType2 = SumType | int
11
12struct Gen {}
13
14fn (g Gen) t(arg SumType2) {
15}
16
17fn test_main() {
18 gen := Gen{}
19 s := Bar{
20 expr: Foo{
21 expr: 'foobar'
22 }
23 }
24 gen.t((s.expr as Foo).expr)
25 assert true
26}
27