mirror of
https://github.com/godotengine/godot.git
synced 2025-11-01 06:01:14 +00:00
Fix shadowed global identifier warning duplication
This commit is contained in:
parent
6d58b968d5
commit
566895732c
3 changed files with 26 additions and 39 deletions
|
|
@ -3691,9 +3691,27 @@ bool GDScriptAnalyzer::validate_call_arg(const List<GDScriptParser::DataType> &p
|
|||
bool GDScriptAnalyzer::is_shadowing(GDScriptParser::IdentifierNode *p_local, const String &p_context) {
|
||||
const StringName &name = p_local->name;
|
||||
GDScriptParser::DataType base = parser->current_class->get_datatype();
|
||||
|
||||
GDScriptParser::ClassNode *base_class = base.class_type;
|
||||
|
||||
{
|
||||
List<MethodInfo> gdscript_funcs;
|
||||
GDScriptLanguage::get_singleton()->get_public_functions(&gdscript_funcs);
|
||||
|
||||
for (MethodInfo &info : gdscript_funcs) {
|
||||
if (info.name == name) {
|
||||
parser->push_warning(p_local, GDScriptWarning::SHADOWED_GLOBAL_IDENTIFIER, p_context, name, "built-in function");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (Variant::has_utility_function(name)) {
|
||||
parser->push_warning(p_local, GDScriptWarning::SHADOWED_GLOBAL_IDENTIFIER, p_context, name, "built-in function");
|
||||
return true;
|
||||
} else if (ClassDB::class_exists(name)) {
|
||||
parser->push_warning(p_local, GDScriptWarning::SHADOWED_GLOBAL_IDENTIFIER, p_context, name, "global class");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
while (base_class != nullptr) {
|
||||
if (base_class->has_member(name)) {
|
||||
parser->push_warning(p_local, GDScriptWarning::SHADOWED_VARIABLE, p_context, p_local->name, base_class->get_member(name).get_type_name(), itos(base_class->get_member(name).get_line()));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue