Skip to content

Commit

Permalink
Adjust logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Youssef1313 committed Dec 29, 2021
1 parent 7fdc39c commit 6d53a72
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,13 @@ internal static BoundBlock ConstructAutoPropertyAccessorBody(SourceMemberMethodS
}

var field = property.BackingField;
if (field is null)
{
// This happens for public int { set; } where we produce ERR_AutoPropertyMustHaveGetAccessor
Debug.Assert(!property.HasGetAccessor);
return null;
}

Debug.Assert(!field.IsCreatedForFieldKeyword);
var fieldAccess = new BoundFieldAccess(syntax, thisReference, field, ConstantValue.NotAvailable) { WasCompilerGenerated = true };
BoundStatement statement;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ protected SourcePropertyAccessorSymbol(
isIterator)
{
_property = property;
_accessorBodyShouldBeSynthesized = (property.IsAutoProperty && property.HasGetAccessor && syntax is AccessorDeclarationSyntax { SemicolonToken.RawKind: (int)SyntaxKind.SemicolonToken, ExpressionBody: null, Body: null }) ||
_accessorBodyShouldBeSynthesized = (property.IsAutoProperty && syntax is AccessorDeclarationSyntax { SemicolonToken.RawKind: (int)SyntaxKind.SemicolonToken, ExpressionBody: null, Body: null }) ||
property is SynthesizedRecordPropertySymbol;
_containsFieldKeyword = property.IsIndexer ? false : NodeContainsFieldKeyword(getAccessorSyntax(syntax));
Debug.Assert(!_property.IsExpressionBodied, "Cannot have accessors in expression bodied lightweight properties");
Expand Down

0 comments on commit 6d53a72

Please sign in to comment.