### Godot version

4.1.1

### System information

windows 11

### Issue description

When registering a type with class_name and using that class name to declare a variable in code only, autocomplete works as expected anywhere in other nodes/scenes. However, if making a custom scene node that extends a script with the class_name, if that custom scene is instantiated in a different scene, even if the type is specified, it only shows the parent node's functions and not any of the extended functionality. I have made a basic project showing the issue

### Steps to reproduce

I have made a very simple project showing the issue. https://github.com/mmmmmmmmmmmmmmmmmmmdonuts/godot_4_autocomplete_issue essentially, the extended Node scene will only show the custom function when both the type is specified as well as the type afterwards following "as" 
e.g. `@onready var my_class_4: MyClass = $MyClass4 as MyClass`

### Minimal reproduction project

https://github.com/mmmmmmmmmmmmmmmmmmmdonuts/godot_4_autocomplete_issue
ScriptLanguage::CodeCompletionOption hint1("attenuation", ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT);
			hint1.insert_text = hint1.display.quote(p_quote_style);
			r_result.insert(hint1.display, hint1);
			ScriptLanguage::CodeCompletionOption hint2("inout", ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT);
			hint2.insert_text = hint2.display.quote(p_quote_style);
			r_result.insert(hint2.display, hint2);
		}
	} else if (p_annotation->name == SNAME("@export_node_path")) {
		ScriptLanguage::CodeCompletionOption node("Node", ScriptLanguage::CODE_COMPLETION_KIND_CLASS);
		node.insert_text = node.display.quote(p_quote_style);
		r_result.insert(node.display, node);
		List<StringName> native_classes;
		ClassDB::get_inheriters_from_class("Node", &native_classes);
		for (const StringName &E : native_classes) {
			if (!ClassDB::is_class_exposed(E)) {
				continue;
			}
			ScriptLanguage::CodeCompletionOption option(E, ScriptLanguage::CODE_COMPLETION_KIND_CLASS);
			option.insert_text = option.display.quote(p_quote_style);
			r_result.insert(option.display, option);
		}
		List<StringName> global_script_classes;
		ScriptServer::get_global_class_list(&global_script_classes);
		for (const StringName &E : global_script_classes) {
			if (!ClassDB::is_parent_class(ScriptServer::get_global_class_native_base(E), "Node")) {
				continue;
			}
			ScriptLanguage::CodeCompletionOption option(E, ScriptLanguage::CODE_COMPLETION_KIND_CLASS);
			option.insert_text = option.display.quote(p_quote_style);
			r_result.insert(option.display, option);