Comments (4)
As a user, either warnings would be fine. I'm getting a NRT warning, and it's effectively telling me that object!
and object?
are going to be a problem. That's literally all that matters, and the exact verbiage isn't really going to matter to me :)
from csharplang.
How about a combination of option 1 with another language rule - if it has IEnumerable<T>
and void Add(T? item) { ... }
, produce a new NRT warning about inconsistent surface area?
class C<T> : IEnumerable<T>
{
...
public void Add(T? t) { }
}
C<object> c1 = [maybeNull]; // 2 warnings: the iteration type is `object!` but the element is maybe-null `object`,
// and `Add` is incompatible with `IEnumerable<>`
from csharplang.
Discussed in LDM 11/15. In short, we're going with option 1 (check conversion of elements to iteration type).
from csharplang.
Discussed in LDM on https://github.com/dotnet/csharplang/blob/main/meetings/2023/LDM-2023-11-15.md#nullability-analysis-of-collection-expressions.
from csharplang.
Related Issues (20)
- More user-friendly Compile-time type checking / 更加人性化的编译时类型检查 HOT 2
- Feature Request: Syntax Sugar for AddRange in List Initialization
- [Proposal]: request support for the ISO 8601 standard 24:00:00 time format in C# HOT 2
- C#: foreach breaking when the IEnumerator.MoveNext method throws exceptions HOT 2
- [Proposal]: Dictionary expressions HOT 90
- strong typed CallerAttributes like CallerMemberName CallerArgumentExpression HOT 2
- CS8509 - Consider Exhaustiveness For Algebraic Data Types HOT 17
- [Proposal]: Implementation specific documentation HOT 2
- [Proposal]: First-Class Span Types HOT 30
- [Proposal]: Collection Expressions Next (C#13 and beyond) HOT 46
- Open issues: Breaking changes HOT 27
- [Proposal]: Field and value as contextual keywords HOT 33
- [Proposal]: Extended identifier syntax
- [API Proposal]: IsNullableAttribute to flow nullability of generic type parameters into methods HOT 4
- Anonymous type optimization HOT 5
- Feature Request: Recursively Foreach
- Compiler can't determine best common type for `switch` expression HOT 8
- [Proposal]: Relax `Add` requirement for collection expression conversions to types implementing `IEnumerable` HOT 2
- [Proposal]: Proposal for Allowing Single-Element Tuples in Type Definitions HOT 2
- [Proposal]: Params collections and older language versions
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from csharplang.