checker: show signature for interface method on error (#8111)
parent
7441889efe
commit
890fb2d09d
|
@ -1851,6 +1851,8 @@ fn (mut c Checker) type_implements(typ table.Type, inter_typ table.Type, pos tok
|
||||||
if method := typ_sym.find_method(imethod.name) {
|
if method := typ_sym.find_method(imethod.name) {
|
||||||
msg := c.table.is_same_method(imethod, method)
|
msg := c.table.is_same_method(imethod, method)
|
||||||
if msg.len > 0 {
|
if msg.len > 0 {
|
||||||
|
sig := c.table.fn_signature(imethod, skip_receiver: true)
|
||||||
|
c.add_error_detail('$inter_sym.name has `$sig`')
|
||||||
c.error('`$styp` incorrectly implements method `$imethod.name` of interface `$inter_sym.name`: $msg',
|
c.error('`$styp` incorrectly implements method `$imethod.name` of interface `$inter_sym.name`: $msg',
|
||||||
pos)
|
pos)
|
||||||
return false
|
return false
|
||||||
|
@ -4907,6 +4909,7 @@ pub fn (mut c Checker) map_init(mut node ast.MapInit) table.Type {
|
||||||
return map_type
|
return map_type
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// call this *before* calling error or warn
|
||||||
pub fn (mut c Checker) add_error_detail(s string) {
|
pub fn (mut c Checker) add_error_detail(s string) {
|
||||||
c.error_details << s
|
c.error_details << s
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,3 +4,4 @@ vlib/v/checker/tests/unimplemented_interface_b.vv:13:6: error: `Cat` incorrectly
|
||||||
13 | foo(c)
|
13 | foo(c)
|
||||||
| ^
|
| ^
|
||||||
14 | }
|
14 | }
|
||||||
|
details: main.Animal has `name() string`
|
||||||
|
|
|
@ -4,3 +4,4 @@ vlib/v/checker/tests/unimplemented_interface_c.vv:12:6: error: `Cat` incorrectly
|
||||||
12 | foo(Cat{})
|
12 | foo(Cat{})
|
||||||
| ~~~~~
|
| ~~~~~
|
||||||
13 | }
|
13 | }
|
||||||
|
details: main.Animal has `name()`
|
||||||
|
|
|
@ -4,3 +4,4 @@ vlib/v/checker/tests/unimplemented_interface_d.vv:12:6: error: `Cat` incorrectly
|
||||||
12 | foo(Cat{})
|
12 | foo(Cat{})
|
||||||
| ~~~~~
|
| ~~~~~
|
||||||
13 | }
|
13 | }
|
||||||
|
details: main.Animal has `speak(s string)`
|
||||||
|
|
|
@ -4,3 +4,4 @@ vlib/v/checker/tests/unimplemented_interface_e.vv:12:6: error: `Cat` incorrectly
|
||||||
12 | foo(Cat{})
|
12 | foo(Cat{})
|
||||||
| ~~~~~
|
| ~~~~~
|
||||||
13 | }
|
13 | }
|
||||||
|
details: main.Animal has `speak(s string)`
|
||||||
|
|
|
@ -4,3 +4,4 @@ vlib/v/checker/tests/unimplemented_interface_f.vv:11:13: error: `Cat` incorrectl
|
||||||
11 | animals << Cat{}
|
11 | animals << Cat{}
|
||||||
| ~~~~~
|
| ~~~~~
|
||||||
12 | }
|
12 | }
|
||||||
|
details: main.Animal has `speak(s string)`
|
||||||
|
|
Loading…
Reference in New Issue