Browse Source

Merge pull request #84264 from HolonProduction/autocompletion-78003

Try to guess method return type even if subscript base has no value
Rémi Verschelde 8 months ago
parent
commit
632c77e10b

+ 1 - 1
modules/gdscript/gdscript_editor.cpp

@@ -1925,7 +1925,7 @@ static bool _guess_expression_type(GDScriptParser::CompletionContext &p_context,
 						}
 					}
 
-					if (!found && base.value.get_type() != Variant::NIL) {
+					if (!found) {
 						found = _guess_method_return_type_from_base(c, base, call->function_name, r_type);
 					}
 				}

+ 5 - 0
modules/gdscript/tests/scripts/completion/common/infer_return_type_without_value.cfg

@@ -0,0 +1,5 @@
+[output]
+include=[
+    ; String
+    {"display": "begins_with(…)"},
+]

+ 9 - 0
modules/gdscript/tests/scripts/completion/common/infer_return_type_without_value.gd

@@ -0,0 +1,9 @@
+class B:
+	func to_str(b: int):
+		return str(b)
+
+var a: B
+
+func _ready():
+	a.to_str(10).➡
+    pass