Repository: godot
Issue: GDScript issues identified by MetSys
Labels: bug,topic:gdscript,topic:editor

### Godot version

4.2 beta6

### System information

Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1060 (NVIDIA; 30.0.15.1403) - Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz (8 Threads)

### Issue description

Assorted list of issues related to GDscript and script editor that I found while working on a big GDScript addon. Some of them might be already reported, but this issue is kind of a tracker for this stuff. I also provided steps how to reproduce each issue (you need the minimal project).

- [x] Missing autocompletion for typed variable
![image](https://github.com/godotengine/godot/assets/2223172/27f5e610-c3b4-4b33-8dd5-e6abbb987e63)
The variable has explicit type, but does not provide autocompletion for methods (in above case, `merge()`).

Reproduction:
https://github.com/KoBeWi/Metroidvania-System/blob/78ec4620e9a4d555debca783fd5a5b92fe64bc20/addons/MetroidvaniaSystem/Scripts/RoomDrawer.gd#L180-L181
Refer to one of the dictionaries and try to autocomplete methods.

- [ ] Lack of preloaded type autocompletion
![image](https://github.com/godotengine/godot/assets/2223172/a7c8bf7f-2374-4f54-a83f-cdcab4a07495)
I have `const MapData = preload()` type inside a `class_name` script and this type is not suggested as a member of the class. `MapData` has a an inner class `CellData`, which also isn't suggested. Both types provide autocompletion for their own members when used in variables:
![image](https://github.com/godotengine/godot/assets/2223172/239ea0c3-0109-4bc6-a054-68ec4ca2671b)

Reproduction:
In any script, refer to `MetroidvaniaSystem.MapData` type. It's not suggested by autocompletion, despite being a constant of the class.

- [x] Missing autocompletion for variables of an autoload that use preloaded type
![image](https://github.com/godotengine/godot/assets/2223172/7a43ccd6-0bd9-4592-a5e2-3f3fc6ed9283)
I have a variable `settings` in a singleton `MetSys` and there is no autocompletion for its members. However the variable itself works correctly with type inference:
![image](https://github.com/godotengine/godot/assets/2223172/ce6c4b18-34d3-4716-85d7-0cb6229b23f6)
No error, so type is known.

Reproduction:
In any script, refer to members of `MetSys.settings`.

- [x] Can't jump to member

![image](https://github.com/godotengine/godot/assets/2223172/17304c5f-7185-46c6-8a35-624a9fdf8fb2)

Again with `MapData` type. It's known here, because inference does not complain, but I can't Ctrl+Click the method below caret.

Reproduction:
https://github.com/KoBeWi/Metroidvania-System/blob/78ec4620e9a4d555debca783fd5a5b92fe64bc20/addons/MetroidvaniaSystem/Scripts/MapBuilder.gd#L13
Try to Ctrl+Click `create_custom_cell()`.

- [ ] Inference fails only at runtime

https://github.com/godotengine/godot/assets/2223172/3e3b14b6-f411-472a-b09b-11fb702d46c8

Same line as above. I'm actually using explicit type here, because otherwise it breaks at runtime. As you can see above, in the editor the variable even gets autocompletion, which means the type is known.

Reproduction:
https://github.com/KoBeWi/Metroidvania-System/blob/78ec4620e9a4d555debca783fd5a5b92fe64bc20/addons/MetroidvaniaSystem/Scripts/MapBuilder.gd#L13
Remove explicit type and use inference (`:=`).
Another line where this happens:
https://github.com/KoBeWi/Metroidvania-System/blob/78ec4620e9a4d555debca783fd5a5b92fe64bc20/addons/MetroidvaniaSystem/Scripts/RoomDrawer.gd#L334

I actually written down 4 more issues, but 2 seem fixed and 2 are more editor related, so I'll open them separate.

### Steps to reproduce

Listed below for each point.

### Minimal reproduction project

https://github.com/KoBeWi/Metroidvania-System