GDScript: Replace abstract keyword with @abstract annotation

Co-authored-by: Danil Alexeev <dalexeev12@yandex.ru>
This commit is contained in:
Aaron Franke
2025-06-19 04:53:15 -07:00
parent 88b9932ce1
commit 1085200f51
31 changed files with 179 additions and 197 deletions

View File

@@ -1,15 +1,15 @@
abstract class AbstractClass:
abstract func some_func()
@abstract class AbstractClass:
@abstract func some_func()
class ImplementedClass extends AbstractClass:
func some_func():
pass
abstract class AbstractClassAgain extends ImplementedClass:
abstract func some_func()
@abstract class AbstractClassAgain extends ImplementedClass:
@abstract func some_func()
class Test1:
abstract func some_func()
@abstract func some_func()
class Test2 extends AbstractClass:
pass
@@ -24,5 +24,18 @@ class Test4 extends AbstractClass:
func other_func():
super.some_func()
@abstract class A:
@abstract @abstract func abstract_dup()
# An abstract function cannot have a body.
@abstract func abstract_bodyful():
pass
# A static function cannot be marked as `@abstract`.
@abstract static func abstract_stat()
@abstract @abstract class DuplicateAbstract:
pass
func test():
pass

View File

@@ -1,6 +1,11 @@
GDTEST_ANALYZER_ERROR
>> ERROR at line 11: Class "Test1" is not abstract but contains abstract methods. Mark the class as abstract or remove "abstract" from all methods in this class.
>> ERROR at line 14: Class "Test2" must implement "AbstractClass.some_func()" and other inherited abstract methods or be marked as abstract.
>> ERROR at line 17: Class "Test3" must implement "AbstractClassAgain.some_func()" and other inherited abstract methods or be marked as abstract.
>> ERROR at line 37: "@abstract" annotation can only be used once per class.
>> ERROR at line 28: "@abstract" annotation can only be used once per function.
>> ERROR at line 35: "@abstract" annotation cannot be applied to static functions.
>> ERROR at line 11: Class "Test1" is not abstract but contains abstract methods. Mark the class as "@abstract" or remove "@abstract" from all methods in this class.
>> ERROR at line 14: Class "Test2" must implement "AbstractClass.some_func()" and other inherited abstract methods or be marked as "@abstract".
>> ERROR at line 17: Class "Test3" must implement "AbstractClassAgain.some_func()" and other inherited abstract methods or be marked as "@abstract".
>> ERROR at line 22: Cannot call the parent class' abstract function "some_func()" because it hasn't been defined.
>> ERROR at line 25: Cannot call the parent class' abstract function "some_func()" because it hasn't been defined.
>> ERROR at line 32: Abstract function cannot have a body.
>> ERROR at line 35: A function must either have a ":" followed by a body, or be marked as "@abstract".

View File

@@ -2,7 +2,7 @@ extends RefCounted
const AbstractScript = preload("./construct_abstract_script.notest.gd")
abstract class AbstractClass:
@abstract class AbstractClass:
pass
func test():

View File

@@ -1 +1 @@
abstract class_name AbstractScript
@abstract class_name AbstractScript

View File

@@ -8,7 +8,7 @@ class B extends A:
class C extends CanvasItem:
pass
abstract class X:
@abstract class X:
pass
class Y extends X: