GDScript: Fix extending abstract classes, forbid their construction

This commit is contained in:
Dmitrii Maganov
2022-12-29 09:34:13 +02:00
parent e80cf3259e
commit 274d49790d
8 changed files with 54 additions and 12 deletions

View File

@@ -0,0 +1,2 @@
func test():
CanvasItem.new()

View File

@@ -0,0 +1,2 @@
GDTEST_ANALYZER_ERROR
Native class "CanvasItem" cannot be constructed as it is abstract.

View File

@@ -0,0 +1,9 @@
class A extends CanvasItem:
func _init():
print('no')
class B extends A:
pass
func test():
B.new()

View File

@@ -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".

View File

@@ -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')

View File

@@ -0,0 +1,2 @@
GDTEST_OK
ok