Skip to content

Commit 330423b

Browse files
committed
Close #1846
1 parent f0f830b commit 330423b

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

Rubberduck.Parsing/Symbols/Declaration.cs

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public Declaration(
144144
_parentScope = parentScope ?? string.Empty;
145145
_identifierName = qualifiedName.MemberName;
146146
_asTypeName = asTypeName;
147-
_isSelfAssigned = isSelfAssigned || (declarationType == DeclarationType.Variable && parentDeclaration != null && parentDeclaration.IdentifierName == ComponentName);
147+
_isSelfAssigned = isSelfAssigned;
148148
_isWithEvents = isWithEvents;
149149
_accessibility = accessibility;
150150
_declarationType = declarationType;
@@ -464,7 +464,17 @@ public bool AsTypeIsBaseType
464464
}
465465
}
466466

467-
public Declaration AsTypeDeclaration { get; internal set; }
467+
private Declaration _asTypeDeclaration;
468+
public Declaration AsTypeDeclaration
469+
{
470+
get { return _asTypeDeclaration; }
471+
internal set
472+
{
473+
_asTypeDeclaration = value;
474+
IsSelfAssigned = _isSelfAssigned || (DeclarationType == DeclarationType.Variable &&
475+
AsTypeDeclaration.DeclarationType == DeclarationType.UserDefinedType);
476+
}
477+
}
468478

469479
private readonly IReadOnlyList<DeclarationType> _neverArray = new[]
470480
{
@@ -495,11 +505,19 @@ public bool IsSelected(QualifiedSelection selection)
495505
Selection.ContainsFirstCharacter(selection.Selection);
496506
}
497507

498-
private readonly bool _isSelfAssigned;
508+
private bool _isSelfAssigned;
509+
499510
/// <summary>
500511
/// Gets a value indicating whether the declaration is a joined assignment (e.g. "As New xxxxx")
501512
/// </summary>
502-
public bool IsSelfAssigned { get { return _isSelfAssigned; } }
513+
public bool IsSelfAssigned
514+
{
515+
get { return _isSelfAssigned; }
516+
private set
517+
{
518+
_isSelfAssigned = value;
519+
}
520+
}
503521

504522
private readonly Accessibility _accessibility;
505523
/// <summary>

Rubberduck.Parsing/VBA/RubberduckParser.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,11 +408,13 @@ private void SyncComReferences(IReadOnlyList<VBProject> projects)
408408
{
409409
State.OnStatusMessageUpdate(ParserState.LoadingReference.ToString());
410410

411+
var tightlyScopedCapture = reference;
412+
411413
loadTasks.Add(
412414
Task.Run(() =>
413415
{
414416
var comReflector = new ReferencedDeclarationsCollector(State);
415-
var items = comReflector.GetDeclarationsForReference(reference);
417+
var items = comReflector.GetDeclarationsForReference(tightlyScopedCapture);
416418

417419
foreach (var declaration in items)
418420
{

0 commit comments

Comments
 (0)