cgen: generate interfaces after all other typedefs (#9680)

pull/9700/head
Henrixounez 2021-04-11 23:43:19 +02:00 committed by GitHub
parent 0facc5a559
commit 6cfd53bf57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 3 deletions

View File

@ -791,9 +791,6 @@ pub fn (mut g Gen) write_typedef_types() {
}
}
}
.interface_ {
g.write_interface_typesymbol_declaration(typ)
}
.chan {
if typ.name != 'chan' {
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) {

View File

@ -0,0 +1,7 @@
struct Test {}
interface Testing {
tests []Test
}
fn test_field_typearray() {}