diff options
| author | Rémi Verschelde <rverschelde@gmail.com> | 2024-10-02 15:00:42 +0200 |
|---|---|---|
| committer | Rémi Verschelde <rverschelde@gmail.com> | 2024-10-02 15:00:42 +0200 |
| commit | 7f1f9799c5955af4e29ecb7d4d3d765ad36f5beb (patch) | |
| tree | dcec8debf6edb050c867fbe4d6e812624a46457e /modules | |
| parent | b070f4a49d3309c4fdd36ecb5da9084137f24246 (diff) | |
| parent | 9a84387017fe7921954107d16a69a54ff54556f6 (diff) | |
| download | redot-engine-7f1f9799c5955af4e29ecb7d4d3d765ad36f5beb.tar.gz | |
Merge pull request #92263 from HolonProduction/autocompletion-get-node-set-value-if-type-compatible
Autocompletion: Keep `get_node` values which are compatible with type hint
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/gdscript/gdscript_editor.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp index 73f2b1d618..8fc5c7fa23 100644 --- a/modules/gdscript/gdscript_editor.cpp +++ b/modules/gdscript/gdscript_editor.cpp @@ -2975,11 +2975,6 @@ static bool _get_subscript_type(GDScriptParser::CompletionContext &p_context, co } break; case GDScriptParser::Node::IDENTIFIER: { - if (p_subscript->base->datatype.type_source == GDScriptParser::DataType::ANNOTATED_EXPLICIT) { - // Annotated type takes precedence. - return false; - } - const GDScriptParser::IdentifierNode *identifier_node = static_cast<GDScriptParser::IdentifierNode *>(p_subscript->base); switch (identifier_node->source) { @@ -3017,6 +3012,14 @@ static bool _get_subscript_type(GDScriptParser::CompletionContext &p_context, co if (get_node != nullptr) { const Object *node = p_context.base->call("get_node_or_null", NodePath(get_node->full_path)); if (node != nullptr) { + GDScriptParser::DataType assigned_type = _type_from_variant(node, p_context).type; + GDScriptParser::DataType base_type = p_subscript->base->datatype; + + if (p_subscript->base->type == GDScriptParser::Node::IDENTIFIER && base_type.type_source == GDScriptParser::DataType::ANNOTATED_EXPLICIT && (assigned_type.kind != base_type.kind || assigned_type.script_path != base_type.script_path || assigned_type.native_type != base_type.native_type)) { + // Annotated type takes precedence. + return false; + } + if (r_base != nullptr) { *r_base = node; } |
