mirror of
https://github.com/godotengine/godot.git
synced 2025-01-23 19:12:24 -05:00
Merge pull request #72804 from vnen/gdscript-no-onready-without-node
GDScript: Fix inheritance check of @onready for inner classes
This commit is contained in:
commit
7b86a082be
5 changed files with 19 additions and 1 deletions
|
@ -3619,7 +3619,7 @@ bool GDScriptParser::icon_annotation(const AnnotationNode *p_annotation, Node *p
|
|||
bool GDScriptParser::onready_annotation(const AnnotationNode *p_annotation, Node *p_node) {
|
||||
ERR_FAIL_COND_V_MSG(p_node->type != Node::VARIABLE, false, R"("@onready" annotation can only be applied to class variables.)");
|
||||
|
||||
if (head && !ClassDB::is_parent_class(head->get_datatype().native_type, SNAME("Node"))) {
|
||||
if (current_class && !ClassDB::is_parent_class(current_class->get_datatype().native_type, SNAME("Node"))) {
|
||||
push_error(R"("@onready" can only be used in classes that inherit "Node".)", p_annotation);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
extends Node
|
||||
|
||||
class Inner extends RefCounted:
|
||||
@onready var nope = 0
|
||||
|
||||
func test():
|
||||
print("Cannot use @onready without a Node base")
|
|
@ -0,0 +1,2 @@
|
|||
GDTEST_ANALYZER_ERROR
|
||||
"@onready" can only be used in classes that inherit "Node".
|
|
@ -0,0 +1,7 @@
|
|||
extends RefCounted
|
||||
|
||||
func test():
|
||||
print("ok")
|
||||
|
||||
class Inner extends Node:
|
||||
@onready var okay = 0
|
|
@ -0,0 +1,2 @@
|
|||
GDTEST_OK
|
||||
ok
|
Loading…
Add table
Reference in a new issue