C#: Don't return MethodInfo for overloaded methods

This means the GDScript analyzer loses the method signature information so it can't do type checking for the parameters.
This commit is contained in:
Raul Santos 2024-04-21 05:32:47 +02:00
parent 2efbc6bfb3
commit 7316918a0f
No known key found for this signature in database
GPG Key ID: B532473AE3A803E4
1 changed files with 9 additions and 2 deletions

View File

@ -2518,13 +2518,20 @@ MethodInfo CSharpScript::get_method_info(const StringName &p_method) const {
return MethodInfo(); return MethodInfo();
} }
MethodInfo mi;
for (const CSharpMethodInfo &E : methods) { for (const CSharpMethodInfo &E : methods) {
if (E.name == p_method) { if (E.name == p_method) {
return E.method_info; if (mi.name == p_method) {
// We already found a method with the same name before so
// that means this method has overloads, the best we can do
// is return an empty MethodInfo.
return MethodInfo();
}
mi = E.method_info;
} }
} }
return MethodInfo(); return mi;
} }
Variant CSharpScript::callp(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) { Variant CSharpScript::callp(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) {