Repository: dotnet/roslyn
File: src/Compilers/CSharp/Portable/Binder/Binder.ValueChecks.cs (C#)

Code before:
                    Debug.Assert(valueKind is (BindValueKind.Assignable or BindValueKind.RefOrOut or BindValueKind.RefAssignable) || diagnostics.DiagnosticBag is null || diagnostics.HasAnyResolvedErrors());
                    return expr;

                case BoundKind.PropertyAccess:
                    if (!InAttributeArgument)
                    {
                        // If the property has a synthesized backing field, record the accessor kind of the property
                        // access for determining whether the property access can use the backing field directly.
                        var propertyAccess = (BoundPropertyAccess)expr;
                        if (HasSynthesizedBackingField(propertyAccess.PropertySymbol, out _))
                        {
                            expr = propertyAccess.Update(
                                propertyAccess.ReceiverOpt,
                                propertyAccess.InitialBindingReceiverIsSubjectToCloning,
                                propertyAccess.PropertySymbol,
                                autoPropertyAccessorKind: GetAccessorKind(valueKind),
                                propertyAccess.ResultKind,
                                propertyAccess.Type);
                        }
                    }
#if DEBUG
                    expr.WasPropertyBackingFieldAccessChecked = true;
#endif
                    break;

                case BoundKind.IndexerAccess:
                    expr = BindIndexerDefaultArgumentsAndParamsCollection((BoundIndexerAccess)expr, valueKind, diagnostics);
                    break;

                case BoundKind.ImplicitIndexerAccess:
                    {
                        var implicitIndexer = (BoundImplicitIndexerAccess)expr;
                        if (implicitIndexer.IndexerOrSliceAccess is BoundIndexerAccess indexerAccess)
                        {
                            var kind = GetIndexerAccessorKind(indexerAccess, valueKind);
                            expr = implicitIndexer.Update(
                                implicitIndexer.Receiver,
                                implicitIndexer.Argument,
                                implicitIndexer.LengthOrCountAccess,
                                implicitIndexer.ReceiverPlaceholder,
                                indexerAccess.Update(kind),
                                implicitIndexer.ArgumentPlaceholders,
                                implicitIndexer.Type);
                        }
                    }
                    break;

                case BoundKind.UnconvertedObjectCreationExpression:
                case BoundKind.UnconvertedCollectionExpression:
                case BoundKind.UnconvertedConditionalOperator:
                case BoundKind.UnconvertedSwitchExpression:

Review comment (suggestion):
Can't we instead remove the assert inside WasPropertyBackingFieldAccessChecked? It doesn't seem useful anymore since we are working around it.

Code after:
                    Debug.Assert(valueKind is (BindValueKind.Assignable or BindValueKind.RefOrOut or BindValueKind.RefAssignable) || diagnostics.DiagnosticBag is null || diagnostics.HasAnyResolvedErrors());
                    return expr;

                case BoundKind.PropertyAccess:
                    var propertyAccess = (BoundPropertyAccess)expr;
                    if (!InAttributeArgument)
                    {
                        // If the property has a synthesized backing field, record the accessor kind of the property
                        // access for determining whether the property access can use the backing field directly.
                        if (HasSynthesizedBackingField(propertyAccess.PropertySymbol, out _))
                        {
                            expr = propertyAccess.Update(
                                propertyAccess.ReceiverOpt,
                                propertyAccess.InitialBindingReceiverIsSubjectToCloning,
                                propertyAccess.PropertySymbol,
                                autoPropertyAccessorKind: GetAccessorKind(valueKind),
                                propertyAccess.ResultKind,
                                propertyAccess.Type);
                        }
#if DEBUG
                        else
                        {
                            // Under DEBUG, create a new node to mark as checked, rather than mutating the original.
                            // This allows the original node to be passed to CheckValue multiple times safely, without
                            // asserting in WasPropertyBackingFieldAccessChecked.
                            expr = propertyAccess.Clone();
                        }
#endif
                    }
#if DEBUG
                    else
                    {
                        // Under DEBUG, create a new node to mark as checked, rather than mutating the original.
                        // This allows the original node to be passed to CheckValue multiple times safely, without
                        // asserting in WasPropertyBackingFieldAccessChecked.
                        expr = propertyAccess.Clone();
                    }
                    expr.WasPropertyBackingFieldAccessChecked = true;
#endif
                    break;

                case BoundKind.IndexerAccess:
                    expr = BindIndexerDefaultArgumentsAndParamsCollection((BoundIndexerAccess)expr, valueKind, diagnostics);
                    break;

                case BoundKind.ImplicitIndexerAccess:
                    {
                        var implicitIndexer = (BoundImplicitIndexerAccess)expr;
                        if (implicitIndexer.IndexerOrSliceAccess is BoundIndexerAccess indexerAccess)
                        {
                            var kind = GetIndexerAccessorKind(indexerAccess, valueKind);