Merge pull request #70700 from vonagam/fix-abstract-extends

GDScript: Fix extending abstract classes, forbid their construction
This commit is contained in:
Rémi Verschelde
2023-01-12 17:19:51 +01:00
8 changed files with 54 additions and 12 deletions
@@ -0,0 +1,2 @@
func test():
CanvasItem.new()
@@ -0,0 +1,2 @@
GDTEST_ANALYZER_ERROR
Native class "CanvasItem" cannot be constructed as it is abstract.
@@ -0,0 +1,9 @@
class A extends CanvasItem:
func _init():
print('no')
class B extends A:
pass
func test():
B.new()
@@ -0,0 +1,2 @@
GDTEST_ANALYZER_ERROR
Class "abstract_script_instantiate.gd::B" cannot be constructed as it is based on abstract native class "CanvasItem".
@@ -0,0 +1,12 @@
class A extends CanvasItem:
func _init():
pass
class B extends A:
pass
class C extends CanvasItem:
pass
func test():
print('ok')
@@ -0,0 +1,2 @@
GDTEST_OK
ok