Merge pull request #62760 from cdemirer/fix-annotation-initializer-conflict
Fix priority of annotated type vs initializer type
This commit is contained in:
commit
4873886830
2 changed files with 34 additions and 34 deletions
|
@ -655,7 +655,8 @@ void GDScriptAnalyzer::resolve_class_interface(GDScriptParser::ClassNode *p_clas
|
|||
} else {
|
||||
ERR_PRINT("Parser bug (please report): tried to assign unset node without an identifier.");
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
if (member.variable->datatype_specifier != nullptr) {
|
||||
datatype = specified_type;
|
||||
|
||||
|
@ -692,7 +693,6 @@ void GDScriptAnalyzer::resolve_class_interface(GDScriptParser::ClassNode *p_clas
|
|||
}
|
||||
datatype.type_source = GDScriptParser::DataType::ANNOTATED_INFERRED;
|
||||
}
|
||||
}
|
||||
|
||||
datatype.is_constant = false;
|
||||
member.variable->set_datatype(datatype);
|
||||
|
|
|
@ -2040,7 +2040,10 @@ static bool _guess_identifier_type_from_base(GDScriptParser::CompletionContext &
|
|||
return true;
|
||||
case GDScriptParser::ClassNode::Member::VARIABLE:
|
||||
if (!is_static) {
|
||||
if (member.variable->initializer) {
|
||||
if (member.variable->get_datatype().is_set() && !member.variable->get_datatype().is_variant()) {
|
||||
r_type.type = member.variable->get_datatype();
|
||||
return true;
|
||||
} else if (member.variable->initializer) {
|
||||
const GDScriptParser::ExpressionNode *init = member.variable->initializer;
|
||||
if (init->is_constant) {
|
||||
r_type.value = init->reduced_value;
|
||||
|
@ -2062,9 +2065,6 @@ static bool _guess_identifier_type_from_base(GDScriptParser::CompletionContext &
|
|||
r_type.type = init->get_datatype();
|
||||
return true;
|
||||
}
|
||||
} else if (member.variable->get_datatype().is_set() && !member.variable->get_datatype().is_variant()) {
|
||||
r_type.type = member.variable->get_datatype();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// TODO: Check assignments in constructor.
|
||||
|
|
Loading…
Reference in a new issue