Skip to content

Address false positive cases for return value codefix - #38410

Closed
Ron Buckton (rbuckton) wants to merge 2 commits into
masterfrom
fixCheckInReturnValueCodefix
Closed

Address false positive cases for return value codefix#38410
Ron Buckton (rbuckton) wants to merge 2 commits into
masterfrom
fixCheckInReturnValueCodefix

Conversation

@rbuckton

Copy link
Copy Markdown
Contributor

In #26434 we added a code fix that can insert a return statement in places where it is missing, however the code fix has a step that is intended to verify that the resulting return expression will be correctly assignable. Unfortunately, this code fix attempts to type check a purely synthetic AST with no original pointer set, which results in the call to checker.getTypeAtLocation essentially returning any. This results in false-positives for code fixes that should not be valid.

This changes the code fix to instead leverage the checker.createSignature and checker.createAnonymousType functions to synthesize the expected type for comparison.

@rbuckton
Ron Buckton (rbuckton) force-pushed the fixCheckInReturnValueCodefix branch from 0c78eff to bd53776 Compare May 8, 2020 00:11

@Kingwl Wenlu Wang (Kingwl) left a comment

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.

Thanks!

@weswigham

Copy link
Copy Markdown
Member

Ron Buckton (@rbuckton) you planning on merging this? 😄

@rbuckton

Copy link
Copy Markdown
Contributor Author

It looks like this was updated and merged as part of #35282.

@microsoft Microsoft (microsoft) locked as resolved and limited conversation to collaborators Oct 21, 2025
@jakebailey
Jake Bailey (jakebailey) deleted the fixCheckInReturnValueCodefix branch August 28, 2026 19:35
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

5 participants