1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-08 12:40:44 +00:00

Merge pull request #107717 from aaronfranke/abstract-annotation

GDScript: Replace `abstract` keyword with `@abstract` annotation
This commit is contained in:
Rémi Verschelde
2025-06-27 17:12:56 +02:00
committed by GitHub
31 changed files with 179 additions and 197 deletions

View File

@@ -296,6 +296,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>