Adjust how NotNull interacts with MaybeNullWhen#42322
Conversation
| public class C | ||
| { | ||
| internal virtual bool TryGetValueCore<TKey, TValue>(TKey key, [MaybeNull] [NotNullWhen(false)] out TValue value) | ||
| where TKey : class |
There was a problem hiding this comment.
is TKey necessary to reproduce the issue (before the compiler change)?
There was a problem hiding this comment.
It's not. This came from the use case I ran into in an adoption PR. I'll remove the parameter :-)
|
Can you please explain the relationship between the bug (and its symptoms) and the bug fix? I would have expected you to be making a fix in the override checks. |
|
@gafter The overrides check computes the nullability of a value (from one of the signatures) and checks if it can be assigned to the type (from the other signature). This fix is so that we can assign a value from a |
In an override situation, we want to allow an assignment from a
[NotNull, MaybeNullWhen(true)] T parameterto an identical parameter.Fixes #42169