-
Notifications
You must be signed in to change notification settings - Fork 4.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
Collection expression arguments: support [CollectionBuilder] factory methods #76998
base: features/dictionary-expressions
Are you sure you want to change the base?
Collection expression arguments: support [CollectionBuilder] factory methods #76998
Conversation
da3c3e3
to
6c4fc7e
Compare
Diagnostic(ErrorCode.WRN_NullabilityMismatchInTypeParameterNotNullConstraint, "[null]").WithArguments("MyCollectionBuilder.Create<T>(System.ReadOnlySpan<T>)", "T", "string?").WithLocation(7, 28), | ||
//// (7,28): warning CS8714: The type 'string?' cannot be used as type parameter 'T' in the generic type or method 'MyCollectionBuilder.Create<T>(ReadOnlySpan<T>)'. Nullability of type argument 'string?' doesn't match 'notnull' constraint. | ||
//// MyCollection<string?> x1 = [null]; // 1 | ||
//Diagnostic(ErrorCode.WRN_NullabilityMismatchInTypeParameterNotNullConstraint, "[null]").WithArguments("MyCollectionBuilder.Create<T>(System.ReadOnlySpan<T>)", "T", "string?").WithLocation(7, 28), |
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.
This case was previously handled in Binder.GetAndValidateCollectionBuilderMethod()
in the call to collectionBuilderMethod.CheckConstraints()
. That was unintentional, because initial binding should check type constraints but not nullability constraints. Nullability constraints should be checked in NullableWalker
, and the existing work item in #68786 covers that.
242f3ea
to
399140a
Compare
399140a
to
f826cdb
Compare
d8277bf
to
fb0b649
Compare
fb0b649
to
c45c03a
Compare
fd9db56
to
e6301bb
Compare
Binding and lowering of collection expression arguments for target types that are constructed using
[CollectionBuilder]
factory methods.See proposals/collection-expression-arguments.md