Check implicit receiver in nested initializers#34141
Conversation
There was a problem hiding this comment.
Perhaps we should consider putting the warning on the f = part, and not the f2 and f3 parts. I don't think it's immediately obvious why there's an error on f2 or f3. #Closed
There was a problem hiding this comment.
It still won't be obvious, but I adjusted the location a bit ;-) #Closed
There was a problem hiding this comment.
Please add tests for:
When f is both not null and when it's defined in an oblivious context.
Doubly nested (Do we warn on both the nested f2 = { ... } and the outer f = { f2 = { ... } }?)
Object initializer inside an indexer that returns a nullable reference.
There was a problem hiding this comment.
|
Done review pass (commit 2). Would like some more tests. |
There was a problem hiding this comment.
fc [](start = 18, length = 2)
What I meant was making fc here nullable as well: namely, what will happen when there's potential nested null derefs.
|
There was a transient failure in one of the async-iterator tests. I filed issue to investigate further: #34207 |
|
@cston @dotnet/roslyn-compiler for a second review. Thanks |
| // (6,14): warning CS8618: Non-nullable field 'f' is uninitialized. | ||
| // public class C | ||
| Diagnostic(ErrorCode.WRN_UninitializedNonNullableField, "C").WithArguments("field", "f").WithLocation(6, 14) | ||
| ); |
There was a problem hiding this comment.
); [](start = 16, length = 2)
Shouldn't we report CS8602: Possible dereference here too?
Fixes #32495