Open cston opened 2 years ago
In this bit, it seems like we weren't precisely correct in our assumptions on how the calls within interpolated string conversions could be formed. An unscoped in-parameter could come in here which we don't handle properly: https://github.com/dotnet/roslyn/blob/3a17b7bca601565f3629ac62e964e02312183eb7/src/Compilers/CSharp/Portable/Binder/Binder.ValueChecks.cs#L4131-L4135
I think we could avoid entirely making assumptions about the shape of the call here, and instead just pass it through the appropriate general purpose helper for calls (GetInvocationArgumentsForEscape or GetInvocationArgumentsForEscapeWithUpdatedRules in #62886). Another layer may be synthesizing the call within some limited set of constraints, but it doesn't matter to the escape analysis layer.
This is no longer a bug because the in
here is RTSE of return only so it can't be captured. A very related scenario is if a ref struct
is passed by value that is tracked by our current code. There is no test for that scenario though. This bug will now track updating the existign test for in
and adding a new test for passing a ref struct
by value
Expected: Escape analysis should report errors for the conversions from interpolated string to
CustomHandler
since a reference to the local is potentially returned to the calling method.Actual: No errors.