cgen: generate interfaces after all other typedefs (#9680)
parent
0facc5a559
commit
6cfd53bf57
|
@ -791,9 +791,6 @@ pub fn (mut g Gen) write_typedef_types() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.interface_ {
|
|
||||||
g.write_interface_typesymbol_declaration(typ)
|
|
||||||
}
|
|
||||||
.chan {
|
.chan {
|
||||||
if typ.name != 'chan' {
|
if typ.name != 'chan' {
|
||||||
g.type_definitions.writeln('typedef chan $typ.cname;')
|
g.type_definitions.writeln('typedef chan $typ.cname;')
|
||||||
|
@ -825,6 +822,14 @@ static inline void __${typ.cname}_pushval($typ.cname ch, $el_stype val) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Generating interfaces after all the common types have been defined
|
||||||
|
// to prevent generating interface struct before definition of field types
|
||||||
|
for typ in g.table.type_symbols {
|
||||||
|
if typ.kind == .interface_ && typ.name !in c.builtins {
|
||||||
|
g.write_interface_typesymbol_declaration(typ)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (mut g Gen) write_interface_typesymbol_declaration(sym ast.TypeSymbol) {
|
pub fn (mut g Gen) write_interface_typesymbol_declaration(sym ast.TypeSymbol) {
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
struct Test {}
|
||||||
|
|
||||||
|
interface Testing {
|
||||||
|
tests []Test
|
||||||
|
}
|
||||||
|
|
||||||
|
fn test_field_typearray() {}
|
Loading…
Reference in New Issue