提交 c3e89aed 编写于 作者: H Heejae Chang

added null check

上级 a51c2509
// 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;
using System.Collections.Generic;
......@@ -13,7 +13,7 @@ namespace Microsoft.CodeAnalysis.Semantics
internal abstract partial class BaseAddressOfExpression : Operation, IAddressOfExpression
{
protected BaseAddressOfExpression(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue) :
base(OperationKind.AddressOfExpression, semanticModel, syntax, type, constantValue)
base(OperationKind.AddressOfExpression, semanticModel, syntax, type, constantValue)
{
}
......
......@@ -97,7 +97,8 @@ public static IOperation CreateOperationNone(SemanticModel semanticModel, Syntax
public static T SetParentOperation<T>(T operation, IOperation parent) where T : IOperation
{
(operation as Operation).SetParentOperation(parent);
// operation can be null
(operation as Operation)?.SetParentOperation(parent);
return operation;
}
......@@ -154,7 +155,8 @@ public override void Accept(OperationVisitor visitor)
{
void EnqueueChildOperations(Queue<IOperation> queue, IOperation parent)
{
foreach (var o in parent.Children)
// children can return null
foreach (var o in parent.Children.WhereNotNull())
{
queue.Enqueue(o);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册