Skip to content

Update FindImplementationsForInterfaceMemberAsync to correctly handle ambiguous type returns#35853

Merged
ryzngard merged 10 commits intodotnet:masterfrom
ryzngard:issue/35786_verifyforwardedtypes_null
Jun 4, 2019
Merged

Update FindImplementationsForInterfaceMemberAsync to correctly handle ambiguous type returns#35853
ryzngard merged 10 commits intodotnet:masterfrom
ryzngard:issue/35786_verifyforwardedtypes_null

Conversation

@ryzngard
Copy link
Copy Markdown
Contributor

@ryzngard ryzngard commented May 21, 2019

FindImplementationsForInterfaceMemberAsync checks for forwarded types using SymbolFinder.OriginalSymbolsMatch, which expects non-null compilation for both the project containing the interface and the project containing the symbol to compare to. Until now, most instances have found equivalence without falling through, but in cases where the type forwarding isn't completely verified a non-null compilation for the interface symbol is needed as well. See VerifyForwardedTypes for the logic being used.

In #35786 the type System.Text.Encoding is provided by a a NuGet reference and could be ambiguous based on the build target. The OOP service attempts to find the correct type resolution but needs the original symbol compilation to verify.

Without this fix, FindAllReferences may cause a null deref and fail.

Fixes #35786

@ryzngard ryzngard requested a review from heejaechang May 21, 2019 21:23
@ryzngard ryzngard requested a review from a team as a code owner May 21, 2019 21:23
@CyrusNajmabadi
Copy link
Copy Markdown
Contributor

Title of this should be changed to more explain what impact this has.

Copy link
Copy Markdown
Contributor

@CyrusNajmabadi CyrusNajmabadi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something seems fishy here.

Request changes
Submit feedback suggesting changes.

@ryzngard
Copy link
Copy Markdown
Contributor Author

@CyrusNajmabadi I updated the comment to better describe the issue.

@CyrusNajmabadi
Copy link
Copy Markdown
Contributor

@ryzngard did you push new commits? i'm not seeing them...

@ryzngard
Copy link
Copy Markdown
Contributor Author

@CyrusNajmabadi the only code change looked like the simplification of the null expression, which I hadn't pushed. Let me know if you have more concerns about this.

@CyrusNajmabadi
Copy link
Copy Markdown
Contributor

Any way to write a test for this?

@ryzngard ryzngard changed the title Also get the compilation for the interface symbol instead of passing null Update FindImplementationsForInterfaceMemberAsync to correctly handle ambiguous type returns May 23, 2019
@ryzngard
Copy link
Copy Markdown
Contributor Author

Any way to write a test for this?

Working on that now. I've updated the comment a bit more with details, since it still wasn't very clear what the problem was. Trying to get a repro in a test now.

@@ -180,7 +182,7 @@ public static async Task<ImmutableArray<SymbolAndProjectId>> FindImplementations
interfaceMember,
solution,
typeSymbolCompilation,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so, the input is basically, current symbol (actual implementation) and interface symbol (target interface symbol to match) ? and compilation of each symbol belong to?

wouldn't it be much cleaner if SymbolAndProjectId keep passed down and OriginalSymbolsMatch become Async method?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

by the way, when typeSymbolCompilation is null, VerifyForwardType seems doing this
http://source.roslyn.io/#Microsoft.CodeAnalysis.Workspaces/FindSymbols/SymbolFinder_Hierarchy.cs,508
to handle that case?

you might do the same for symbolToMatch?

I can see case where typeSymbolCompilation is null case?
http://source.roslyn.io/#Microsoft.CodeAnalysis.Workspaces/FindSymbols/FindReferences/Finders/AbstractReferenceFinder.cs,202

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't it be much cleaner if SymbolAndProjectId keep passed down and OriginalSymbolsMatch become Async method?

Maybe? At this time it'd be a lot of refactoring. I don't feel strongly enough that it would be cleaner, but if it would it should be a separate change.

@ryzngard
Copy link
Copy Markdown
Contributor Author

ryzngard commented Jun 3, 2019

@heejaechang @CyrusNajmabadi is there anything left blocking this?

Copy link
Copy Markdown
Contributor

@CyrusNajmabadi CyrusNajmabadi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope! LGTM. Thanks!

Approve
Submit feedback approving these changes.

@ryzngard ryzngard merged commit a094703 into dotnet:master Jun 4, 2019
@ryzngard ryzngard deleted the issue/35786_verifyforwardedtypes_null branch June 4, 2019 21:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

exception on "Find all references"

4 participants