Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
GD0402: The class must not be generic¶
规则 ID |
GD0402 |
类别 |
用法 |
修复是中断修复还是非中断修复 |
中断 |
默认启用 |
是 |
原因¶
A generic type is annotated with the [GlobalClass] attribute.
规则说明¶
The Godot editor assumes every global class is instantiable, but generic types can't be instantiated because the type parameters 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> { }
如何解决冲突¶
To fix a violation of this rule, change the type to remove the generic type parameters
or remove the [GlobalClass] attribute.
何时禁止显示警告¶
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.