| 1 | // Regression test for #19618. |
| 2 | // Generic interface inference should bind nested generic struct arguments. |
| 3 | |
| 4 | interface MyInterface[T] { |
| 5 | is_good(a T) bool |
| 6 | } |
| 7 | |
| 8 | struct MyStruct[T] {} |
| 9 | |
| 10 | struct Opt[T] { |
| 11 | x ?T |
| 12 | } |
| 13 | |
| 14 | fn (_ MyStruct[T]) is_good(a Opt[T]) bool { |
| 15 | if _ := a.x { |
| 16 | return true |
| 17 | } |
| 18 | return false |
| 19 | } |
| 20 | |
| 21 | fn check[T](a MyInterface[T], b T) bool { |
| 22 | return a.is_good(b) |
| 23 | } |
| 24 | |
| 25 | fn test_generic_interface_infers_nested_generic_struct_argument() { |
| 26 | a := MyStruct[int]{} |
| 27 | b := Opt[int]{ |
| 28 | x: 6 |
| 29 | } |
| 30 | assert check(a, b) |
| 31 | } |
| 32 | |