Fixed type mapping for return types
このコミットが含まれているのは:
1 親
97d023387d
コミット
ab43075351
3ファイル変更
+33
-1
検索条件に一致するファイルはありません
@@ -58,6 +58,12 @@ namespace ComputeSharp.SourceGenerators.Extensions
|
||||
_ => semanticModel.GetTypeInfo(sourceType).Type!
|
||||
};
|
||||
|
||||
// Do nothing if the type is just void
|
||||
if (typeSymbol.SpecialType == SpecialType.System_Void)
|
||||
{
|
||||
return node;
|
||||
}
|
||||
|
||||
string typeName = typeSymbol.ToDisplayString(ISymbolExtensions.FullyQualifiedWithoutGlobalFormat);
|
||||
|
||||
discoveredTypes.Add((INamedTypeSymbol)typeSymbol);
|
||||
|
||||
@@ -153,7 +153,9 @@ namespace ComputeSharp.SourceGenerators.SyntaxRewriters
|
||||
{
|
||||
this.currentMethod = node;
|
||||
|
||||
var updatedNode = (MethodDeclarationSyntax?)base.Visit(node);
|
||||
var updatedNode = (MethodDeclarationSyntax?)base.Visit(node)!;
|
||||
|
||||
updatedNode = updatedNode.ReplaceAndTrackType(updatedNode.ReturnType, node!.ReturnType, this.semanticModel, this.discoveredTypes);
|
||||
|
||||
if (node!.Modifiers.Any(m => m.IsKind(SyntaxKind.AsyncKeyword)))
|
||||
{
|
||||
@@ -358,6 +360,8 @@ namespace ComputeSharp.SourceGenerators.SyntaxRewriters
|
||||
.WithAttributeLists(List<AttributeListSyntax>())
|
||||
.WithIdentifier(Identifier($"__{this.currentMethod!.Identifier.Text}__{node.Identifier.Text}"));
|
||||
|
||||
updatedNode = updatedNode.ReplaceAndTrackType(updatedNode.ReturnType, node!.ReturnType, this.semanticModel, this.discoveredTypes);
|
||||
|
||||
if (node.Modifiers.Any(m => m.IsKind(SyntaxKind.AsyncKeyword)))
|
||||
{
|
||||
this.context.ReportDiagnostic(AsyncModifierOnMethodOrFunction, node);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Threading;
|
||||
using ComputeSharp.Interop;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
@@ -27,5 +28,26 @@ namespace ComputeSharp.Tests
|
||||
row_major[ThreadIds.X] = log / dword;
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SpecialTypeAsReturnType()
|
||||
{
|
||||
ReflectionServices.GetShaderInfo<FloatReturnType>(out _);
|
||||
}
|
||||
|
||||
[AutoConstructor]
|
||||
public readonly partial struct FloatReturnType : IComputeShader
|
||||
{
|
||||
public readonly ReadWriteBuffer<Float2> buffer;
|
||||
|
||||
Float2 Foo(float x) => x;
|
||||
|
||||
public void Execute()
|
||||
{
|
||||
static Float3 Bar(float x) => x;
|
||||
|
||||
buffer[ThreadIds.X] = Foo(ThreadIds.X) + Bar(ThreadIds.X).XY;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする