GDScript: Improve call analysis

* Add missing `UNSAFE_CALL_ARGUMENT` warning.
* Fix `Object` constructor.
* Display an error for non-existent static methods.
This commit is contained in:
Danil Alexeev 2023-09-21 12:42:55 +03:00
parent 59139df16e
commit e8696f9961
No known key found for this signature in database
GPG key ID: 124453E157DA8DC7
25 changed files with 184 additions and 46 deletions

View file

@ -52,11 +52,18 @@
#include "editor/editor_settings.h"
#endif
// This function is used to determine that a type is "built-in" as opposed to native
// and custom classes. So `Variant::NIL` and `Variant::OBJECT` are excluded:
// `Variant::NIL` - `null` is literal, not a type.
// `Variant::OBJECT` - `Object` should be treated as a class, not as a built-in type.
static HashMap<StringName, Variant::Type> builtin_types;
Variant::Type GDScriptParser::get_builtin_type(const StringName &p_type) {
if (builtin_types.is_empty()) {
for (int i = 1; i < Variant::VARIANT_MAX; i++) {
builtin_types[Variant::get_type_name((Variant::Type)i)] = (Variant::Type)i;
if (unlikely(builtin_types.is_empty())) {
for (int i = 0; i < Variant::VARIANT_MAX; i++) {
Variant::Type type = (Variant::Type)i;
if (type != Variant::NIL && type != Variant::OBJECT) {
builtin_types[Variant::get_type_name(type)] = type;
}
}
}