mirror of https://github.com/icsharpcode/ILSpy.git
Browse Source
NullPropagationTransform only rewrites "x != null ? x.Chain : fallback" into "x?.Chain ?? fallback" when the chain's inferred type is a non-nullable value type, and InferType had no case for ldlen. Array length therefore came back as UnknownType, so "arr?.Length ?? 0" was left as a ternary. The inferred type mirrors ExpressionBuilder.VisitLdLen, which decides between Array.Length and Array.LongLength from the result type alone. Found while investigating #3704, where the surviving ternary also keeps the tested array in a stack slot and strands the typeof of a dynamic call's static target. That issue is fixed separately in #4072, whose DynamicTests cases pinned the ternary as expected output; those blocks round-trip exactly now, so they are gone. Also carries a review follow-up that missed #4072: the static-target test in VisitDynamicInvokeMemberInstruction is a plain null check, the way DynamicInvokeMemberInstruction itself tests the field, rather than a pattern match binding a name it does not need. Assisted-by: Claude:claude-opus-5[1m]:Claude Codepull/4075/head
4 changed files with 24 additions and 59 deletions
Loading…
Reference in new issue