提交 f45e1654 编写于 作者: G Gen Lu 提交者: GitHub

Merge pull request #22675 from dotnet/revert-22653-fixDupMember

Revert "Remove duplicate member symbol from EventReferenceExpression"
......@@ -327,11 +327,12 @@ private IFieldReferenceExpression CreateBoundFieldAccessOperation(BoundFieldAcce
IFieldSymbol field = boundFieldAccess.FieldSymbol;
bool isDeclaration = boundFieldAccess.IsDeclaration;
Lazy<IOperation> instance = new Lazy<IOperation>(() => Create(boundFieldAccess.FieldSymbol.IsStatic ? null : boundFieldAccess.ReceiverOpt));
ISymbol member = boundFieldAccess.FieldSymbol;
SyntaxNode syntax = boundFieldAccess.Syntax;
ITypeSymbol type = boundFieldAccess.Type;
Optional<object> constantValue = ConvertToOptional(boundFieldAccess.ConstantValue);
bool isImplicit = boundFieldAccess.WasCompilerGenerated;
return new LazyFieldReferenceExpression(field, isDeclaration, instance, _semanticModel, syntax, type, constantValue, isImplicit);
return new LazyFieldReferenceExpression(field, isDeclaration, instance, member, _semanticModel, syntax, type, constantValue, isImplicit);
}
private IPropertyReferenceExpression CreateBoundPropertyAccessOperation(BoundPropertyAccess boundPropertyAccess)
......@@ -339,17 +340,19 @@ private IPropertyReferenceExpression CreateBoundPropertyAccessOperation(BoundPro
IPropertySymbol property = boundPropertyAccess.PropertySymbol;
Lazy<IOperation> instance = new Lazy<IOperation>(() => Create(boundPropertyAccess.PropertySymbol.IsStatic ? null : boundPropertyAccess.ReceiverOpt));
Lazy<ImmutableArray<IArgument>> argumentsInEvaluationOrder = new Lazy<ImmutableArray<IArgument>>(() => ImmutableArray<IArgument>.Empty);
ISymbol member = boundPropertyAccess.PropertySymbol;
SyntaxNode syntax = boundPropertyAccess.Syntax;
ITypeSymbol type = boundPropertyAccess.Type;
Optional<object> constantValue = ConvertToOptional(boundPropertyAccess.ConstantValue);
bool isImplicit = boundPropertyAccess.WasCompilerGenerated;
return new LazyPropertyReferenceExpression(property, instance, argumentsInEvaluationOrder, _semanticModel, syntax, type, constantValue, isImplicit);
return new LazyPropertyReferenceExpression(property, instance, member, argumentsInEvaluationOrder, _semanticModel, syntax, type, constantValue, isImplicit);
}
private IPropertyReferenceExpression CreateBoundIndexerAccessOperation(BoundIndexerAccess boundIndexerAccess)
{
IPropertySymbol property = boundIndexerAccess.Indexer;
Lazy<IOperation> instance = new Lazy<IOperation>(() => Create(boundIndexerAccess.Indexer.IsStatic ? null : boundIndexerAccess.ReceiverOpt));
ISymbol member = boundIndexerAccess.Indexer;
Lazy<ImmutableArray<IArgument>> argumentsInEvaluationOrder = new Lazy<ImmutableArray<IArgument>>(() =>
{
MethodSymbol accessor = boundIndexerAccess.UseSetterForDefaultArgumentGeneration
......@@ -373,18 +376,19 @@ private IPropertyReferenceExpression CreateBoundIndexerAccessOperation(BoundInde
ITypeSymbol type = boundIndexerAccess.Type;
Optional<object> constantValue = ConvertToOptional(boundIndexerAccess.ConstantValue);
bool isImplicit = boundIndexerAccess.WasCompilerGenerated;
return new LazyPropertyReferenceExpression(property, instance, argumentsInEvaluationOrder, _semanticModel, syntax, type, constantValue, isImplicit);
return new LazyPropertyReferenceExpression(property, instance, member, argumentsInEvaluationOrder, _semanticModel, syntax, type, constantValue, isImplicit);
}
private IEventReferenceExpression CreateBoundEventAccessOperation(BoundEventAccess boundEventAccess)
{
IEventSymbol @event = boundEventAccess.EventSymbol;
Lazy<IOperation> instance = new Lazy<IOperation>(() => Create(boundEventAccess.EventSymbol.IsStatic ? null : boundEventAccess.ReceiverOpt));
ISymbol member = boundEventAccess.EventSymbol;
SyntaxNode syntax = boundEventAccess.Syntax;
ITypeSymbol type = boundEventAccess.Type;
Optional<object> constantValue = ConvertToOptional(boundEventAccess.ConstantValue);
bool isImplicit = boundEventAccess.WasCompilerGenerated;
return new LazyEventReferenceExpression(@event, instance, _semanticModel, syntax, type, constantValue, isImplicit);
return new LazyEventReferenceExpression(@event, instance, member, _semanticModel, syntax, type, constantValue, isImplicit);
}
private IEventAssignmentExpression CreateBoundEventAssignmentOperatorOperation(BoundEventAssignmentOperator boundEventAssignmentOperator)
......@@ -432,12 +436,13 @@ private IPropertyReferenceExpression CreateBoundAnonymousPropertyDeclarationOper
{
PropertySymbol property = boundAnonymousPropertyDeclaration.Property;
Lazy<IOperation> instance = new Lazy<IOperation>(() => null);
ISymbol member = boundAnonymousPropertyDeclaration.Property;
Lazy<ImmutableArray<IArgument>> argumentsInEvaluationOrder = new Lazy<ImmutableArray<IArgument>>(() => ImmutableArray<IArgument>.Empty);
SyntaxNode syntax = boundAnonymousPropertyDeclaration.Syntax;
ITypeSymbol type = boundAnonymousPropertyDeclaration.Type;
Optional<object> constantValue = ConvertToOptional(boundAnonymousPropertyDeclaration.ConstantValue);
bool isImplicit = boundAnonymousPropertyDeclaration.WasCompilerGenerated;
return new LazyPropertyReferenceExpression(property, instance, argumentsInEvaluationOrder, _semanticModel, syntax, type, constantValue, isImplicit);
return new LazyPropertyReferenceExpression(property, instance, member, argumentsInEvaluationOrder, _semanticModel, syntax, type, constantValue, isImplicit);
}
private IObjectCreationExpression CreateBoundObjectCreationExpressionOperation(BoundObjectCreationExpression boundObjectCreationExpression)
......@@ -554,10 +559,10 @@ private IMemberReferenceExpression CreateBoundObjectInitializerMemberOperation(B
case SymbolKind.Field:
var field = (FieldSymbol)boundObjectInitializerMember.MemberSymbol;
bool isDeclaration = false;
return new LazyFieldReferenceExpression(field, isDeclaration, instance, _semanticModel, syntax, type, constantValue, isImplicit);
return new LazyFieldReferenceExpression(field, isDeclaration, instance, field, _semanticModel, syntax, type, constantValue, isImplicit);
case SymbolKind.Event:
var eventSymbol = (EventSymbol)boundObjectInitializerMember.MemberSymbol;
return new LazyEventReferenceExpression(eventSymbol, instance, _semanticModel, syntax, type, constantValue, isImplicit);
return new LazyEventReferenceExpression(eventSymbol, instance, eventSymbol, _semanticModel, syntax, type, constantValue, isImplicit);
case SymbolKind.Property:
var property = (PropertySymbol)boundObjectInitializerMember.MemberSymbol;
Lazy<ImmutableArray<IArgument>> argumentsInEvaluationOrder;
......@@ -586,7 +591,7 @@ private IMemberReferenceExpression CreateBoundObjectInitializerMemberOperation(B
});
}
return new LazyPropertyReferenceExpression(property, instance, argumentsInEvaluationOrder, _semanticModel, syntax, type, constantValue, isImplicit);
return new LazyPropertyReferenceExpression(property, instance, property, argumentsInEvaluationOrder, _semanticModel, syntax, type, constantValue, isImplicit);
default:
throw ExceptionUtilities.Unreachable;
}
......
......@@ -84,7 +84,7 @@ private IEventReferenceExpression CreateBoundEventAccessOperation(BoundEventAssi
SyntaxNode eventAccessSyntax = ((AssignmentExpressionSyntax)syntax).Left;
bool isImplicit = boundEventAssignmentOperator.WasCompilerGenerated;
return new LazyEventReferenceExpression(@event, instance, _semanticModel, eventAccessSyntax, @event.Type, ConvertToOptional(null), isImplicit);
return new LazyEventReferenceExpression(@event, instance, @event, _semanticModel, eventAccessSyntax, @event.Type, ConvertToOptional(null), isImplicit);
}
private ImmutableArray<IArgument> DeriveArguments(
......
......@@ -1395,15 +1395,15 @@ public LazyEventAssignmentExpression(Lazy<IEventReferenceExpression> eventRefere
/// </summary>
internal abstract partial class BaseEventReferenceExpression : MemberReferenceExpression, IEventReferenceExpression
{
public BaseEventReferenceExpression(IEventSymbol @event, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue, bool isImplicit) :
base(@event, OperationKind.EventReferenceExpression, semanticModel, syntax, type, constantValue, isImplicit)
public BaseEventReferenceExpression(IEventSymbol @event, ISymbol member, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue, bool isImplicit) :
base(member, OperationKind.EventReferenceExpression, semanticModel, syntax, type, constantValue, isImplicit)
{
Event = @event;
}
/// <summary>
/// Referenced event.
/// </summary>
public IEventSymbol Event => (IEventSymbol)Member;
public IEventSymbol Event { get; }
public override IEnumerable<IOperation> Children
{
get
......@@ -1427,8 +1427,8 @@ public override void Accept(OperationVisitor visitor)
/// </summary>
internal sealed partial class EventReferenceExpression : BaseEventReferenceExpression, IEventReferenceExpression
{
public EventReferenceExpression(IEventSymbol @event, IOperation instance, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue, bool isImplicit) :
base(@event, semanticModel, syntax, type, constantValue, isImplicit)
public EventReferenceExpression(IEventSymbol @event, IOperation instance, ISymbol member, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue, bool isImplicit) :
base(@event, member, semanticModel, syntax, type, constantValue, isImplicit)
{
InstanceImpl = instance;
}
......@@ -1442,8 +1442,8 @@ internal sealed partial class LazyEventReferenceExpression : BaseEventReferenceE
{
private readonly Lazy<IOperation> _lazyInstance;
public LazyEventReferenceExpression(IEventSymbol @event, Lazy<IOperation> instance, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue, bool isImplicit) :
base(@event, semanticModel, syntax, type, constantValue, isImplicit)
public LazyEventReferenceExpression(IEventSymbol @event, Lazy<IOperation> instance, ISymbol member, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue, bool isImplicit) :
base(@event, member, semanticModel, syntax, type, constantValue, isImplicit)
{
_lazyInstance = instance ?? throw new System.ArgumentNullException(nameof(instance));
}
......@@ -1576,15 +1576,16 @@ internal sealed partial class LazyFieldInitializer : BaseFieldInitializer, IFiel
/// </summary>
internal abstract partial class BaseFieldReferenceExpression : MemberReferenceExpression, IFieldReferenceExpression
{
public BaseFieldReferenceExpression(IFieldSymbol field, bool isDeclaration, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue, bool isImplicit) :
base(field, OperationKind.FieldReferenceExpression, semanticModel, syntax, type, constantValue, isImplicit)
public BaseFieldReferenceExpression(IFieldSymbol field, bool isDeclaration, ISymbol member, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue, bool isImplicit) :
base(member, OperationKind.FieldReferenceExpression, semanticModel, syntax, type, constantValue, isImplicit)
{
Field = field;
IsDeclaration = isDeclaration;
}
/// <summary>
/// Referenced field.
/// </summary>
public IFieldSymbol Field => (IFieldSymbol)Member;
public IFieldSymbol Field { get; }
public bool IsDeclaration { get; }
public override IEnumerable<IOperation> Children
{
......@@ -1609,8 +1610,8 @@ public override void Accept(OperationVisitor visitor)
/// </summary>
internal sealed partial class FieldReferenceExpression : BaseFieldReferenceExpression, IFieldReferenceExpression
{
public FieldReferenceExpression(IFieldSymbol field, bool isDeclaration, IOperation instance, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue, bool isImplicit) :
base(field, isDeclaration, semanticModel, syntax, type, constantValue, isImplicit)
public FieldReferenceExpression(IFieldSymbol field, bool isDeclaration, IOperation instance, ISymbol member, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue, bool isImplicit) :
base(field, isDeclaration, member, semanticModel, syntax, type, constantValue, isImplicit)
{
InstanceImpl = instance;
}
......@@ -1624,8 +1625,8 @@ internal sealed partial class LazyFieldReferenceExpression : BaseFieldReferenceE
{
private readonly Lazy<IOperation> _lazyInstance;
public LazyFieldReferenceExpression(IFieldSymbol field, bool isDeclaration, Lazy<IOperation> instance, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue, bool isImplicit) :
base(field, isDeclaration, semanticModel, syntax, type, constantValue, isImplicit)
public LazyFieldReferenceExpression(IFieldSymbol field, bool isDeclaration, Lazy<IOperation> instance, ISymbol member, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue, bool isImplicit) :
base(field, isDeclaration, member, semanticModel, syntax, type, constantValue, isImplicit)
{
_lazyInstance = instance ?? throw new System.ArgumentNullException(nameof(instance));
}
......@@ -3831,14 +3832,15 @@ internal sealed partial class LazyPropertyInitializer : BasePropertyInitializer,
/// </summary>
internal abstract partial class BasePropertyReferenceExpression : MemberReferenceExpression, IPropertyReferenceExpression, IHasArguments
{
protected BasePropertyReferenceExpression(IPropertySymbol property, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue, bool isImplicit) :
base(property, OperationKind.PropertyReferenceExpression, semanticModel, syntax, type, constantValue, isImplicit)
protected BasePropertyReferenceExpression(IPropertySymbol property, ISymbol member, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue, bool isImplicit) :
base(member, OperationKind.PropertyReferenceExpression, semanticModel, syntax, type, constantValue, isImplicit)
{
Property = property;
}
/// <summary>
/// Referenced property.
/// </summary>
public IPropertySymbol Property => (IPropertySymbol)Member;
public IPropertySymbol Property { get; }
protected abstract ImmutableArray<IArgument> ArgumentsInEvaluationOrderImpl { get; }
public override IEnumerable<IOperation> Children
{
......@@ -3875,8 +3877,8 @@ public override void Accept(OperationVisitor visitor)
/// </summary>
internal sealed partial class PropertyReferenceExpression : BasePropertyReferenceExpression, IPropertyReferenceExpression, IHasArguments
{
public PropertyReferenceExpression(IPropertySymbol property, IOperation instance, ImmutableArray<IArgument> argumentsInEvaluationOrder, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue, bool isImplicit) :
base(property, semanticModel, syntax, type, constantValue, isImplicit)
public PropertyReferenceExpression(IPropertySymbol property, IOperation instance, ISymbol member, ImmutableArray<IArgument> argumentsInEvaluationOrder, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue, bool isImplicit) :
base(property, member, semanticModel, syntax, type, constantValue, isImplicit)
{
InstanceImpl = instance;
ArgumentsInEvaluationOrderImpl = argumentsInEvaluationOrder;
......@@ -3902,8 +3904,8 @@ internal sealed partial class LazyPropertyReferenceExpression : BasePropertyRefe
private readonly Lazy<IOperation> _lazyInstance;
private readonly Lazy<ImmutableArray<IArgument>> _lazyArgumentsInEvaluationOrder;
public LazyPropertyReferenceExpression(IPropertySymbol property, Lazy<IOperation> instance, Lazy<ImmutableArray<IArgument>> argumentsInEvaluationOrder, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue, bool isImplicit) :
base(property, semanticModel, syntax, type, constantValue, isImplicit)
public LazyPropertyReferenceExpression(IPropertySymbol property, Lazy<IOperation> instance, ISymbol member, Lazy<ImmutableArray<IArgument>> argumentsInEvaluationOrder, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue, bool isImplicit) :
base(property, member, semanticModel, syntax, type, constantValue, isImplicit)
{
_lazyInstance = instance ?? throw new System.ArgumentNullException(nameof(instance));
_lazyArgumentsInEvaluationOrder = argumentsInEvaluationOrder ?? throw new System.ArgumentNullException(nameof(argumentsInEvaluationOrder));
......
......@@ -217,7 +217,7 @@ public override IOperation VisitInstanceReferenceExpression(IInstanceReferenceEx
public override IOperation VisitFieldReferenceExpression(IFieldReferenceExpression operation, object argument)
{
return new FieldReferenceExpression(operation.Field, operation.IsDeclaration, Visit(operation.Instance), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit);
return new FieldReferenceExpression(operation.Field, operation.IsDeclaration, Visit(operation.Instance), operation.Member, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit);
}
public override IOperation VisitMethodReferenceExpression(IMethodReferenceExpression operation, object argument)
......@@ -227,12 +227,12 @@ public override IOperation VisitMethodReferenceExpression(IMethodReferenceExpres
public override IOperation VisitPropertyReferenceExpression(IPropertyReferenceExpression operation, object argument)
{
return new PropertyReferenceExpression(operation.Property, Visit(operation.Instance), VisitArray(operation.ArgumentsInEvaluationOrder), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit);
return new PropertyReferenceExpression(operation.Property, Visit(operation.Instance), operation.Member, VisitArray(operation.ArgumentsInEvaluationOrder), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit);
}
public override IOperation VisitEventReferenceExpression(IEventReferenceExpression operation, object argument)
{
return new EventReferenceExpression(operation.Event, Visit(operation.Instance), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit);
return new EventReferenceExpression(operation.Event, Visit(operation.Instance), operation.Member, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit);
}
public override IOperation VisitEventAssignmentExpression(IEventAssignmentExpression operation, object argument)
......
......@@ -785,7 +785,7 @@ Namespace Microsoft.CodeAnalysis.Semantics
Dim type As ITypeSymbol = boundPropertyAccess.Type
Dim constantValue As [Optional](Of Object) = ConvertToOptional(boundPropertyAccess.ConstantValueOpt)
Dim isImplicit As Boolean = boundPropertyAccess.WasCompilerGenerated
Return New LazyPropertyReferenceExpression([property], instance, argumentsInEvaluationOrder, _semanticModel, syntax, type, constantValue, isImplicit)
Return New LazyPropertyReferenceExpression([property], instance, [property], argumentsInEvaluationOrder, _semanticModel, syntax, type, constantValue, isImplicit)
End Function
Private Function CreateBoundWithLValueExpressionPlaceholder(boundWithLValueExpressionPlaceholder As BoundWithLValueExpressionPlaceholder) As IInstanceReferenceExpression
......@@ -819,7 +819,7 @@ Namespace Microsoft.CodeAnalysis.Semantics
Dim type As ITypeSymbol = boundEventAccess.Type
Dim constantValue As [Optional](Of Object) = ConvertToOptional(boundEventAccess.ConstantValueOpt)
Dim isImplicit As Boolean = boundEventAccess.WasCompilerGenerated
Return New LazyEventReferenceExpression([event], instance, _semanticModel, syntax, type, constantValue, isImplicit)
Return New LazyEventReferenceExpression([event], instance, [event], _semanticModel, syntax, type, constantValue, isImplicit)
End Function
Private Function CreateBoundFieldAccessOperation(boundFieldAccess As BoundFieldAccess) As IFieldReferenceExpression
......@@ -834,11 +834,12 @@ Namespace Microsoft.CodeAnalysis.Semantics
End If
End Function)
Dim member As ISymbol = boundFieldAccess.FieldSymbol
Dim syntax As SyntaxNode = boundFieldAccess.Syntax
Dim type As ITypeSymbol = boundFieldAccess.Type
Dim constantValue As [Optional](Of Object) = ConvertToOptional(boundFieldAccess.ConstantValueOpt)
Dim isImplicit As Boolean = boundFieldAccess.WasCompilerGenerated
Return New LazyFieldReferenceExpression(field, isDeclaration, instance, _semanticModel, syntax, type, constantValue, isImplicit)
Return New LazyFieldReferenceExpression(field, isDeclaration, instance, member, _semanticModel, syntax, type, constantValue, isImplicit)
End Function
Private Function CreateBoundConditionalAccessOperation(boundConditionalAccess As BoundConditionalAccess) As IConditionalAccessExpression
......@@ -1409,6 +1410,7 @@ Namespace Microsoft.CodeAnalysis.Semantics
Dim eventReference As Lazy(Of IEventReferenceExpression) = New Lazy(Of IEventReferenceExpression)(Function() As IEventReferenceExpression
Return New LazyEventReferenceExpression(eventSymbol,
eventReferenceInstance,
eventSymbol,
_semanticModel,
eventReferenceSyntax,
eventReferenceType,
......@@ -1513,7 +1515,7 @@ Namespace Microsoft.CodeAnalysis.Semantics
Dim type As ITypeSymbol = boundAnonymousTypePropertyAccess.Type
Dim constantValue As [Optional](Of Object) = ConvertToOptional(boundAnonymousTypePropertyAccess.ConstantValueOpt)
Dim isImplicit As Boolean = boundAnonymousTypePropertyAccess.WasCompilerGenerated
Return New LazyPropertyReferenceExpression([property], instance, argumentsInEvaluationOrder, _semanticModel, syntax, type, constantValue, isImplicit)
Return New LazyPropertyReferenceExpression([property], instance, [property], argumentsInEvaluationOrder, _semanticModel, syntax, type, constantValue, isImplicit)
End Function
Private Function CreateBoundQueryExpressionOperation(boundQueryExpression As BoundQueryExpression) As IOperation
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册