From 173101077485a6d4828a1600674de80946208100 Mon Sep 17 00:00:00 2001 From: George Marques Date: Tue, 21 Feb 2023 14:37:08 -0300 Subject: [PATCH] GDScript: Fix override signature check of script inheritance Avoid treating the super class as a meta type for signature check, since it is looking at the instance level for that. --- modules/gdscript/gdscript_analyzer.cpp | 1 + .../features/inheritance_signature_check_no_meta.gd | 10 ++++++++++ .../features/inheritance_signature_check_no_meta.out | 2 ++ 3 files changed, 13 insertions(+) create mode 100644 modules/gdscript/tests/scripts/analyzer/features/inheritance_signature_check_no_meta.gd create mode 100644 modules/gdscript/tests/scripts/analyzer/features/inheritance_signature_check_no_meta.out diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cpp index 38f9163f700..f1300207069 100644 --- a/modules/gdscript/gdscript_analyzer.cpp +++ b/modules/gdscript/gdscript_analyzer.cpp @@ -1534,6 +1534,7 @@ void GDScriptAnalyzer::resolve_function_signature(GDScriptParser::FunctionNode * // Check if the function signature matches the parent. If not it's an error since it breaks polymorphism. // Not for the constructor which can vary in signature. GDScriptParser::DataType base_type = parser->current_class->base_type; + base_type.is_meta_type = false; GDScriptParser::DataType parent_return_type; List parameters_types; int default_par_count = 0; diff --git a/modules/gdscript/tests/scripts/analyzer/features/inheritance_signature_check_no_meta.gd b/modules/gdscript/tests/scripts/analyzer/features/inheritance_signature_check_no_meta.gd new file mode 100644 index 00000000000..6c056530f65 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/features/inheritance_signature_check_no_meta.gd @@ -0,0 +1,10 @@ +func test(): + print("ok") + +# https://github.com/godotengine/godot/issues/71994 +class A: + extends RefCounted +class B: + extends A + func duplicate(): + pass diff --git a/modules/gdscript/tests/scripts/analyzer/features/inheritance_signature_check_no_meta.out b/modules/gdscript/tests/scripts/analyzer/features/inheritance_signature_check_no_meta.out new file mode 100644 index 00000000000..1b47ed10dc0 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/features/inheritance_signature_check_no_meta.out @@ -0,0 +1,2 @@ +GDTEST_OK +ok