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

Don't generate nullable type when applying value type with unconstrained nullable generic #49154

Merged
merged 8 commits into from
May 17, 2021

Conversation

huoyaoyuan
Copy link
Member

Fixes #48742. Should prevent similar issue in other cases.

throw new System.NotImplementedException();
}
}");
}
Copy link
Member

Choose a reason for hiding this comment

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

can we a few more tests.

  1. where T is unconstrained
  2. where T is constrained to class.
  3. where T is unconstrained, and passed as T? to the base type
  4. where T is constrained to class, and passed as T? to the base type
  5. where T is constrained to struct, and passed as T? to the base type

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, make sure that other cases doesn't regress.

{
// value type with nullable annotation may be composed from unconstrained nullable generic
// doesn't mean nullable value type in this case
typeSyntax = AddInformationTo(SyntaxFactory.NullableType(typeSyntax), symbol);
}
Copy link
Member

Choose a reason for hiding this comment

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

what about other named types that can be value types. like tuples. can you update as well (or add tests showing they're k).

Copy link
Member Author

Choose a reason for hiding this comment

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

Are they special for this case? Here is adding top-level nullability, I couldn't imagine any type to have special semantics. The inner type has been handled above.

Copy link
Member

Choose a reason for hiding this comment

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

they're a named type that is a value type :) i just want to make sure it works properly and nothing unexpected happens.

Copy link
Member Author

Choose a reason for hiding this comment

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

Adding tests should be OK I think

@jinujoseph jinujoseph added the Community The pull request was submitted by a contributor who is not a Microsoft employee. label Nov 3, 2020
@huoyaoyuan
Copy link
Member Author

Well, this is actually duplicated by #49242 . The corresponding issue can be closed now.

@huoyaoyuan huoyaoyuan closed this Jan 6, 2021
@huoyaoyuan huoyaoyuan deleted the issue-48742 branch January 6, 2021 13:29
@huoyaoyuan
Copy link
Member Author

@CyrusNajmabadi this has more test coverage than #49242 . Idea?

@CyrusNajmabadi
Copy link
Member

@CyrusNajmabadi this has more test coverage than #49242 . Idea?

You can reopen and just include the tests you want to add. Thanks!

@huoyaoyuan huoyaoyuan restored the issue-48742 branch January 6, 2021 16:22
@huoyaoyuan huoyaoyuan reopened this Jan 6, 2021
@huoyaoyuan
Copy link
Member Author

I think it's better to keep this PR, because it adds more comment and addresses another position.

Base automatically changed from master to main March 3, 2021 23:53
@huoyaoyuan
Copy link
Member Author

@CyrusNajmabadi Idea on this? Do you think it's worth to keep it?

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@CyrusNajmabadi CyrusNajmabadi merged commit ac43b83 into dotnet:main May 17, 2021
@ghost ghost added this to the Next milestone May 17, 2021
@huoyaoyuan huoyaoyuan deleted the issue-48742 branch May 17, 2021 20:41
@RikkiGibson RikkiGibson modified the milestones: Next, 17.0.P2 Jun 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Community The pull request was submitted by a contributor who is not a Microsoft employee.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement abstract class incorrect for unconstrained generic nullable in base and value type in derived
6 participants