Annotate BoundNodeExtensions.

上级 04a9ad4f
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#nullable enable
using System.Collections.Immutable;
using System.Diagnostics;
......@@ -27,7 +28,7 @@ public static bool HasErrors<T>(this ImmutableArray<T> nodeArray)
}
// Like HasErrors property, but also returns false for a null node.
public static bool HasErrors(this BoundNode node)
public static bool HasErrors(this BoundNode? node)
{
return node != null && node.HasErrors;
}
......@@ -35,7 +36,7 @@ public static bool HasErrors(this BoundNode node)
public static bool IsConstructorInitializer(this BoundStatement statement)
{
Debug.Assert(statement != null);
if (statement.Kind == BoundKind.ExpressionStatement)
if (statement!.Kind == BoundKind.ExpressionStatement)
{
BoundExpression expression = ((BoundExpressionStatement)statement).Expression;
if (expression.Kind == BoundKind.Sequence && ((BoundSequence)expression).SideEffects.IsDefaultOrEmpty)
......@@ -53,8 +54,8 @@ public static bool IsConstructorInitializer(this BoundStatement statement)
public static bool IsConstructorInitializer(this BoundCall call)
{
Debug.Assert(call != null);
MethodSymbol method = call.Method;
BoundExpression receiverOpt = call.ReceiverOpt;
MethodSymbol method = call!.Method;
BoundExpression? receiverOpt = call!.ReceiverOpt;
return method.MethodKind == MethodKind.Constructor &&
receiverOpt != null &&
(receiverOpt.Kind == BoundKind.ThisReference || receiverOpt.Kind == BoundKind.BaseReference);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册