Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify and reduce amount of work performed by SourcePropertySymbolBase constructor. #49360

Merged
merged 8 commits into from
Nov 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Compilers/CSharp/Portable/Binder/Binder_Statements.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1628,7 +1628,7 @@ private static bool AccessingAutoPropertyFromConstructor(BoundExpression receive
var propertyIsStatic = propertySymbol.IsStatic;

return (object)sourceProperty != null &&
sourceProperty.IsAutoProperty &&
sourceProperty.IsAutoPropertyWithGetAccessor &&
TypeSymbol.Equals(sourceProperty.ContainingType, fromMember.ContainingType, TypeCompareKind.ConsiderEverything2) &&
IsConstructorOrField(fromMember, isStatic: propertyIsStatic) &&
(propertyIsStatic || receiver.Kind == BoundKind.ThisReference);
Expand Down
2 changes: 1 addition & 1 deletion src/Compilers/CSharp/Portable/Compiler/MethodCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1754,7 +1754,7 @@ syntaxNode is ConstructorDeclarationSyntax constructorSyntax &&
else
{
var property = sourceMethod.AssociatedSymbol as SourcePropertySymbolBase;
if ((object)property != null && property.IsAutoProperty)
if ((object)property != null && property.IsAutoPropertyWithGetAccessor)
{
return MethodBodySynthesizer.ConstructAutoPropertyAccessorBody(sourceMethod);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ private BoundExpression MakePropertyAssignment(
if (setMethod is null)
{
var autoProp = (SourcePropertySymbolBase)property;
Debug.Assert(autoProp.IsAutoProperty,
Debug.Assert(autoProp.IsAutoPropertyWithGetAccessor,
"only autoproperties can be assignable without having setters");

var backingField = autoProp.BackingField;
Expand Down
15 changes: 10 additions & 5 deletions src/Compilers/CSharp/Portable/Symbols/CompletionPart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,16 @@ internal enum CompletionPart
TypeParameterSymbolAll = Attributes | TypeParameterConstraints,

// For property symbols
StartPropertyParameters = 1 << 4,
FinishPropertyParameters = 1 << 5,
StartPropertyType = 1 << 6,
FinishPropertyType = 1 << 7,
PropertySymbolAll = Attributes | StartPropertyParameters | FinishPropertyParameters | StartPropertyType | FinishPropertyType,
StartPropertyEnsureSignature = 1 << 4,
FinishPropertyEnsureSignature = 1 << 5,
StartPropertyParameters = 1 << 6,
FinishPropertyParameters = 1 << 7,
StartPropertyType = 1 << 8,
FinishPropertyType = 1 << 9,
StartPropertyFinalCompletion = 1 << 10,
FinishPropertyFinalCompletion = 1 << 11,
PropertySymbolAll = Attributes | StartPropertyEnsureSignature | FinishPropertyEnsureSignature | StartPropertyParameters | FinishPropertyParameters |
StartPropertyType | FinishPropertyType | StartPropertyFinalCompletion | FinishPropertyFinalCompletion,

// For alias symbols
AliasTarget = 1 << 4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3291,15 +3291,15 @@ ImmutableArray<PropertySymbol> addProperties(ImmutableArray<ParameterSymbol> rec
}
if (existingMember is null)
{
addProperty(new SynthesizedRecordPropertySymbol(this, syntax, param, isOverride: false, diagnostics));
addProperty(new SynthesizedRecordPropertySymbol(this, syntax, param, isOverride: false));
}
else if (existingMember is PropertySymbol { IsStatic: false, GetMethod: { } } prop
&& prop.TypeWithAnnotations.Equals(param.TypeWithAnnotations, TypeCompareKind.AllIgnoreOptions))
{
// There already exists a member corresponding to the candidate synthesized property.
if (isInherited && prop.IsAbstract)
{
addProperty(new SynthesizedRecordPropertySymbol(this, syntax, param, isOverride: true, diagnostics));
addProperty(new SynthesizedRecordPropertySymbol(this, syntax, param, isOverride: true));
}
else
{
Expand All @@ -3320,6 +3320,8 @@ void addProperty(SynthesizedRecordPropertySymbol property)
{
existingOrAddedMembers.Add(property);
members.Add(property);
Debug.Assert(property.GetMethod is object);
Debug.Assert(property.SetMethod is object);
members.Add(property.GetMethod);
members.Add(property.SetMethod);
members.Add(property.BackingField);
Expand Down Expand Up @@ -3393,7 +3395,7 @@ PropertySymbol addEqualityContract()

if (!memberSignatures.TryGetValue(targetProperty, out Symbol? existingEqualityContractProperty))
{
equalityContract = new SynthesizedRecordEqualityContractProperty(this, diagnostics);
equalityContract = new SynthesizedRecordEqualityContractProperty(this);
members.Add(equalityContract);
members.Add(equalityContract.GetMethod);
}
Expand Down
Loading