Added support for out discard expressions

このコミットが含まれているのは:
Sergio Pedri committed 2020-12-02 14:49:12 +01:00
1 親 4d9e46060e
コミット 00f1b8d911
3ファイル変更
+42 -3

検索条件に一致するファイルはありません

+15 -1
ファイルの表示
@@ -348,7 +348,21 @@ namespace ComputeSharp.SourceGenerators.SyntaxRewriters
var updatedNode = (ArgumentSyntax)base.VisitArgument(node)!;
// Strip the ref keywords from arguments
return updatedNode.WithRefKindKeyword(Token(SyntaxKind.None));
updatedNode = updatedNode.WithRefKindKeyword(Token(SyntaxKind.None));
// Track and rewrite the discarded declaration
if (this.semanticModel.GetOperation(node.Expression) is IDiscardOperation operation)
{
TypeSyntax typeSyntax = operation.Type.TrackType(this.discoveredTypes);
string identifier = $"__implicit{this.implicitVariables.Count}";
// Add the variable to the list of implicit declarations
this.implicitVariables.Add(VariableDeclaration(typeSyntax).AddVariables(VariableDeclarator(identifier)));
return updatedNode.WithExpression(IdentifierName(identifier));
}
return updatedNode;
}
/// <inheritdoc/>