File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -155,6 +155,9 @@ fn (mut g Gen) gen_struct_equality_fn(left_type ast.Type) string {
155
155
fn_builder.write_string ('${eq_fn} _alias_eq(a.$field_name , b.$field_name )' )
156
156
} else if field_type.sym.kind == .function {
157
157
fn_builder.write_string ('*((voidptr*)(a.$field_name )) == *((voidptr*)(b.$field_name ))' )
158
+ } else if field_type.sym.kind == .interface_ {
159
+ eq_fn := g.gen_interface_equality_fn (field.typ)
160
+ fn_builder.write_string ('${eq_fn} _interface_eq(a.$field_name , b.$field_name )' )
158
161
} else {
159
162
fn_builder.write_string ('a.$field_name == b.$field_name ' )
160
163
}
Original file line number Diff line number Diff line change
1
+ interface IExample {
2
+ thing () bool
3
+ }
4
+
5
+ struct Foo {}
6
+
7
+ fn (n Foo) thing () bool {
8
+ return true
9
+ }
10
+
11
+ struct Test {
12
+ a IExample
13
+ }
14
+
15
+ fn new () Test {
16
+ return Test{Foo{}}
17
+ }
18
+
19
+ fn test_struct_auto_eq_gen_interface_case () {
20
+ w1 := new ()
21
+ w2 := new ()
22
+ assert w1 == w2
23
+ }
You can’t perform that action at this time.
0 commit comments