[mono][interp] Fix GetType called on ptr constrained to Nullable` (#61020)
authorVlad Brezae <brezaevlad@gmail.com>
Thu, 4 Nov 2021 21:24:26 +0000 (23:24 +0200)
committerGitHub <noreply@github.com>
Thu, 4 Nov 2021 21:24:26 +0000 (16:24 -0500)
commitc02a37c569b8d8a283c771703c86556aa7593017
treefae7d805ddd8010dca3794874dec88dee3e1d4d0
parentd216c7c15cb0080342f1191368afc7e5be172de0
[mono][interp] Fix GetType called on ptr constrained to Nullable` (#61020)

* [interp] Fix GetType called on ptr constrained to Nullable`

We were statically optimizing this call to return the actual constrained class type, which is incorrect for nullables, because boxing of a nullable (as part of the constrained call) actually creates an object with the type of the nullable's value (or null if there is no value).

* Add test for GetType call on ptr constrained to nullable
src/mono/mono/mini/interp/transform.c
src/tests/JIT/Directed/nullabletypes/gettype.cs [new file with mode: 0644]
src/tests/JIT/Directed/nullabletypes/gettype_d.csproj [new file with mode: 0644]
src/tests/JIT/Directed/nullabletypes/gettype_do.csproj [new file with mode: 0644]
src/tests/JIT/Directed/nullabletypes/gettype_r.csproj [new file with mode: 0644]
src/tests/JIT/Directed/nullabletypes/gettype_ro.csproj [new file with mode: 0644]