From 1135dffe2d5a165e2df1a6e164034cf73e55860f Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Thu, 13 Aug 2020 19:56:58 +0300 Subject: [PATCH] cgen: prevent generation of duplicate interface method wrappers --- vlib/v/gen/cgen.v | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/vlib/v/gen/cgen.v b/vlib/v/gen/cgen.v index 142070884d..eab989a0ab 100644 --- a/vlib/v/gen/cgen.v +++ b/vlib/v/gen/cgen.v @@ -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) {