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

@@ -295,6 +295,27 @@
</constant>
</constants>
<annotations>
<annotation name="@abstract">
<return type="void" />
<description>
Marks a class or a method as abstract.
An abstract class is a class that cannot be instantiated directly. Instead, it is meant to be inherited by other classes. Attempting to instantiate an abstract class will result in an error.
An abstract method is a method that has no implementation. Therefore, a newline or a semicolon is expected after the function header. This defines a contract that inheriting classes must conform to, because the method signature must be compatible when overriding.
Inheriting classes must either provide implementations for all abstract methods, or the inheriting class must be marked as abstract. If a class has at least one abstract method (either its own or an unimplemented inherited one), then it must also be marked as abstract. However, the reverse is not true: an abstract class is allowed to have no abstract methods.
[codeblock]
@abstract class Shape:
@abstract func draw()
class Circle extends Shape:
func draw():
print("Drawing a circle.")
class Square extends Shape:
func draw():
print("Drawing a square.")
[/codeblock]
</description>
</annotation>
<annotation name="@export">
<return type="void" />
<description>