Skip to content
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

Report error creating delegate from partial generic method without implementation #73060

Merged
merged 3 commits into from
Apr 17, 2024

Conversation

cston
Copy link
Member

@cston cston commented Apr 17, 2024

Fixes #72431.

@cston cston requested a review from a team as a code owner April 17, 2024 06:37
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Apr 17, 2024
@@ -2788,7 +2788,7 @@ static ErrorCode getRefMismatchErrorCode(TypeKind type)
return true;
}

var sourceMethod = selectedMethod as SourceOrdinaryMethodSymbol;
var sourceMethod = selectedMethod.OriginalDefinition as SourceOrdinaryMethodSymbol;
if (sourceMethod is object && sourceMethod.IsPartialWithoutImplementation)
Copy link
Contributor

@AlekseyTs AlekseyTs Apr 17, 2024

Choose a reason for hiding this comment

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

IsPartialWithoutImplementation

Consider checking other use sites of this API #Resolved

Copy link
Member Author

Choose a reason for hiding this comment

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

There was only one other use of IsPartialWithoutImplementation, in CallsAreOmitted().

Copy link
Contributor

@AlekseyTs AlekseyTs left a comment

Choose a reason for hiding this comment

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

LGTM (commit 1)

@AlekseyTs
Copy link
Contributor

AlekseyTs commented Apr 17, 2024

Consider adding similar tests for VB #Resolved

@cston
Copy link
Member Author

cston commented Apr 17, 2024

Consider adding similar tests for VB

Thanks, the same issue existed in VB.


In reply to: 2061785068

{
static void Main()
{
M1(M2<int>);
Copy link
Contributor

@RikkiGibson RikkiGibson Apr 17, 2024

Choose a reason for hiding this comment

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

Is there also a bug when using a method group like GenericType<int>.PartialMethod? #Resolved

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, tested in _03. For that case, previously, the assembly was emitted without errors but the IL contained a reference to a missing method.

@cston cston changed the title Report CS0762 creating delegate from partial generic method without implementation Report error creating delegate from partial generic method without implementation Apr 17, 2024
Copy link
Contributor

@AlekseyTs AlekseyTs left a comment

Choose a reason for hiding this comment

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

LGTM (commit 3)

@cston cston merged commit 7569a2a into dotnet:main Apr 17, 2024
24 checks passed
@cston cston deleted the 72431 branch April 17, 2024 20:30
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Apr 17, 2024
@dibarbet dibarbet modified the milestones: Next, 17.11 P1 Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

KeyNotFoundException thrown when compiling optional generic partial methods (no modifier)
4 participants