提交 0e3232c5 编写于 作者: H Heejae Chang 提交者: Jinu

made children not to return null and reorder children in evaluation o… (#22726)

* made children not to return null and reorder children in evaluation order

* added some verification

* fixed formatting

* fixed ordering

* removed temp variable.
上级 8187bb2d
...@@ -423,7 +423,7 @@ private IEventReferenceExpression CreateBoundEventAccessOperation(BoundEventAcce ...@@ -423,7 +423,7 @@ private IEventReferenceExpression CreateBoundEventAccessOperation(BoundEventAcce
ITypeSymbol type = boundEventAccess.Type; ITypeSymbol type = boundEventAccess.Type;
Optional<object> constantValue = ConvertToOptional(boundEventAccess.ConstantValue); Optional<object> constantValue = ConvertToOptional(boundEventAccess.ConstantValue);
bool isImplicit = boundEventAccess.WasCompilerGenerated; bool isImplicit = boundEventAccess.WasCompilerGenerated;
return new LazyEventReferenceExpression(@event, instance, _semanticModel, syntax, type, constantValue, isImplicit); return new LazyEventReferenceExpression(@event, instance, _semanticModel, syntax, type, constantValue, isImplicit);
} }
private IEventAssignmentExpression CreateBoundEventAssignmentOperatorOperation(BoundEventAssignmentOperator boundEventAssignmentOperator) private IEventAssignmentExpression CreateBoundEventAssignmentOperatorOperation(BoundEventAssignmentOperator boundEventAssignmentOperator)
...@@ -996,7 +996,7 @@ private IIncrementOrDecrementExpression CreateBoundIncrementOperatorOperation(Bo ...@@ -996,7 +996,7 @@ private IIncrementOrDecrementExpression CreateBoundIncrementOperatorOperation(Bo
private IInvalidExpression CreateBoundBadExpressionOperation(BoundBadExpression boundBadExpression) private IInvalidExpression CreateBoundBadExpressionOperation(BoundBadExpression boundBadExpression)
{ {
Lazy<ImmutableArray<IOperation>> children = new Lazy<ImmutableArray<IOperation>>(() => boundBadExpression.ChildBoundNodes.SelectAsArray(n => Create(n))); Lazy<ImmutableArray<IOperation>> children = new Lazy<ImmutableArray<IOperation>>(() => boundBadExpression.ChildBoundNodes.Select(n => Create(n)).WhereNotNull().ToImmutableArray());
SyntaxNode syntax = boundBadExpression.Syntax; SyntaxNode syntax = boundBadExpression.Syntax;
// We match semantic model here: if the expression IsMissing, we have a null type, rather than the ErrorType of the bound node. // We match semantic model here: if the expression IsMissing, we have a null type, rather than the ErrorType of the bound node.
ITypeSymbol type = syntax.IsMissing ? null : boundBadExpression.Type; ITypeSymbol type = syntax.IsMissing ? null : boundBadExpression.Type;
...@@ -1490,7 +1490,7 @@ private ILockStatement CreateBoundLockStatementOperation(BoundLockStatement boun ...@@ -1490,7 +1490,7 @@ private ILockStatement CreateBoundLockStatementOperation(BoundLockStatement boun
private IInvalidStatement CreateBoundBadStatementOperation(BoundBadStatement boundBadStatement) private IInvalidStatement CreateBoundBadStatementOperation(BoundBadStatement boundBadStatement)
{ {
Lazy<ImmutableArray<IOperation>> children = new Lazy<ImmutableArray<IOperation>>(() => boundBadStatement.ChildBoundNodes.SelectAsArray(n => Create(n))); Lazy<ImmutableArray<IOperation>> children = new Lazy<ImmutableArray<IOperation>>(() => boundBadStatement.ChildBoundNodes.Select(n => Create(n)).WhereNotNull().ToImmutableArray());
SyntaxNode syntax = boundBadStatement.Syntax; SyntaxNode syntax = boundBadStatement.Syntax;
ITypeSymbol type = null; ITypeSymbol type = null;
Optional<object> constantValue = default(Optional<object>); Optional<object> constantValue = default(Optional<object>);
......
...@@ -502,7 +502,8 @@ Namespace Microsoft.CodeAnalysis.Semantics ...@@ -502,7 +502,8 @@ Namespace Microsoft.CodeAnalysis.Semantics
End Function End Function
Private Function CreateBoundBadExpressionOperation(boundBadExpression As BoundBadExpression) As IInvalidExpression Private Function CreateBoundBadExpressionOperation(boundBadExpression As BoundBadExpression) As IInvalidExpression
Dim children As Lazy(Of ImmutableArray(Of IOperation)) = New Lazy(Of ImmutableArray(Of IOperation))(Function() boundBadExpression.ChildBoundNodes.SelectAsArray(Function(n) Create(n))) Dim children As Lazy(Of ImmutableArray(Of IOperation)) = New Lazy(Of ImmutableArray(Of IOperation))(
Function() boundBadExpression.ChildBoundNodes.Select(Function(n) Create(n)).WhereNotNull().ToImmutableArray())
Dim syntax As SyntaxNode = boundBadExpression.Syntax Dim syntax As SyntaxNode = boundBadExpression.Syntax
' We match semantic model here: If the Then expression IsMissing, we have a null type, rather than the ErrorType Of the bound node. ' We match semantic model here: If the Then expression IsMissing, we have a null type, rather than the ErrorType Of the bound node.
Dim type As ITypeSymbol = If(syntax.IsMissing, Nothing, boundBadExpression.Type) Dim type As ITypeSymbol = If(syntax.IsMissing, Nothing, boundBadExpression.Type)
......
...@@ -326,7 +326,9 @@ internal void VisitRefKindArrayElement(RefKind element) ...@@ -326,7 +326,9 @@ internal void VisitRefKindArrayElement(RefKind element)
private void VisitChildren(IOperation operation) private void VisitChildren(IOperation operation)
{ {
var children = operation.Children.WhereNotNull().ToImmutableArray(); Debug.Assert(operation.Children.All(o => o != null));
var children = operation.Children.ToImmutableArray();
if (!children.IsEmpty || operation.Kind != OperationKind.None) if (!children.IsEmpty || operation.Kind != OperationKind.None)
{ {
VisitArray(children, "Children", logElementCount: true); VisitArray(children, "Children", logElementCount: true);
...@@ -1315,7 +1317,7 @@ public override void VisitDynamicMemberReferenceExpression(IDynamicMemberReferen ...@@ -1315,7 +1317,7 @@ public override void VisitDynamicMemberReferenceExpression(IDynamicMemberReferen
LogString(")"); LogString(")");
LogCommonPropertiesAndNewLine(operation); LogCommonPropertiesAndNewLine(operation);
VisitArrayCommon(operation.TypeArguments, "Type Arguments", logElementCount: true,logNullForDefault: false, arrayElementVisitor: VisitSymbolArrayElement); VisitArrayCommon(operation.TypeArguments, "Type Arguments", logElementCount: true, logNullForDefault: false, arrayElementVisitor: VisitSymbolArrayElement);
VisitInstanceExpression(operation.Instance); VisitInstanceExpression(operation.Instance);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册