### Godot version

4.0 rc1

### System information

Windows 11, GTX 1080Ti, Vulkan

### Issue description

Automplete can't find any variables and methods on custom classes when the nodes are loaded with `@onready`:

simple_rotate.gd:
```gdscript
extends Node2D
class_name SimpleRotate

@export var shouldRotate : bool = true
```

machine.gd:
```gdscript
@onready var wheel1 : SimpleRotate = $Wheel

func start_motor():
	wheel1.sho... # Doesn't autocomplete, it can't find shouldRotate 
```

If I add another cast like below, autocomplete does work:
machine.gd:
```gdscript
@onready var wheel1 : SimpleRotate = $Wheel as SimpleRotate

func start_motor():
	wheel1.shouldRotate = true # Autocomplete works
```

To make things even weirder, it does work if I make Wheel into a unique name and access it using %:
machine.gd:
```gdscript
@onready var wheel1 : SimpleRotate = $"%Wheel"

func start_motor():
	wheel1.shouldRotate = true # Autocomplete works
```


### Steps to reproduce

- Create a script with a class_name
- Add that script to a node
- Create another script referencing the node with the type of the script
- Try to let automcomplete find any methods or variables on the script with the class_name
- Notice that it fails

### Minimal reproduction project

N/A
}
		MethodInfo mi(PropertyInfo(Variant::OBJECT, "resource", PROPERTY_HINT_RESOURCE_TYPE, "Resource"), "preload", PropertyInfo(Variant::STRING, "path"));
		r_arghint = _make_arguments_hint(mi, p_argidx);
		return;
	} else if (p_call->type != GDScriptParser::Node::CALL) {
		return;
	}
	Variant base;
	GDScriptParser::DataType base_type;
	bool _static = false;
	const GDScriptParser::CallNode *call = static_cast<const GDScriptParser::CallNode *>(p_call);
	GDScriptParser::Node::Type callee_type = call->get_callee_type();
	if (callee_type == GDScriptParser::Node::SUBSCRIPT) {
		const GDScriptParser::SubscriptNode *subscript = static_cast<const GDScriptParser::SubscriptNode *>(call->callee);
		if (subscript->base != nullptr && subscript->base->type == GDScriptParser::Node::IDENTIFIER) {
			const GDScriptParser::IdentifierNode *base_identifier = static_cast<const GDScriptParser::IdentifierNode *>(subscript->base);
			Variant::Type method_type = GDScriptParser::get_builtin_type(base_identifier->name);
			if (method_type < Variant::VARIANT_MAX) {
				Variant v;
				Callable::CallError err;
				Variant::construct(method_type, v, nullptr, 0, err);
				if (err.error != Callable::CallError::CALL_OK) {
					return;
				}
				List<MethodInfo> methods;
				v.get_method_list(&methods);
				for (MethodInfo &E : methods) {
					if (p_argidx >= E.arguments.size()) {
						continue;
					}