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

Code before:
		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;
				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();

Review comment (suggestion):
I think this part can just be `native->callp(p_method, p_args, p_argcount, r_error);`.

Code after:

	{
		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;
				}
				r_ret = top->static_variables[E->value.index];
				return true;
			}
		}

		if (likely(top->valid)) {
			HashMap<StringName, GDScriptFunction *>::ConstIterator E = top->member_functions.find(p_name);
			if (E && E->value->is_static()) {
				if (top->rpc_config.has(p_name)) {
					r_ret = Callable(memnew(GDScriptRPCCallable(const_cast<GDScript *>(top), E->key)));