mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cgen: fix interface embedding complex cases (#13472)
This commit is contained in:
parent
73cf597bec
commit
fb3dd82400
@ -5536,7 +5536,7 @@ static inline __shared__$interface_name ${shared_fn_name}(__shared__$cctype* x)
|
||||
}
|
||||
t_methods := g.table.get_embed_methods(st_sym)
|
||||
for t_method in t_methods {
|
||||
if t_method.name !in method_names {
|
||||
if t_method.name !in methods.map(it.name) {
|
||||
methods << t_method
|
||||
}
|
||||
}
|
||||
|
57
vlib/v/tests/interface_embedding_complex_test.v
Normal file
57
vlib/v/tests/interface_embedding_complex_test.v
Normal file
@ -0,0 +1,57 @@
|
||||
fn test_interface_embedding_complex() {
|
||||
mut win := &Window{}
|
||||
ll := &LinearLayout{}
|
||||
win.initables << ll
|
||||
win.init()
|
||||
}
|
||||
|
||||
//----------------------------------
|
||||
|
||||
[heap]
|
||||
pub struct Window {
|
||||
mut:
|
||||
initables []Initable
|
||||
}
|
||||
|
||||
interface Initable {
|
||||
get_ptr()
|
||||
mut:
|
||||
init(&Window)
|
||||
}
|
||||
|
||||
fn (mut w Window) init() {
|
||||
for mut i in w.initables {
|
||||
i.init(w)
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------
|
||||
|
||||
pub struct ViewBase {}
|
||||
|
||||
pub fn (mut vb ViewBase) init(window &Window) {
|
||||
dump(@METHOD)
|
||||
assert false
|
||||
}
|
||||
|
||||
pub fn (vb ViewBase) get_ptr() {}
|
||||
|
||||
//-------------------------------------
|
||||
|
||||
[heap]
|
||||
pub struct ContainerBase {
|
||||
ViewBase
|
||||
}
|
||||
|
||||
// want to excute this method
|
||||
pub fn (mut cb ContainerBase) init(window &Window) {
|
||||
dump(@METHOD)
|
||||
assert true
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
|
||||
[heap]
|
||||
pub struct LinearLayout {
|
||||
ContainerBase
|
||||
}
|
Loading…
Reference in New Issue
Block a user