You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Microsoft Visual Studio Professional 2022
Version 17.8.0 Preview 2.0
VisualStudio.17.Preview/17.8.0-pre.2.0+34112.27
Microsoft .NET Framework
Version 4.8.09037
Expected Behavior:
A warning is reported for the intercepted call c.Method1(x) which is translated into C.Interceptor1<string?>(x); because the type argument doesn't satisfy the where T: notnull constraint on the interceptor method
Actual Behavior:
No warnings at all. The code crashes at runtime with a NullReferenceException
The problem here is that the interceptor's type parameter constraints are checked during lowering. At that point, the nullable-reinferred version of the call has been discarded, and we are lowering the initially-bound version of the call.
It's not straightforward to solve, unfortunately, and I think I'd want to pursue some of the longer-term design questions before investing effort into solving it.
Version Used:
Steps to Reproduce:
Compile the following code:
Expected Behavior:
A warning is reported for the intercepted call
c.Method1(x)
which is translated intoC.Interceptor1<string?>(x);
because the type argument doesn't satisfy thewhere T: notnull
constraint on the interceptor methodActual Behavior:
No warnings at all. The code crashes at runtime with a
NullReferenceException
[jcouv update:] Relates to test plan #67421
The text was updated successfully, but these errors were encountered: