ref readonly
returns should not return references to temps when used with PEVerifyCompat flag
#22721
Labels
Milestone
PEVerifyCompat forces readonly references of readonly fields be ftched off a copy (since direct references are not allowed by PEVerify).
The whole point of a ref return, however, is to return a direct reference.
We should not be returning references to temps in cases which specifically demand references such as ref returns and ref assignments, even if that causes PEverify failure, since returning a reference to a temp completely misses the point.
See testcase
ReadonlyFieldCanReturnByRefReadonly
as an example.The text was updated successfully, but these errors were encountered: