提交 4094ee44 编写于 作者: H Heejae Chang

PR feedbacks.

reverted encoding only changes
marked as implicit for expression statement that doesn't point to expression syntax node
added tracking bug in the comment
上级 90715eea
......@@ -1381,7 +1381,11 @@ private IExpressionStatement CreateBoundExpressionStatementOperation(BoundExpres
SyntaxNode syntax = boundExpressionStatement.Syntax;
ITypeSymbol type = null;
Optional<object> constantValue = default(Optional<object>);
bool isImplicit = boundExpressionStatement.WasCompilerGenerated;
// lambda body can point to expression directly and binder can insert exression statement there. and end up statement pointing to
// expression syntax node since there is no statement syntax node to point to. this will mark such one as implicit since it doesn't
// actually exist in code
bool isImplicit = boundExpressionStatement.WasCompilerGenerated || !boundExpressionStatement.Syntax.IsKind(SyntaxKind.ExpressionStatement);
return new LazyExpressionStatement(expression, _semanticModel, syntax, type, constantValue, isImplicit);
}
......
......@@ -60,7 +60,7 @@ class Program
{
static void Main(string[] args)
{
Action x = /*<bind>*/() => F();/*</bind>*/
Action x = /*<bind>*/() => F()/*</bind>*/;
}
static void F()
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Test.Utilities;
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.CSharp.Test.Utilities;
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.CodeAnalysis.CSharp.Syntax;
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Linq;
using Microsoft.CodeAnalysis.CSharp.Syntax;
......@@ -2935,8 +2935,7 @@ static void Main()
}
";
string expectedOperationTree = @"
IExpressionStatement (OperationKind.ExpressionStatement, IsInvalid) (Syntax: 'new C { 1 }')
Expression: IObjectCreationExpression (Constructor: C..ctor()) (OperationKind.ObjectCreationExpression, Type: C, IsInvalid) (Syntax: 'new C { 1 }')
IObjectCreationExpression (Constructor: C..ctor()) (OperationKind.ObjectCreationExpression, Type: C, IsInvalid) (Syntax: 'new C { 1 }')
Arguments(0)
Initializer: IObjectOrCollectionInitializerExpression (OperationKind.ObjectOrCollectionInitializerExpression, Type: C, IsInvalid) (Syntax: '{ 1 }')
Initializers(1):
......
......@@ -1070,6 +1070,11 @@ private static void VerifyModelForOutVarInNotExecutableCode(SemanticModel model,
private static void AssertTypeFromOperation(SemanticModel model, TypeSymbol expectedType, DeclarationExpressionSyntax decl)
{
// see https://github.com/dotnet/roslyn/issues/22175 for more detail.
// unlike GetSymbolInfo or GetTypeInfo, GetOperation doesn't use SemanticModel's recovery mode.
// what that means is that GetOperation might return null for ones GetSymbol/GetTypeInfo do return info from
// error recovery mode
var variableDeclarator = decl.Ancestors().OfType<VariableDeclaratorSyntax>().FirstOrDefault();
if (variableDeclarator?.ArgumentList?.FullSpan.Contains(decl.Span) == true)
{
......@@ -795,6 +795,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Friend Overrides Function GetOperationWorker(node As VisualBasicSyntaxNode, cancellationToken As CancellationToken) As IOperation
' see whether we can bind smaller scope than GetBindingRoot to make perf better
' https://github.com/dotnet/roslyn/issues/22176
Dim bindingRoot = DirectCast(GetBindingRoot(node), VisualBasicSyntaxNode)
Dim statementOrRootOperation As IOperation = GetStatementOrRootOperation(bindingRoot, cancellationToken)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册