-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Suppress ERR_BadRetType and ERR_MethDelegateMismatch for delegate conversions with omitted type arguments #81278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Copilot
wants to merge
11
commits into
main
Choose a base branch
from
copilot/fix-extension-method-type-error
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+40
−5
Draft
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
1842f92
Initial plan
Copilot 913b839
Fix: Suppress ERR_BadRetType when return type contains type parameters
Copilot 78786f7
Simplify fix to check ContainsErrorType only
Copilot 8e1be16
Remove Binder_Conversions.cs change and handle ERR_MethDelegateMismat…
Copilot dc326a1
Fix formatting: remove trailing whitespace from blank lines
Copilot 45ce1e2
Simplify
CyrusNajmabadi 878ac15
Add test and fix for parameter types with omitted type arguments
Copilot 703d298
Use raw string literal in test
Copilot 14d1ba2
Add WorkItem attribute to test
Copilot f5ec480
Update src/Compilers/CSharp/Portable/Binder/Semantics/Conversions/Con…
CyrusNajmabadi c7ac7e5
Indent raw string literal and rename Foo to Goo
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot you made two changes to the code. Are there tests demonstrating the effect of each change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The existing test at line 3785 (
System.Func<object> delegateConversion1 = "string literal".ExtensionMethod1<>;) exercises both changes. During method group conversion to a delegate type:HadReturnMismatchin OverloadResolutionResult.cs if the return type doesn't matchMethodIsCompatibleWithDelegateOrFunctionPointerin Binder_Conversions.cs verifies the delegate compatibilityBoth code paths suppress ERR_BadRetType when the return type contains error types (from omitted type arguments). The test verifies that the confusing ERR_BadRetType error with
?symbols is no longer reported for this scenario, confirming both changes work correctly together.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot this is a good update that validates the case where the return type contains an error type.
Can you add a test after this that is a trimmed down version of this, except that the extension method has this form:
public static void ExtensionMethod1<T>(this object obj, T t) { }and assigns toAction<object>.Let's see if we have a similar problem where we report
?for the parameter type. If not, then we don't need to do anything more. If we see a similar problem, then we should update our checks accordingly to check parameters as well as return type.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added test in commit 878ac15. The same issue exists for parameter types - ERR_MethDelegateMismatch was being reported. Extended the fix to also check for error types in method parameters, not just return types. Both tests now pass.