Skip to content

Decline the compiled-invoker fast lane for custom type converters and foreign receivers#2737

Merged
lahma merged 1 commit into
sebastienros:mainfrom
lahma:fix/compiled-invoker-gates
Jul 22, 2026
Merged

Decline the compiled-invoker fast lane for custom type converters and foreign receivers#2737
lahma merged 1 commit into
sebastienros:mainfrom
lahma:fix/compiled-invoker-gates

Conversation

@lahma

@lahma lahma commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Pre-release review follow-up to #2733. Two behavior-parity gaps in the exact-type compiled fast lane, both verified with repros against 4.13 behavior:

  1. Custom ITypeConverter bypass. The gate checked _objectConverters but not the engine's user-replaceable TypeConverter. The reflection path consults it for some exact-type argument conversions (a bool argument under default value coercion flows through converter.TryConvert), so a converter installed via SetTypeConverter that vetoes/transforms those conversions was silently skipped and calls succeeded that previously failed (or were transformed). The lane now requires the exact DefaultTypeConverter type — TryConvert is virtual, so an is check would not do.
  2. Foreign-receiver exception drift. var f = host.method; f.call(other) surfaced InvalidCastException from the compiled receiver cast instead of the reflection path's TargetException. Host catch clauses and Interop.ExceptionHandler predicates key on the exception type. The lane now declines when the receiver is not an instance of the declaring type (one isinst per call), letting the slow path surface the original exception shape.

Both new tests fail without the gate changes (verified by reverting). Full suite green on net10.0 + net472.

🤖 Generated with Claude Code

https://claude.ai/code/session_0115tQFNyyQqc1HQGPLUgZND

… foreign receivers

Two behavior-parity gaps in the sebastienros#2733 exact-type fast lane found in
pre-release review:

- The lane's gate checked custom IObjectConverters but not the engine's
  user-replaceable ITypeConverter. The reflection path consults the
  converter for some exact-type argument conversions (e.g. bool under
  default value coercion), so a custom converter installed via
  SetTypeConverter was silently bypassed. The lane now requires the
  exact DefaultTypeConverter.
- An extracted instance method invoked with a wrong-typed this
  (f.call(foreignObject)) surfaced InvalidCastException from the
  compiled receiver cast instead of the reflection path's
  TargetException, which host code and Interop.ExceptionHandler
  predicates key on. The lane now declines when the receiver is not an
  instance of the declaring type so the slow path surfaces the original
  exception shape.

Both new tests fail without the gate changes.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0115tQFNyyQqc1HQGPLUgZND
@lahma
lahma merged commit 66353d0 into sebastienros:main Jul 22, 2026
4 checks passed
@lahma
lahma deleted the fix/compiled-invoker-gates branch July 22, 2026 10:13
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.

1 participant