Repository: godot
Issue: Crash when calling a static method in a @tool script 
Labels: bug,topic:gdscript,topic:editor,crash

### Tested versions

v4.3.dev.custom_build[4a0160241]

### System information

Manjaro Linux

### Issue description

If a script has a class_name that conflicts with an internal editor class, calling a static method of this script in the editor (using `@tool`) causes a crash.


```
handle_crash: Program crashed with signal 11
Engine version: Godot Engine v4.3.dev.custom_build (4a0160241fd0c1e874e297f6b08676cf0761e5e8)
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[1] /usr/lib/libc.so.6(+0x40770) [0x7f978c04f770] (??:0)
[2] GDScriptFunction::call(GDScriptInstance*, Variant const**, int, Callable::CallError&, GDScriptFunction::CallState*) (modules/gdscript/gdscript_vm.cpp:1929)
[3] GDScriptInstance::callp(StringName const&, Variant const**, int, Callable::CallError&) (modules/gdscript/gdscript.cpp:1959)
[4] bool Node::_gdvirtual__ready_call<false>() (scene/main/node.h:354 (discriminator 1))
[5] Node::_notification(int) (scene/main/node.cpp:214)
[6] Node::_notificationv(int, bool) (./scene/main/node.h:49 (discriminator 14))
[7] CanvasItem::_notificationv(int, bool) (./scene/main/canvas_item.h:45 (discriminator 3))
[8] Control::_notificationv(int, bool) (./scene/gui/control.h:48 (discriminator 3))
[9] Object::notification(int, bool) (core/object/object.cpp:902)
[10] Node::_propagate_ready() (scene/main/node.cpp:269)
[11] Node::_set_tree(SceneTree*) (scene/main/node.cpp:3181)
[12] Node::_add_child_nocheck(Node*, StringName const&, Node::InternalMode) (scene/main/node.cpp:1552)
[13] Node::add_child(Node*, bool, Node::InternalMode) (scene/main/node.cpp:1580)
[14] EditorNode::set_edited_scene(Node*) (editor/editor_node.cpp:3706)
[15] EditorNode::load_scene(String const&, bool, bool, bool, bool, bool) (editor/editor_node.cpp:4032)
[16] EditorNode::open_request(String const&) (editor/editor_node.cpp:4245)
[17] FileSystemDock::_select_file(String const&, bool) (editor/filesystem_dock.cpp:1224 (discriminator 1))
[18] FileSystemDock::_tree_activate_file() (editor/filesystem_dock.cpp:1263 (discriminator 1))
[19] void call_with_variant_args_helper<FileSystemDock>(FileSystemDock*, void (FileSystemDock::*)(), Variant const**, Callable::CallError&, IndexSequence<>) (./core/variant/binder_common.h:309)
[20] void call_with_variant_args<FileSystemDock>(FileSystemDock*, void (FileSystemDock::*)(), Variant const**, int, Callable::CallError&) (./core/variant/binder_common.h:419)
[21] CallableCustomMethodPointer<FileSystemDock>::call(Variant const**, int, Variant&, Callable::CallError&) const (./core/object/callable_method_pointer.h:104)
[22] Callable::callp(Variant const**, int, Variant&, Callable::CallError&) const (core/variant/callable.cpp:57)
[23] Object::emit_signalp(StringName const&, Variant const**, int) (core/object/object.cpp:1216)
[24] Node::emit_signalp(StringName const&, Variant const**, int) (scene/main/node.cpp:3901)
[25] Error Object::emit_signal<>(StringName const&) (./core/object/object.h:935)
[26] Tree::gui_input(Ref<InputEvent> const&) (scene/gui/tree.cpp:3935)
[27] Control::_call_gui_input(Ref<InputEvent> const&) (scene/gui/control.cpp:1795)
[28] Viewport::_gui_call_input(Control*, Ref<InputEvent> const&) (scene/main/viewport.cpp:1548)
[29] Viewport::_gui_input_event(Ref<InputEvent>) (scene/main/viewport.cpp:1778 (discriminator 2))
[30] Viewport::push_input(Ref<InputEvent> const&, bool) (scene/main/viewport.cpp:3239 (discriminator 2))
[31] Window::_window_input(Ref<InputEvent> const&) (scene/main/window.cpp:1629)
[32] void call_with_variant_args_helper<Window, Ref<InputEvent> const&, 0ul>(Window*, void (Window::*)(Ref<InputEvent> const&), Variant const**, Callable::CallError&, IndexSequence<0ul>) (./core/variant/binder_common.h:304 (discriminator 2))
[33] void call_with_variant_args<Window, Ref<InputEvent> const&>(Window*, void (Window::*)(Ref<InputEvent> const&), Variant const**, int, Callable::CallError&) (./core/variant/binder_common.h:419)
[34] CallableCustomMethodPointer<Window, Ref<InputEvent> const&>::call(Variant const**, int, Variant&, Callable::CallError&) const (./core/object/callable_method_pointer.h:104)
[35] Callable::callp(Variant const**, int, Variant&, Callable::CallError&) const (core/variant/callable.cpp:57)
[36] Variant Callable::call<Ref<InputEvent> >(Ref<InputEvent>) const (./core/variant/variant.h:855)
[37] DisplayServerX11::_dispatch_input_event(Ref<InputEvent> const&) (platform/linuxbsd/x11/display_server_x11.cpp:4012 (discriminator 2))
[38] DisplayServerX11::_dispatch_input_events(Ref<InputEvent> const&) (platform/linuxbsd/x11/display_server_x11.cpp:3989)
[39] Input::_parse_input_event_impl(Ref<InputEvent> const&, bool) (core/input/input.cpp:773)
[40] Input::flush_buffered_events() (core/input/input.cpp:1044)
[41] DisplayServerX11::process_events() (platform/linuxbsd/x11/display_server_x11.cpp:5103)
[42] OS_LinuxBSD::run() (platform/linuxbsd/os_linuxbsd.cpp:960)
[43] godotd(main+0x18c) [0x563da33bf4c5] (platform/linuxbsd/godot_linuxbsd.cpp:85)
[44] /usr/lib/libc.so.6(+0x29cd0) [0x7f978c038cd0] (??:0)
[45] /usr/lib/libc.so.6(__libc_start_main+0x8a) [0x7f978c038d8a] (??:0)
[46] godotd(_start+0x25) [0x563da33bf265] (??:?)
-- END OF BACKTRACE --

```

### Steps to reproduce

- Create a script (no need to be `@tool`) which name conflicts with an internal editor class (e.g. SceneTreeEditor, CanvasItemEditorViewport)
- Add a static method to this script
- Create a scene which root's script is tool and calls the static method in _ready()
- Open the scene and the crash occurs

### Minimal reproduction project (MRP)

[static_method_tool.zip](https://github.com/godotengine/godot/files/15149518/static_method_tool.zip)
Open `example.tscn` to reproduce the crash.