@@ -1166,6 +1166,48 @@ void AbstractMetaBuilder::traverseFunctions(ScopeModelItem scope_item, AbstractM
1166
1166
}
1167
1167
}
1168
1168
}
1169
+ removeEquivalentFunctions (meta_class);
1170
+ }
1171
+
1172
+ void AbstractMetaBuilder::removeEquivalentFunctions (AbstractMetaClass* parent)
1173
+ {
1174
+ AbstractMetaFunctionList functions = parent->functions ();
1175
+ for (AbstractMetaFunction* fun : functions)
1176
+ {
1177
+ AbstractMetaArgumentList args = fun->arguments ();
1178
+ bool candidateToRemove = false ;
1179
+ for (AbstractMetaArgument* arg : args) {
1180
+ const TypeEntry* argType = arg->type ()->typeEntry ();
1181
+ if (argType && argType->equivalentType ()) {
1182
+ candidateToRemove = true ;
1183
+ break ;
1184
+ }
1185
+ }
1186
+ if (!candidateToRemove) {
1187
+ continue ;
1188
+ }
1189
+ // check if there are other functions with the same name and equivalent parameters
1190
+ AbstractMetaFunctionList overloadedFunctions = parent->queryFunctionsByName (fun->name ());
1191
+ for (AbstractMetaFunction* overload : overloadedFunctions) {
1192
+ if (overload != fun) {
1193
+ AbstractMetaArgumentList overloadArgs = overload->arguments ();
1194
+ if (overloadArgs.size () == args.size ()) {
1195
+ bool equivalentArgs = true ;
1196
+ for (int i = 0 ; i < args.size () && equivalentArgs; i++) {
1197
+ const TypeEntry* argType = args[i]->type ()->typeEntry ();
1198
+ const TypeEntry* overloadArgType = overloadArgs[i]->type ()->typeEntry ();
1199
+ // This could have some more equivalency checks, but currently this seems to be sufficient
1200
+ equivalentArgs = (argType && overloadArgType &&
1201
+ (argType == overloadArgType || argType->equivalentType () == overloadArgType));
1202
+ }
1203
+ if (equivalentArgs) {
1204
+ parent->removeFunction (fun);
1205
+ break ;
1206
+ }
1207
+ }
1208
+ }
1209
+ }
1210
+ }
1169
1211
}
1170
1212
1171
1213
bool AbstractMetaBuilder::setupInheritance (AbstractMetaClass *meta_class)
0 commit comments