Skip to content

Commit 6b26b79

Browse files
committed
Correct the ordering for the MemberAccessTypeBinding
Update SimpleNameTypeBinding to check for ambiguous matches and return a ResolutionFailedExpression
1 parent 112e378 commit 6b26b79

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

Rubberduck.Parsing/Binding/Bindings/MemberAccessTypeBinding.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,7 @@ private IBoundExpression ResolveLExpressionIsProject(IBoundExpression lExpressio
7373
IBoundExpression boundExpression = null;
7474
var referencedProject = lExpression.ReferencedDeclaration;
7575
bool lExpressionIsEnclosingProject = _project.Equals(referencedProject);
76-
boundExpression = ResolveProject(lExpression, name);
77-
if (boundExpression != null)
78-
{
79-
return boundExpression;
80-
}
76+
8177
boundExpression = ResolveProceduralModule(lExpressionIsEnclosingProject, lExpression, name, referencedProject);
8278
if (boundExpression != null)
8379
{
@@ -98,6 +94,11 @@ private IBoundExpression ResolveLExpressionIsProject(IBoundExpression lExpressio
9894
{
9995
return boundExpression;
10096
}
97+
boundExpression = ResolveProject(lExpression, name);
98+
if (boundExpression != null)
99+
{
100+
return boundExpression;
101+
}
101102
return boundExpression;
102103
}
103104

Rubberduck.Parsing/Binding/Bindings/SimpleNameTypeBinding.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using Rubberduck.Parsing.Grammar;
1+
using System;
2+
using Rubberduck.Parsing.Grammar;
23
using Rubberduck.Parsing.Symbols;
34

45
namespace Rubberduck.Parsing.Binding
@@ -123,6 +124,13 @@ procedural module or class module contained in the enclosing project.
123124
*/
124125
if (_declarationFinder.IsMatch(_project.ProjectName, name))
125126
{
127+
// Ensure there is no ambiguous matches
128+
var ambiguousClassModule = _declarationFinder.FindModuleEnclosingProjectWithoutEnclosingModule(_project, _module, name, DeclarationType.ClassModule);
129+
if (ambiguousClassModule != null)
130+
{
131+
// We have an indeterminate result... (normally a VBA compile error)
132+
return new ResolutionFailedExpression();
133+
}
126134
return new SimpleNameExpression(_project, ExpressionClassification.Project, _expression);
127135
}
128136
var referencedProject = _declarationFinder.FindReferencedProject(_project, name);

RubberduckTests/Symbols/DeclarationFinderTests.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,6 @@ End Sub
716716

717717
[Test]
718718
[Category("Resolver")]
719-
[Ignore("WIP until PR is finalized")]
720719
public void SameNameForProjectAndClass_ScopedDeclaration_ClassSelection()
721720
{
722721
var refEditClass = @"
@@ -761,7 +760,7 @@ End Sub
761760

762761
[Test]
763762
[Category("Resolver")]
764-
[Ignore("WIP until PR is finalized")]
763+
[Ignore("The test should fail as this is a compile error; need to work out how to set state to ResolverError")]
765764
public void SameNameForProjectAndClassImplicit_ScopedDeclaration()
766765
{
767766
var refEditClass = @"

0 commit comments

Comments
 (0)