-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Unconstrained type parameter annotation proposal #3035
Conversation
|
||
`ITypeParameterSymbol.NullableAnnotation` will return `NullableAnnotation.Annotated` for `T??`, indistinquisable from `T?`. | ||
To determine if that type parameter annotation would be represented in source as `??` would require checking the | ||
constraints of the `ITypeParameterSymbol` which might involve checking constraints inherited from base types. |
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.
seems painful fwiw.
} | ||
``` | ||
|
||
`T??` may be used interchangably with `[MaybeNull]T` in cases where `T` is not constrained to a value type or reference 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.
I really hope this lands as T?
at the end - for the same reasons that the team were avoiding introducing T!
.
Furthermore, the fact that you need to change annotations T??
-> T?
if you add a constraint is a pain point.
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.
I really hope unconstrained T?
will sooner or later end up as an unconstrained T?
that is T?
for reference types or T?
for value types.
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.
I really hope unconstrained T? will sooner or later end up as an unconstrained T? that is T? for reference types or T? for value types.
That would probably require runtime changes but it's the ideal outcome. Personally I'm ok with [MaybeNull]
for the time being. T??
would be just an oddball that I don't want to have to deal with.
Sorry for posting here but I can't for the life of me find the discussion where @gafter and others are discussing unconstrained Would |
@mikernet, |
Looks like this finally implemented as BTW it's not documented in language feature status or https://github.com/dotnet/csharplang/tree/master/proposals/csharp-9.0 |
Replaced by support for |
No description provided.