Handle ref-containing structs returned by value from function-pointers#49883
Handle ref-containing structs returned by value from function-pointers#49883333fred merged 3 commits intodotnet:masterfrom
Conversation
|
@dotnet/roslyn-compiler for review. |
Please look for other instances where we perform similar kind check or a type check and confirm that we are not missing a check for function pointers. Refers to: src/Compilers/CSharp/Portable/Binder/Binder.ValueChecks.cs:2041 in b1dc76d. [](commit_id = b1dc76d, deletion_comment = False) |
Co-authored-by: Jared Parsons <jaredpparsons@gmail.com>
Looked through these cases. I only found one assert in the local rewriter around ensuring that a compound assignment LHS that got to this point has a ref-returning method. |
…r has a ref-returning signature if it got to local rewriting.
| break; | ||
|
|
||
| case BoundKind.FunctionPointerInvocation: | ||
| Debug.Assert(((BoundFunctionPointerInvocation)originalLHS).FunctionPointer.Signature.RefKind != RefKind.None); |
There was a problem hiding this comment.
Debug.Assert(((BoundFunctionPointerInvocation)originalLHS).FunctionPointer.Signature.RefKind != RefKind.None); [](start = 20, length = 110)
Do we have a test covering this code path?
There was a problem hiding this comment.
Yep, the positive test I added hits this.
* upstream/master: (241 commits) Allow pattern matching `null` against pointer types when the pointer types contain nested type parameters (dotnet#49915) Remove document extension method and convert usages to use the text buffer extension method. VB: Strengthen implementation of `PropertySymbol.IsWritable` against NullReferenceException (dotnet#49962) Add switch to skip nullable analysis (dotnet#49876) Update dependencies from https://github.com/dotnet/roslyn build 20201211.16 (dotnet#49958) Treat record positional parameters as properties (dotnet#48329) [master] Update dependencies from dotnet/roslyn (dotnet#49395) VB: Ensure array access indexes undergo conversion to integer even when there is a mismatch with array rank. (dotnet#49907) Disable OOP when running as cloud environment client VS instance Rename workspace context method (and unify impls) to better represent the condition being checked Report non-Const locals used in an expression that must have a constant value. (dotnet#49912) Add support for more ServiceAudience values (dotnet#49914) Handle ref-containing structs returned by value from function-pointers (dotnet#49883) Fix error on out param of extern local function (dotnet#49860) Fix constructor exit warnings for generic NotNull (dotnet#49841) Loc updates Prefer more specific path map key (dotnet#49670) Rename `_availablelocalFunctionOrdinal` to `_availableLocalFunctionOrdinal` (dotnet#49901) Fix namespace so that external access wrapper type can be accessed from UT. XamlProjectService fixes (dotnet#49711) ...
My fix for #49315 missed the case of ref-containing types like Span being returned by value, instead of by reference. We now check that case as well. Fixes #49760.