diff --git a/src/ComputeSharp.SourceGenerators/Extensions/SyntaxNodeExtensions.cs b/src/ComputeSharp.SourceGenerators/Extensions/SyntaxNodeExtensions.cs index 3023cb87..77831764 100644 --- a/src/ComputeSharp.SourceGenerators/Extensions/SyntaxNodeExtensions.cs +++ b/src/ComputeSharp.SourceGenerators/Extensions/SyntaxNodeExtensions.cs @@ -60,18 +60,16 @@ namespace ComputeSharp.SourceGenerators.Extensions } /// - /// Checks a value and replaces the value type to be HLSL compatible, if needed. + /// Tracks the associated type for a value and returns the HLSL compatible . /// - /// The type of the input instance. - /// The input to check and modify if needed. - /// The original node in the input source tree. + /// The input to check. /// The instance with info on the input tree. /// The collection of currently discovered types. /// A instance that represents a type compatible with HLSL. [Pure] - public static TypeSyntax ReplaceAndTrackType(this LiteralExpressionSyntax node, SyntaxNode sourceNode, SemanticModel semanticModel, ICollection discoveredTypes) + public static TypeSyntax TrackType(this SyntaxNode node, SemanticModel semanticModel, ICollection discoveredTypes) { - ITypeSymbol typeSymbol = semanticModel.GetTypeInfo(sourceNode).Type!; + ITypeSymbol typeSymbol = semanticModel.GetTypeInfo(node).Type!; string typeName = typeSymbol.ToDisplayString(ISymbolExtensions.FullyQualifiedWithoutGlobalFormat); discoveredTypes.Add((INamedTypeSymbol)typeSymbol); diff --git a/src/ComputeSharp.SourceGenerators/SyntaxRewriters/ShaderSourceRewriter.cs b/src/ComputeSharp.SourceGenerators/SyntaxRewriters/ShaderSourceRewriter.cs index 9503cfa2..d6f2a027 100644 --- a/src/ComputeSharp.SourceGenerators/SyntaxRewriters/ShaderSourceRewriter.cs +++ b/src/ComputeSharp.SourceGenerators/SyntaxRewriters/ShaderSourceRewriter.cs @@ -203,7 +203,7 @@ namespace ComputeSharp.SourceGenerators.SyntaxRewriters if (updatedNode.IsKind(SyntaxKind.DefaultLiteralExpression)) { - TypeSyntax type = updatedNode.ReplaceAndTrackType(node, this.semanticModel, this.discoveredTypes); + TypeSyntax type = node.TrackType(this.semanticModel, this.discoveredTypes); // Same HLSL-style expression in the form (T)0 return CastExpression(type, LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(0)));