Skip to content

Fix generic interface method dispatch for multi-argument types#3453

Merged
josesimoes merged 2 commits into
nanoframework:developfrom
josesimoes:fix-interface-dispatch
Jun 30, 2026
Merged

Fix generic interface method dispatch for multi-argument types#3453
josesimoes merged 2 commits into
nanoframework:developfrom
josesimoes:fix-interface-dispatch

Conversation

@josesimoes

Copy link
Copy Markdown
Member

Description

  • Loop variable reuse destroyed GenParamCount; KeyValuePair<TKey,TValue> only drained first arg, desynchronized parsers

Motivation and Context

  • Fixes explicit interface impl resolution for Dictionary<TKey,TValue> (Remove, Contains, GetEnumerator)
  • Generic VAR↔GENERICINST signature matching was dropping arguments when draining nested generic instances
  • Drain sub-tree by converging Available() instead of counting arguments by hand
  • Surfaced from Sys.Collections unit tests failing.
  • Related with Support for generics <T> Home#782.

How Has This Been Tested?

Screenshots

Types of changes

  • Improvement (non-breaking change that improves a feature, code or algorithm)
  • Bug fix (non-breaking change which fixes an issue with code or algorithm)
  • New feature (non-breaking change which adds functionality to code)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Config and build (change in the configuration and build system, has no impact on code or features)
  • Dev Containers (changes related with Dev Containers, has no impact on code or features)
  • Dependencies/declarations (update dependencies or assembly declarations and changes associated, has no impact on code or features)
  • Documentation (changes or updates in the documentation, has no impact on code or features)

Checklist

  • My code follows the code style of this project (only if there are changes in source code).
  • My changes require an update to the documentation (there are changes that require the docs website to be updated).
  • I have updated the documentation accordingly (the changes require an update on the docs in this repo).
  • I have read the CONTRIBUTING document.
  • I have tested everything locally and all new and existing tests passed (only if there are changes in source code).

- Loop variable reuse destroyed GenParamCount; KeyValuePair<TKey,TValue> only drained first arg, desynchronized parsers
@josesimoes josesimoes added the Area: Interpreter Everything related with the interpreter, execution engine and such label Jun 30, 2026
@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: ASSERTIVE

Plan: Pro

Run ID: 52d0de23-29f7-48ed-8328-e4d866de0df5

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@josesimoes

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Caution

Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted.

Error details
{}

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/CLR/Core/TypeSystem.cpp`:
- Around line 9119-9147: Refactor the duplicated drain logic in
MatchSignatureForVirtualDispatch by extracting the repeated parser.Advance loop
into a small helper such as DrainGenericInstSubtree. Both
DATATYPE_VAR/DATATYPE_GENERICINST branches should call the helper with the
appropriate CLR_RT_SignatureParser instance and targetAvail value, then continue
on success or return false on failure. Keep the helper near TypeSystem.cpp so
the two branches in MatchSignatureForVirtualDispatch are flattened and the
nesting/duplication is removed.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: ASSERTIVE

Plan: Pro

Run ID: d69393eb-6e41-445b-8d74-feddbfc49951

📥 Commits

Reviewing files that changed from the base of the PR and between 7bddd3e and 42ef6c4.

📒 Files selected for processing (1)
  • src/CLR/Core/TypeSystem.cpp

Comment thread src/CLR/Core/TypeSystem.cpp
@josesimoes
josesimoes enabled auto-merge (squash) June 30, 2026 12:29
@josesimoes
josesimoes merged commit e2d3497 into nanoframework:develop Jun 30, 2026
29 checks passed
@josesimoes
josesimoes deleted the fix-interface-dispatch branch June 30, 2026 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Interpreter Everything related with the interpreter, execution engine and such Type: bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants