mirror of
https://github.com/godotengine/godot.git
synced 2025-11-01 14:11:15 +00:00
Autocompletion: Fix type resolution when assigning variant
This commit is contained in:
parent
019ab8745f
commit
242b5efd9d
3 changed files with 13 additions and 1 deletions
|
|
@ -1640,6 +1640,8 @@ static GDScriptCompletionIdentifier _type_from_property(const PropertyInfo &p_pr
|
|||
|
||||
if (p_property.type == Variant::NIL) {
|
||||
// Variant
|
||||
ci.type.type_source = GDScriptParser::DataType::ANNOTATED_EXPLICIT;
|
||||
ci.type.kind = GDScriptParser::DataType::VARIANT;
|
||||
return ci;
|
||||
}
|
||||
|
||||
|
|
@ -2338,7 +2340,7 @@ static bool _guess_identifier_type(GDScriptParser::CompletionContext &p_context,
|
|||
c.current_line = last_assign_line;
|
||||
GDScriptCompletionIdentifier assigned_type;
|
||||
if (_guess_expression_type(c, last_assigned_expression, assigned_type)) {
|
||||
if (id_type.type.is_set() && assigned_type.type.is_set() && !GDScriptAnalyzer::check_type_compatibility(id_type.type, assigned_type.type)) {
|
||||
if (id_type.type.is_set() && (assigned_type.type.kind == GDScriptParser::DataType::VARIANT || (assigned_type.type.is_set() && !GDScriptAnalyzer::check_type_compatibility(id_type.type, assigned_type.type)))) {
|
||||
// The assigned type is incompatible. The annotated type takes priority.
|
||||
r_type = id_type;
|
||||
r_type.assigned_expression = last_assigned_expression;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
[output]
|
||||
include=[
|
||||
; PackedScene
|
||||
{"display": "instantiate(…)"},
|
||||
]
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
var list: Array
|
||||
|
||||
func spawn_npc() -> void:
|
||||
var scene: PackedScene = list.pick_random()
|
||||
scene.➡
|
||||
Loading…
Add table
Add a link
Reference in a new issue