diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/Sources/MustBeVariant.GD0301.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/Sources/MustBeVariant.GD0301.cs index 462da31d668..2b5eecab8a0 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/Sources/MustBeVariant.GD0301.cs +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/Sources/MustBeVariant.GD0301.cs @@ -66,6 +66,12 @@ public class MustBeVariantGD0301 Method(); } + public void MethodCallDynamic() + { + dynamic self = this; + self.Method(); + } + public void Method<[MustBeVariant] T>() { } diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/MustBeVariantAnalyzer.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/MustBeVariantAnalyzer.cs index 95eaca4d3d3..e894e7a86cf 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/MustBeVariantAnalyzer.cs +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/MustBeVariantAnalyzer.cs @@ -50,8 +50,18 @@ namespace Godot.SourceGenerators var typeSymbol = sm.GetSymbolInfo(typeSyntax).Symbol as ITypeSymbol; Helper.ThrowIfNull(typeSymbol); - var parentSymbol = sm.GetSymbolInfo(parentSyntax).Symbol; - Helper.ThrowIfNull(parentSymbol); + var parentSymbolInfo = sm.GetSymbolInfo(parentSyntax); + var parentSymbol = parentSymbolInfo.Symbol; + if (parentSymbol == null) + { + if (parentSymbolInfo.CandidateReason == CandidateReason.LateBound) + { + // Invocations on dynamic are late bound so we can't retrieve the symbol. + continue; + } + + Helper.ThrowIfNull(parentSymbol); + } if (!ShouldCheckTypeArgument(context, parentSyntax, parentSymbol, typeSyntax, typeSymbol, i)) {