Up to date
This page is up to date for Godot 4.2
.
If you still find outdated information, please open an issue.
GD0402: The class must not contain generic arguments¶
Regel-ID |
GD0402 |
Kategorie |
Verwendung |
Breaking- oder nicht-Breaking-Fix |
Breaking |
Standardmäßig aktiviert |
Ja |
Ursache¶
A generic type is annotated with the [GlobalClass]
attribute.
Beschreibung der Regel¶
The Godot editor assumes every global class is instantiable, but generic types can't be instantiated because the type arguments are unbound.
// This type is a valid global class because it's not generic.
[GlobalClass]
class SomeType : Node { }
// This type is not a valid global class because it's generic.
[GlobalClass]
class SomeGenericType<T> { }
Wie man Verstöße behebt¶
To fix a violation of this rule, change the type to remove the generic type parameters
or remove the [GlobalClass]
attribute.
Wann Warnungen unterdrückt werden sollten¶
Do not suppress a warning from this rule. Adding the [GlobalClass]
to a
generic type is an easy mistake to make and this warning helps users realize
that it may result in unexpected errors.