Skip to content

fix: bind lambdas to imported byref delegates#2806

Merged
DavidObando merged 8 commits into
mainfrom
fix/issue-2802
Jul 25, 2026
Merged

fix: bind lambdas to imported byref delegates#2806
DavidObando merged 8 commits into
mainfrom
fix/issue-2802

Conversation

@DavidObando

Copy link
Copy Markdown
Owner

Summary

  • normalize imported delegate byref parameter value shapes while preserving exact in/ref/out metadata
  • propagate ref-kinds through lambda binding, overload resolution, lowering, closure emission, and delegate invocation
  • use canonical parameter signature encoding so in modreqs match between definitions and member references
  • support generic imported and source-defined byref delegates and method-group conversions
  • report precise ref-kind mismatches instead of GS0159 or GS9998

Security

Exact ref-kind validation prevents unsafe byref aliasing, mutation, overload confusion, and signature drift. Independent Opus 4.8 reviews found no remaining security or correctness issues.

Tests

  • dotnet test test/Compiler.Tests/Compiler.Tests.csproj --filter FullyQualifiedName~ImportedMemberMatrix --no-restore --nologo
  • dotnet test test/Core.Tests/Core.Tests.csproj --filter FullyQualifiedName~RefKindParameter --no-restore --nologo
  • full Core suite and focused delegate/method-group regressions were also exercised during review

Closes #2802

DavidObando and others added 8 commits July 24, 2026 14:50
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 5a96d2bd-106a-4cb2-87ee-cef68a8a77f9
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 5a96d2bd-106a-4cb2-87ee-cef68a8a77f9
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 5a96d2bd-106a-4cb2-87ee-cef68a8a77f9
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 5a96d2bd-106a-4cb2-87ee-cef68a8a77f9
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 5a96d2bd-106a-4cb2-87ee-cef68a8a77f9
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 5a96d2bd-106a-4cb2-87ee-cef68a8a77f9
Use the bound DelegateTypeSymbol signature for strict lambda conversion checks so source and imported delegates enforce identical ref/out/in matching.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 5a96d2bd-106a-4cb2-87ee-cef68a8a77f9
Read ref/out/in metadata from bound source and CLR method groups so delegate conversions and overload ranking validate the actual callable signature.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 5a96d2bd-106a-4cb2-87ee-cef68a8a77f9
@DavidObando
DavidObando merged commit a3babf9 into main Jul 25, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gsc: lambda argument cannot bind to imported C# delegate with an in parameter (GS0159)

1 participant