Fix #4137: Keep nint in conditionals with mixed native int branches
When the branches of a conditional have different types, its type falls back to the IL stack slot type, which is (U)IntPtr. IntroduceNativeIntTypeOnLocals only retypes variables, so with native integers enabled the branches got cast to IntPtr. Map (U)IntPtr to n(u)int the same way boxing does; pointer types are unaffected.
This commit is contained in:
1 parent
197acf8cbe
commit
999d3b48fa
2 files changed
+24
-10
No files matched your search
@@ -254,5 +254,10 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
|
||||
// Explicit `unchecked` is necessary when casting oversized constant to nuint
|
||||
return unchecked((nuint)9123123123123uL);
|
||||
}
|
||||
|
||||
public nint ConditionalWithMixedBranchTypes(bool b, int i, nuint x, nint y)
|
||||
{
|
||||
return (b ? ((nint)i) : ((nint)x)) - y;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user