Browse Source

Merge pull request #78533 from anvilfolk/sadrevert

GDScript: fix regression when checking for virtual function implementation
Rémi Verschelde 2 năm trước cách đây
mục cha
commit
81a0199be4

+ 0 - 10
modules/gdscript/gdscript_analyzer.cpp

@@ -3097,16 +3097,6 @@ void GDScriptAnalyzer::reduce_call(GDScriptParser::CallNode *p_call, bool p_is_a
 	bool is_constructor = (base_type.is_meta_type || (p_call->callee && p_call->callee->type == GDScriptParser::Node::IDENTIFIER)) && p_call->function_name == SNAME("new");
 
 	if (get_function_signature(p_call, is_constructor, base_type, p_call->function_name, return_type, par_types, default_arg_count, method_flags)) {
-		// If the method is implemented in the class hierarchy, the virtual flag will not be set for that MethodInfo and the search stops there.
-		// MethodInfo's above the class that defines the method might still have the virtual flag set.
-		if (method_flags.has_flag(METHOD_FLAG_VIRTUAL)) {
-			if (p_call->is_super) {
-				push_error(vformat(R"*(Cannot call the parent class' virtual function "%s()" because it hasn't been defined.)*", p_call->function_name), p_call);
-			} else {
-				push_error(vformat(R"*(Cannot call virtual function "%s()" because it hasn't been defined.)*", p_call->function_name), p_call);
-			}
-		}
-
 		// If the function require typed arrays we must make literals be typed.
 		for (const KeyValue<int, GDScriptParser::ArrayNode *> &E : arrays) {
 			int index = E.key;

+ 0 - 2
modules/gdscript/tests/scripts/analyzer/errors/virtual_method_not_implemented.gd

@@ -1,2 +0,0 @@
-func test():
-	_get_property_list()

+ 0 - 2
modules/gdscript/tests/scripts/analyzer/errors/virtual_method_not_implemented.out

@@ -1,2 +0,0 @@
-GDTEST_ANALYZER_ERROR
-Cannot call virtual function "_get_property_list()" because it hasn't been defined.

+ 0 - 5
modules/gdscript/tests/scripts/analyzer/errors/virtual_super_not_implemented.gd

@@ -1,5 +0,0 @@
-func _init():
-	super()
-
-func test():
-	pass

+ 0 - 2
modules/gdscript/tests/scripts/analyzer/errors/virtual_super_not_implemented.out

@@ -1,2 +0,0 @@
-GDTEST_ANALYZER_ERROR
-Cannot call the parent class' virtual function "_init()" because it hasn't been defined.

+ 0 - 11
modules/gdscript/tests/scripts/analyzer/features/virtual_method_implemented.gd

@@ -1,11 +0,0 @@
-class TestOne:
-	func _get_property_list():
-		return {}
-
-class TestTwo extends TestOne:
-	func _init():
-		var _x = _get_property_list()
-
-func test():
-	var x = TestTwo.new()
-	var _x = x._get_property_list()

+ 0 - 1
modules/gdscript/tests/scripts/analyzer/features/virtual_method_implemented.out

@@ -1 +0,0 @@
-GDTEST_OK

+ 0 - 10
modules/gdscript/tests/scripts/analyzer/features/virtual_super_implemented.gd

@@ -1,10 +0,0 @@
-class TestOne:
-	func _init():
-		pass
-
-class TestTwo extends TestOne:
-	func _init():
-		super()
-
-func test():
-	pass

+ 0 - 1
modules/gdscript/tests/scripts/analyzer/features/virtual_super_implemented.out

@@ -1 +0,0 @@
-GDTEST_OK