[release/8.0] [mono][interp] Fix type of args when inlining method #102801
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport of #102570 to release/8.0-staging. Fix for #102046
Customer Impact
When using interpreter, inlining a method that has its argument the result of a ternary conditional operator, could lead to an assumption that the argument is of the wrong type. This is a regression from NET7 because in this release we started to devirtualize calls based on the type of objects and when inlining we attempt to get the real type of arguments from the parent method. This issue was reported by customer in BlazorWasm with a simple repro consisting of a list of items so it looks like it can be easily hit. Since reproduction of this issue relies on inlining to happen, it was probably noticed this late in the release cycle since it needs for the problematic method to be tiered up.
Testing
Tested the fix locally on top of 8.0 release branch with the customer provided sample. CI PR testing without issues.
Risk
Low. There are other more conservative fixes like obtaining the type of the arg from the inlined method signature (like it was done in .NET7) or completely disabling devirtualization. In my opinion the fix in this PR is simple enough that reverting behavior is not necessary.