Skip to content

Commit 90220cc

Browse files
Use null-conditional check instead of ?? new DiagnosticBag()
Co-authored-by: CyrusNajmabadi <4564579+CyrusNajmabadi@users.noreply.github.com>
1 parent b62a860 commit 90220cc

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/Compilers/CSharp/Portable/Binder/Binder_Statements.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,10 @@ private BoundStatement BindDeclarationStatementParts(LocalDeclarationStatementSy
709709
// Check for duplicate modifiers in local declarations.
710710
// We call ToDeclarationModifiers here only to report duplicate modifier errors.
711711
// The actual modifier (const) is determined by node.IsConst below.
712-
_ = node.Modifiers.ToDeclarationModifiers(isForTypeDeclaration: false, diagnostics.DiagnosticBag ?? new DiagnosticBag());
712+
if (diagnostics.DiagnosticBag is { } bag)
713+
{
714+
_ = node.Modifiers.ToDeclarationModifiers(isForTypeDeclaration: false, bag);
715+
}
713716

714717
var typeSyntax = node.Declaration.Type;
715718
bool isConst = node.IsConst;

0 commit comments

Comments
 (0)