Skip to content

Commit

Permalink
Simplify ExpressionBuilder.ConvertField.IsUnambiguousAccess by renami…
Browse files Browse the repository at this point in the history
…ng it to ExpressionBuilder.ConvertField.IsAmbiguousAccess
  • Loading branch information
siegfriedpammer committed Jun 13, 2020
1 parent 4f6d4a0 commit 3e40914
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -256,20 +256,19 @@ ExpressionWithResolveResult ConvertField(IField field, ILInstruction targetInstr
bool targetCasted = false;
var targetResolveResult = requireTarget ? target.ResolveResult : null;

bool IsUnambiguousAccess(out MemberResolveResult result)
bool IsAmbiguousAccess(out MemberResolveResult result)
{
if (targetResolveResult == null) {
result = resolver.ResolveSimpleName(field.Name, EmptyList<IType>.Instance, isInvocationTarget: false) as MemberResolveResult;
return !(result == null || result.IsError || !result.Member.Equals(field, NormalizeTypeVisitor.TypeErasure));
} else {
var lookup = new MemberLookup(resolver.CurrentTypeDefinition, resolver.CurrentTypeDefinition.ParentModule);
result = lookup.Lookup(target.ResolveResult, field.Name, EmptyList<IType>.Instance, false) as MemberResolveResult;
return !(result == null || result.IsError || !result.Member.Equals(field, NormalizeTypeVisitor.TypeErasure));
result = lookup.Lookup(target.ResolveResult, field.Name, EmptyList<IType>.Instance, isInvocation: false) as MemberResolveResult;
}
return result == null || result.IsError || !result.Member.Equals(field, NormalizeTypeVisitor.TypeErasure);
}

MemberResolveResult mrr;
while (!IsUnambiguousAccess(out mrr)) {
while (IsAmbiguousAccess(out mrr)) {
if (!requireTarget) {
requireTarget = true;
targetResolveResult = target.ResolveResult;
Expand All @@ -281,6 +280,7 @@ bool IsUnambiguousAccess(out MemberResolveResult result)
break;
}
}

if (mrr == null) {
mrr = new MemberResolveResult(target.ResolveResult, field);
}
Expand Down

0 comments on commit 3e40914

Please sign in to comment.