cgen: prevent generation of duplicate interface method wrappers

pull/6129/head
Delyan Angelov 2020-08-13 19:56:58 +03:00
parent 2353814821
commit 1135dffe2d
1 changed files with 5 additions and 0 deletions

View File

@ -4572,12 +4572,17 @@ fn (mut g Gen) interface_table() string {
cast_functions.write('// Casting functions for interface "$interface_name"')
mut methods_wrapper := strings.new_builder(100)
methods_wrapper.writeln('// Methods wrapper for interface "$interface_name"')
mut already_generated_mwrappers := map[string]bool
for i, st in inter_info.types {
// cctype is the Cleaned Concrete Type name, *without ptr*,
// i.e. cctype is always just Cat, not Cat_ptr:
cctype := g.cc_type(st)
// Speaker_Cat_index = 0
interface_index_name := '_${interface_name}_${cctype}_index'
if already_generated_mwrappers[interface_index_name] {
continue
}
already_generated_mwrappers[interface_index_name] = true
cast_functions.writeln('
_Interface I_${cctype}_to_Interface_${interface_name}($cctype* x) {
return (_Interface) {