Skip to content
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

Type argument nullability warning no longer reported for type parameter constrained to 'int?' #46410

Closed
cston opened this issue Jul 29, 2020 · 0 comments · Fixed by #46405
Closed
Assignees

Comments

@cston
Copy link
Member

cston commented Jul 29, 2020

A warning should be reported for M<T>(t) since T is constrained to int? which does not satisfy the notnull constraint.

#nullable enable
abstract class A<T, U> where T : notnull
{
    internal static void M<V>(V v) where V : T { }
    internal abstract void F<V>(V v) where V : U;
}
class B : A<System.ValueType, int?>
{
    internal override void F<T>(T t)
    {
        M<T>(t);
    }
}

This may be a regression from #45993. Earlier builds reported:

(11,9): warning CS8631: The type 'T' cannot be used as type parameter 'V' in the generic type or method
    'A<ValueType, int?>.M<V>(V)'. Nullability of type argument 'T' doesn't match constraint type 'System.ValueType'.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants