cgen: fix interface embedding complex cases (#13472)
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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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