You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-12 13:20:55 +00:00
GDScript: Add check for super() methods not being implemented
(cherry picked from commit 729c9b4d4b)
This commit is contained in:
committed by
Yuri Sizov
parent
e0221d1c09
commit
2beec2b00f
@@ -0,0 +1,5 @@
|
||||
func _init():
|
||||
super()
|
||||
|
||||
func test():
|
||||
pass
|
||||
@@ -0,0 +1,2 @@
|
||||
GDTEST_ANALYZER_ERROR
|
||||
Cannot call the parent class' virtual function "_init()" because it hasn't been defined.
|
||||
@@ -0,0 +1,21 @@
|
||||
class BaseClass:
|
||||
func _get_property_list():
|
||||
return {"property" : "definition"}
|
||||
|
||||
class SuperClassMethodsRecognized extends BaseClass:
|
||||
func _init():
|
||||
# Recognizes super class methods.
|
||||
var _x = _get_property_list()
|
||||
|
||||
class SuperMethodsRecognized extends BaseClass:
|
||||
func _get_property_list():
|
||||
# Recognizes super method.
|
||||
var result = super()
|
||||
result["new"] = "new"
|
||||
return result
|
||||
|
||||
func test():
|
||||
var test1 = SuperClassMethodsRecognized.new()
|
||||
print(test1._get_property_list()) # Calls base class's method.
|
||||
var test2 = SuperMethodsRecognized.new()
|
||||
print(test2._get_property_list())
|
||||
@@ -0,0 +1,3 @@
|
||||
GDTEST_OK
|
||||
{ "property": "definition" }
|
||||
{ "property": "definition", "new": "new" }
|
||||
Reference in New Issue
Block a user