Handle unresolved value-type call targets - #4053
Merged
dgrunwald merged 2 commits intoSep 3, 2026
Merged
Conversation
1 task
dgrunwald
approved these changes
Aug 28, 2026
dgrunwald
reviewed
Aug 29, 2026
| IType expectedTargetType = constrainedTo ?? memberDeclaringType; | ||
| if (!(translatedTarget.Type is ByReferenceType brt | ||
| && (NormalizeTypeVisitor.TypeErasure.EquivalentTypes(brt.ElementType, expectedTargetType) | ||
| || (expectedTargetType.Kind == TypeKind.Unknown && brt.ElementType.ReflectionName == expectedTargetType.ReflectionName)))) |
Member
There was a problem hiding this comment.
The ReflectionName string comparison is now unnecessary with the change on #4070.
Contributor
Author
There was a problem hiding this comment.
Agreed. I removed the ReflectionName fallback and now rely solely on TypeErasure.EquivalentTypes after #4070. The single commit was force-pushed as d730ec0a2.
I also applied it without conflicts on current master (05d274ff7) and verified:
BuildTools/format.ps1: clean;- full
Release|Any CPUsolution build: 16 succeeded, 0 failed; - complete
ILPrettyTestRunner: 64 total, 63 passed, 1 pre-existing ignored, 0 failed.
A missing value-type definition makes ILReader insert a Ref-to-Unknown conversion before instance calls. Preserve the managed-reference receiver so C# output does not fall back to invalid ref casts or unsafe pointers. Assisted-by: Codex:gpt-5.6-sol:Codex
sonyps5201314
force-pushed
the
split/unresolved-value-type-call-targets
branch
from
August 30, 2026 11:07
e28fabc to
d730ec0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Related to #4049.
Problem
When an instance method belongs to a value type from a missing assembly, its declaring type has unknown stack semantics. ILReader inserts an invalid
Ref -> Unknownconversion around the managed-reference receiver.ExpressionBuilder.TranslateTargetthen treats the conversion as a value receiver and emits invalid C# such as:Solution
For the narrowly defined
Invalid,Ref -> Unknownconversion on an unresolved call target:UnwrapConvhelper to recover the original managed-reference receiver;This PR contains only this call-target fix and its
Issue3729regression case. It does not include constructor-initializer, primary-constructor, collection-expression, resolver, project export, or backing-field changes from #4049.Test
The ILPretty case was added first. Before the implementation it failed with an
unsafemethod, a(MyEnumerator)(ref value)cast, and a pointer dereference for the constrainedIDisposable.Disposecall.After the implementation:
ILPrettyTestRunner.Issue3729: passed.ILPrettyTestRunnerfixture: 63 total, 62 passed, 1 pre-existing ignored, 0 failed.Release|Any CPUsolution build: 16 succeeded, 0 failed.BuildTools/format.ps1: clean.