mirror of
https://github.com/godotengine/godot.git
synced 2026-01-05 06:11:29 +03:00
GDScript: Fix extending abstract classes, forbid their construction
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user