Repository: godotengine/godot
File: modules/gdscript/gdscript.cpp (C++)

Code before:
const Variant GDScript::get_rpc_config() const {
	return rpc_config;
}

void GDScript::unload_static() const {
	GDScriptCache::remove_script(fully_qualified_name);
}

Variant GDScript::callp(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
	GDScript *top = this;
	while (top) {
		if (likely(top->valid)) {
			HashMap<StringName, GDScriptFunction *>::Iterator E = top->member_functions.find(p_method);
			if (E) {
				ERR_FAIL_COND_V_MSG(!E->value->is_static(), Variant(), "Can't call non-static function '" + String(p_method) + "' in script.");

				return E->value->call(nullptr, p_args, p_argcount, r_error);
			}
		}
		top = top->_base;
	}

	Variant ret = Script::callp(p_method, p_args, p_argcount, r_error);
	if (r_error.error != Callable::CallError::CALL_ERROR_INVALID_METHOD) {
		return ret;
	}

	if (native.is_valid()) {
		MethodBind *method = ClassDB::get_method(native->get_name(), p_method);
		if (method && method->is_static()) {
			// Native static method.
			return method->call(nullptr, p_args, p_argcount, r_error);
		}
	}

	r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
	return ret;
}

bool GDScript::_get(const StringName &p_name, Variant &r_ret) const {
	if (p_name == GDScriptLanguage::get_singleton()->strings._script_source) {
		r_ret = get_source_code();
		return true;
	}

	const GDScript *top = this;
	while (top) {
		{
			HashMap<StringName, Variant>::ConstIterator E = top->constants.find(p_name);
			if (E) {
				r_ret = E->value;

Review comment (suggestion):
```suggestion
	{
		Variant ret = Script::callp(p_method, p_args, p_argcount, r_error);
		if (r_error.error != Callable::CallError::CALL_ERROR_INVALID_METHOD) {
			return ret;
		}
	}
```

Code after:
	while (top) {
		if (likely(top->valid)) {
			HashMap<StringName, GDScriptFunction *>::Iterator E = top->member_functions.find(p_method);
			if (E) {
				ERR_FAIL_COND_V_MSG(!E->value->is_static(), Variant(), "Can't call non-static function '" + String(p_method) + "' in script.");

				return E->value->call(nullptr, p_args, p_argcount, r_error);
			}
		}
		top = top->base.ptr();
	}

	{
		Variant ret = Script::callp(p_method, p_args, p_argcount, r_error);
		if (r_error.error != Callable::CallError::CALL_ERROR_INVALID_METHOD) {
			return ret;
		}
	}

	if (native.is_valid()) {
		return native->callp(p_method, p_args, p_argcount, r_error);
	}

	r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
	return Variant();
}

bool GDScript::_get(const StringName &p_name, Variant &r_ret) const {
	if (p_name == GDScriptLanguage::get_singleton()->strings._script_source) {
		r_ret = get_source_code();
		return true;
	}

	const GDScript *top = this;
	while (top) {
		{
			HashMap<StringName, Variant>::ConstIterator E = top->constants.find(p_name);
			if (E) {
				r_ret = E->value;
				return true;
			}
		}

		{
			HashMap<StringName, MemberInfo>::ConstIterator E = top->static_variables_indices.find(p_name);
			if (E) {
				if (likely(top->valid) && E->value.getter) {
					Callable::CallError ce;
					const Variant ret = const_cast<GDScript *>(this)->callp(E->value.getter, nullptr, 0, ce);
					r_ret = (ce.error == Callable::CallError::CALL_OK) ? ret : Variant();
					return true;