mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
GDScript: Don't allow @onready without inheriting Node
This commit is contained in:
parent
47c3e3b781
commit
3941af3d91
5 changed files with 19 additions and 0 deletions
|
@ -3611,6 +3611,10 @@ 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"))) {
|
||||
push_error(R"("@onready" can only be used in classes that inherit "Node".)", p_annotation);
|
||||
}
|
||||
|
||||
VariableNode *variable = static_cast<VariableNode *>(p_node);
|
||||
if (variable->onready) {
|
||||
push_error(R"("@onready" annotation can only be used once per variable.)");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue