Repository: godotengine/godot (language: cpp)

Issue:
Godot4.4-dev5: `ClassDB` provides classes AnimationNodeStartState and AnimationNodeEndStatewhere which are not registered
### Tested versions

v4.4.dev5.mono.official [9e6098432]

### System information

all

### Issue description

I iterate over all classes provided by `ClassDB` for testing. Using `ClassDB:get_class_list()`
With Godot4.4.dev5 there is now “AnimationNodeStartState”, “AnimationNodeEndState” there are not documented and cannot be instantiated.

### Steps to reproduce

Can be verified by
```
extends Node

func _ready() -> void:
	prints("AnimationNodeStartState class_exists:", ClassDB.class_exists("AnimationNodeStartState"))
	prints("AnimationNodeStartState can_instantiate:", ClassDB.can_instantiate("AnimationNodeStartState"))

        # compile error
	AnimationNodeStartState.new()
```
output:
```
AnimationNodeStartState class_exists: true
AnimationNodeStartState can_instantiate: true
````
errors:
```
 res://test.gd:7 - Parse Error: Native class GDScriptNativeClass used in script doesn't exist or isn't exposed.
  res://test.gd:7 - Parse Error: Static function "new()" not found in base "GDScriptNativeClass".
```

### Minimal reproduction project (MRP)

n/a


Discussion / hints:
CC @TokageItLab @RandomShaper, see also #98963 which registered those classes as internal.
They are "currently" only used to make decisions to prevent editing, so I believe they can actually be replaced by the AnimationNode. However, they will need to be exposed again in the future when we allow additional ports (see also https://github.com/godotengine/godot/issues/88878#issuecomment-1966647736), but until then they are not necessary.
> output: 
> 
> ```
> AnimationNodeStartState class_exists: true
> AnimationNodeStartState can_instantiate: true
> ```

I feel like this indicates a bug somewhere. These classes are registered via `GDREGISTER_INTERNAL_CLASS()`, which I would have expected to make `can_instantiate()` return `false`

**UPDATE:** Did a little more poking around!

Internally, we use `ClassDB::_can_instantiate()` to check if we really can instantiate a class - this should return `true` for an internal class, because we need to be able to instantiate one for internal classes to work from GDExtension.

But, for the public `ClassDB::can_instantiate()` it would make logical sense to return `false` - but I'm not sure if that would maybe break something else somewhere? If it would, then maybe we need to add a `ClassDB::is_exposed()` function so its possible to check if a registered class is internal?

Fix patch:
diff --git a/scene/animation/animation_node_state_machine.cpp b/scene/animation/animation_node_state_machine.cpp
index 19acf8c1b161..1c4d489d6873 100644
--- a/scene/animation/animation_node_state_machine.cpp
+++ b/scene/animation/animation_node_state_machine.cpp
@@ -1322,7 +1322,8 @@ bool AnimationNodeStateMachine::are_ends_reset() const {
 
 bool AnimationNodeStateMachine::can_edit_node(const StringName &p_name) const {
 	if (states.has(p_name)) {
-		return !(states[p_name].node->is_class("AnimationNodeStartState") || states[p_name].node->is_class("AnimationNodeEndState"));
+		const AnimationNode *anode = states[p_name].node.ptr();
+		return !(Object::cast_to<AnimationNodeStartState>(anode) || Object::cast_to<AnimationNodeEndState>(anode));
 	}
 
 	return true;
diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp
index bf5e9954349d..a665fa90b8b6 100644
--- a/scene/register_scene_types.cpp
+++ b/scene/register_scene_types.cpp
@@ -523,9 +523,6 @@ void register_scene_types() {
 	GDREGISTER_CLASS(AnimationNodeStateMachinePlayback);
 	GDREGISTER_VIRTUAL_CLASS(AnimationNodeExtension);
 
-	GDREGISTER_INTERNAL_CLASS(AnimationNodeStartState);
-	GDREGISTER_INTERNAL_CLASS(AnimationNodeEndState);
-
 	GDREGISTER_CLASS(AnimationNodeSync);
 	GDREGISTER_CLASS(AnimationNodeStateMachineTransition);
 	GDREGISTER_CLASS(AnimationNodeOutput);


Test patch: