summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2022-12-11 15:18:24 +0100
committerRémi Verschelde <rverschelde@gmail.com>2022-12-11 15:18:24 +0100
commit05097ded0a915cd6c083f15dab08da2bdc0770b8 (patch)
treea8306c0e35644d76dbe470af204d53a0d2926aeb
parent185219de4ac108009c9fe14d36f7c061e63a9660 (diff)
parent1845d927dc41fe62417c50eab96fe1f26ee5f09a (diff)
Merge pull request #69897 from poohcom1/fix/function-return-completion
Fix autocomplete on functions returning variants
-rw-r--r--modules/gdscript/gdscript_editor.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp
index 693863ab38..79387d1bf6 100644
--- a/modules/gdscript/gdscript_editor.cpp
+++ b/modules/gdscript/gdscript_editor.cpp
@@ -2272,6 +2272,11 @@ static bool _guess_method_return_type_from_base(GDScriptParser::CompletionContex
if (base_type.class_type->has_function(p_method)) {
const GDScriptParser::FunctionNode *method = base_type.class_type->get_member(p_method).function;
if (!is_static || method->is_static) {
+ if (method->get_datatype().is_set() && !method->get_datatype().is_variant()) {
+ r_type.type = method->get_datatype();
+ return true;
+ }
+
int last_return_line = -1;
const GDScriptParser::ExpressionNode *last_returned_value = nullptr;
GDScriptParser::CompletionContext c = p_context;
@@ -2285,10 +2290,6 @@ static bool _guess_method_return_type_from_base(GDScriptParser::CompletionContex
if (_guess_expression_type(c, last_returned_value, r_type)) {
return true;
}
- if (method->get_datatype().is_set() && !method->get_datatype().is_variant()) {
- r_type.type = method->get_datatype();
- return true;
- }
}
}
}