Skip to content

Commit

Permalink
Merge pull request #15564 from rchande/fix15443
Browse files Browse the repository at this point in the history
Don't show builder after dot
  • Loading branch information
Ravi Chande authored Jan 4, 2017
2 parents 48dcbe9 + 8e1f317 commit 5a8bacc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,17 @@ class C {
await VerifyNotBuilderAsync(markup);
}

[WorkItem(15443, "https://github.com/dotnet/roslyn/issues/15443")]
[Fact, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task NotBuilderWhenDelegateInferredRightOfDotInInvocation()
{
var markup = @"
class C {
Action a = Task.$$
}";
await VerifyNotBuilderAsync(markup);
}

private async Task VerifyNotBuilderAsync(string markup)
{
await VerifyWorkerAsync(markup, isBuilder: false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,19 @@ private bool IsLambdaExpression(SemanticModel semanticModel, int position, Synta
position = token.Parent.SpanStart;
}

// In the following situation, the type inferrer will infer Task to support target type preselection
// Action a = Task.$$
// We need to explicitly exclude invocation/member access from suggestion mode
var previousToken = token.GetPreviousTokenIfTouchingWord(position);
if (previousToken.IsKind(SyntaxKind.DotToken) &&
previousToken.Parent.IsKind(SyntaxKind.SimpleMemberAccessExpression))
{
return false;
}

// If we're an argument to a function with multiple overloads,
// open the builder if any overload takes a delegate at our argument position
var inferredTypeInfo = typeInferrer.GetTypeInferenceInfo(semanticModel, position, cancellationToken: cancellationToken);

return inferredTypeInfo.Any(type => GetDelegateType(type, semanticModel.Compilation).IsDelegateType());
}

Expand Down

0 comments on commit 5a8bacc

Please sign in to comment.