-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Closed
Copy link
Labels
4 - In ReviewA fix for the issue is submitted for review.A fix for the issue is submitted for review.Area-CompilersBugFeature - Nullable Reference TypesNullable Reference TypesNullable Reference Types
Description
The issue regards type inference in M3 versus M4 below. Both should have the same annotation for the type argument, either unannotated, or oblivious. Which it is may depend on the outcome of #34843, but in any case they should be the same. And yet we report diagnostics for the type arguments in M3 but not in M4. It is possible that the problem is that we do not check the inferred type argument against the constraints in M4. Either way, they should be treated the same and either there should be warnings on both or neither.
See also #30214
#nullable disable
class A<T1, T2, T3> where T2 : class where T3 : object
{
T1 F1;
T2 F2;
T3 F3;
B F4;
#nullable enable
void M3()
{
C.Test<T1>(); // warning given here
C.Test<T2>(); // warning given here
C.Test<T3>(); // warning given here
}
void M4()
{
D.Test(F1); // no warning given here
D.Test(F2); // no warning given here
D.Test(F3); // no warning given here
D.Test(F4);
}
}
class B {}
class C
{
public static void Test<T>() where T : object
{}
}
class D
{
public static void Test<T>(T x) where T : object
{}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
4 - In ReviewA fix for the issue is submitted for review.A fix for the issue is submitted for review.Area-CompilersBugFeature - Nullable Reference TypesNullable Reference TypesNullable Reference Types