提交 71788e59 编写于 作者: V VSadov

Made IDE change very specific to the affected scenario

More CR feedback
上级 5a7d3afc
......@@ -618,7 +618,7 @@ private BoundExpression MakeImplicitConversion(BoundExpression rewrittenOperand,
tupleTypeSymbol = TupleTypeSymbol.Create((NamedTypeSymbol)srcType);
}
var srcElementFields = ((TupleTypeSymbol)srcType).TupleDefaultElementFields;
var srcElementFields = tupleTypeSymbol.TupleDefaultElementFields;
var fieldAccessorsBuilder = ArrayBuilder<BoundExpression>.GetInstance(numElements);
BoundAssignmentOperator assignmentToTemp;
......
......@@ -845,10 +845,10 @@ private ImmutableArray<Symbol> CreateMembers()
if (defaultImplicitlyDeclared && providedName != null)
{
// The name given doesn't match the default name Item8, etc.
// Add a virtual field with the given name
// tupleFieldIndex << 1 + 1, because this is not a default element
members.Add(new TupleVirtualElementFieldSymbol(this, fieldSymbol, providedName, (tupleFieldIndex << 1) + 1, location, isImplicitlyDeclared: false));
// The name given doesn't match the default name Item8, etc.
// Add a virtual field with the given name
// tupleFieldIndex << 1 + 1, because this is not a default element
members.Add(new TupleVirtualElementFieldSymbol(this, fieldSymbol, providedName, (tupleFieldIndex << 1) + 1, location, isImplicitlyDeclared: false));
}
elementsMatchedByFields[tupleFieldIndex] = true; // mark as handled
......@@ -937,7 +937,7 @@ private ImmutableArray<Symbol> CreateMembers()
// Add default element field.
// i << 1 because this is a default element
members.Add(new TupleErrorFieldSymbol(this, defaultName, i << 1, defaultImplicitlyDeclared ? null: location, _elementTypes[i], diagnosticInfo, defaultImplicitlyDeclared));
members.Add(new TupleErrorFieldSymbol(this, defaultName, i << 1, defaultImplicitlyDeclared ? null : location, _elementTypes[i], diagnosticInfo, defaultImplicitlyDeclared));
if (defaultImplicitlyDeclared && providedName != null)
......
......@@ -83,12 +83,12 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
End Get
End Property
Public Sub New(container As NamedTypeSymbol, name As String, tupleFieldId As Integer, location As Location, type As TypeSymbol, useSiteDiagnosticInfo As DiagnosticInfo, isImplicitlyDeclared As Boolean)
Public Sub New(container As NamedTypeSymbol, name As String, tupleElementIndex As Integer, location As Location, type As TypeSymbol, useSiteDiagnosticInfo As DiagnosticInfo, isImplicitlyDeclared As Boolean)
MyBase.New(container, container, type, name, Accessibility.Public)
Debug.Assert(name <> Nothing)
Me._locations = If((location Is Nothing), ImmutableArray(Of Location).Empty, ImmutableArray.Create(Of Location)(location))
Me._useSiteDiagnosticInfo = useSiteDiagnosticInfo
Me._tupleElementIndex = tupleFieldId
Me._tupleElementIndex = tupleElementIndex
Me._isImplicitlyDeclared = isImplicitlyDeclared
End Sub
......
......@@ -175,8 +175,8 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
End Get
End Property
Public Sub New(container As TupleTypeSymbol, underlyingField As FieldSymbol, tupleFieldId As Integer, location As Location, isImplicitlyDeclared As Boolean)
MyBase.New(container, underlyingField, tupleFieldId)
Public Sub New(container As TupleTypeSymbol, underlyingField As FieldSymbol, tupleElementIndex As Integer, location As Location, isImplicitlyDeclared As Boolean)
MyBase.New(container, underlyingField, tupleElementIndex)
Me._locations = If((location Is Nothing), ImmutableArray(Of Location).Empty, ImmutableArray.Create(Of Location)(location))
Me._isImplicitlyDeclared = isImplicitlyDeclared
End Sub
......
......@@ -208,7 +208,16 @@ private async Task<TriggerIdentifierKind> DetermineIfRenamableSymbolAsync(ISymbo
// Get the source symbol if possible
var sourceSymbol = await SymbolFinder.FindSourceDefinitionAsync(symbol, document.Project.Solution, _cancellationToken).ConfigureAwait(false) ?? symbol;
if (sourceSymbol.IsImplicitlyDeclared || !sourceSymbol.Locations.All(loc => loc.IsInSource))
if (sourceSymbol.Kind == SymbolKind.Field &&
((IFieldSymbol)sourceSymbol).ContainingType.IsTupleType &&
sourceSymbol.IsImplicitlyDeclared)
{
// should not rename Item1, Item2...
// when user did not declare them in source.
return TriggerIdentifierKind.NotRenamable;
}
if (!sourceSymbol.Locations.All(loc => loc.IsInSource))
{
return TriggerIdentifierKind.NotRenamable;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册