Skip to content

[mono][interp] Fix GetType called on ptr constrained to Nullable` - #61020

Merged
lewing merged 2 commits into
dotnet:mainfrom
BrzVlad:fix-interp-nullable-gettype
Nov 4, 2021
Merged

[mono][interp] Fix GetType called on ptr constrained to Nullable`#61020
lewing merged 2 commits into
dotnet:mainfrom
BrzVlad:fix-interp-nullable-gettype

Conversation

@BrzVlad

Copy link
Copy Markdown
Member

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).

Fixes#61007

@ghost

Copy link
Copy Markdown

Tagging subscribers to this area: @BrzVlad
See info in area-owners.md if you want to be subscribed.

Issue Details

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).

Fixes #61007

Author:BrzVlad
Assignees:-
Labels:

area-Codegen-Interpreter-mono

Milestone:-

@lewing

Copy link
Copy Markdown
Member

/backport to release/6.0

@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to release/6.0: https://github.com/dotnet/runtime/actions/runs/1400673059

@radical

Copy link
Copy Markdown
Member

This needs a test.

@BrzVlad

Copy link
Copy Markdown
MemberAuthor

@radical Any recommendation where ? In the runtime tests ?

@radical

Copy link
Copy Markdown
Member

@radical Any recommendation where ? In the runtime tests ?

Adding in runtime tests makes sense.

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).
@BrzVlad
BrzVladforce-pushed the fix-interp-nullable-gettype branch from 0e9493b to 989f46dCompareNovember 1, 2021 11:14
@BrzVlad

Copy link
Copy Markdown
MemberAuthor
  1. Added a test case. Set the priority to 0 for now so it gets to run on this PR on all configurations. I think I should leave it with priority 1, although I have no idea what are the guidelines around test priorities.
  2. Changed the fix so it is a bit more reasonable. With the previous fix we were hitting some confusing code paths. Also this fix prevents addition of a cknull and some redundant inlining.

@BrzVlad
BrzVladforce-pushed the fix-interp-nullable-gettype branch from 989f46d to 92ee613CompareNovember 1, 2021 13:30
@lewing

Copy link
Copy Markdown
Member

/backport to release/6.0

@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to release/6.0: https://github.com/dotnet/runtime/actions/runs/1413414901

@lewing
lewing merged commit c02a37c into dotnet:mainNov 4, 2021
BrzVlad added a commit to BrzVlad/runtime that referenced this pull request Nov 8, 2021
…tnet#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
Anipik pushed a commit that referenced this pull request Nov 12, 2021
…1020) (#61305)
* [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
@ghostghost locked as resolved and limited conversation to collaborators Dec 5, 2021
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.NET 6.0 blazor wasm project reports an incorrect type

5 participants

@BrzVlad@lewing@radical@vargaz@lambdageek