未验证 提交 7fcd3b3d 编写于 作者: A AlekseyTs 提交者: GitHub

Report use-site diagnostics in BindWithExpression (#45664)

上级 d59a2b34
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
......@@ -25,8 +25,6 @@ private BoundExpression BindWithExpression(WithExpressionSyntax syntax, Diagnost
var receiverType = receiver.Type;
var lookupResult = LookupResult.GetInstance();
HashSet<DiagnosticInfo>? useSiteDiagnostics = null;
bool hasErrors = false;
if (receiverType is null || receiverType.IsVoidType())
......@@ -38,6 +36,8 @@ private BoundExpression BindWithExpression(WithExpressionSyntax syntax, Diagnost
MethodSymbol? cloneMethod = null;
if (!receiverType.IsErrorType())
{
HashSet<DiagnosticInfo>? useSiteDiagnostics = null;
LookupMembersInType(
lookupResult,
receiverType,
......@@ -69,10 +69,11 @@ private BoundExpression BindWithExpression(WithExpressionSyntax syntax, Diagnost
TypeCompareKind.ConsiderEverything,
ref useSiteDiagnostics))
{
useSiteDiagnostics = null;
hasErrors = true;
diagnostics.Add(ErrorCode.ERR_NoSingleCloneMethod, syntax.Expression.Location, receiverType);
}
diagnostics.Add(syntax.Expression, useSiteDiagnostics);
}
var initializer = BindInitializerExpression(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册