modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/Sources/MustBeVariant.GD0302.cs
raw symbols SCIP| 1 | using Godot; |
| 2 | |
| 3 | public class MustBeVariantGD0302 |
| 4 | { |
| 5 | public void MethodOk<[MustBeVariant] T>() |
| 6 | { |
| 7 | // T is guaranteed to be a Variant-compatible type because it's annotated with the [MustBeVariant] attribute, so it can be used here. |
| 8 | new ExampleClass<T>(); |
| 9 | Method<T>(); |
| 10 | } |
| 11 | |
| 12 | public void MethodFail<T>() |
| 13 | { |
| 14 | // These two calls raise a GD0302 diagnostic error: T is not valid here because it may not a Variant type and method call and class require it. |
| 15 | new ExampleClass<{|GD0302:T|}>(); |
| 16 | Method<{|GD0302:T|}>(); |
| 17 | } |
| 18 | |
| 19 | public void Method<[MustBeVariant] T>() |
| 20 | { |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | public class ExampleClass<[MustBeVariant] T> |
| 25 | { |
| 26 | |
| 27 | } |