Repository navigation
Conversation
…nsions
A CLR method group is stored in the method table under the name it was looked
up by: w.describe stores Widget's Describe overloads under "describe". When
using_clr_extensions activated more Describe overloads, the groups were
invalidated under the extension's CLR name, "Describe", so the group under
"describe" survived and kept serving the old overloads. A call that resolved
describe before the activation made describe("x") a TypeError (no conversion
of String into Integer) afterwards, and method(:describe) returned the same
stale group. This affected extensions on a class, on an interface, and on a
generic definition (List[Integer]#count before System::Linq lost
Enumerable.Count's overloads).
The invalidation now covers the mangled name as well as the CLR name.
ClrExtensionMethods6-8 cover a class, its CLR and Ruby subclasses and
method(:describe); an interface and a generic type definition; and
List#count with System::Linq.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 29, 2026
Owner
Author
|
Moved upstream: Largo#43. The branch stays. |
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.
A CLR method called before
using_clr_extensionsnever saw the extension overloads the activation added.Without the first
w.describe, the last line returns the extension's result.Cause
IronRuby caches a CLR method group in the class's method table under the name it was looked up by, so
w.describefiles Widget'sDescribeoverloads underdescribe. Whenusing_clr_extensionsadded moreDescribeoverloads,RubyClass.PrepareExtensionMethodsUpdatecleared the cached groups under the CLR nameDescribeand nothing else. The group underdescribesurvived and kept serving the old overloads, andmethod(:describe)returned it too. Callingw.Describeworked, which is what gave the cause away.Extensions on interfaces and generic type definitions went stale the same way. After one
List[Integer]#countcall,using_clr_extensions System::Linqcould no longer addEnumerable.Count's overloads, solist.count(->(x) { x > 1 })raised an ArgumentError.Fix
PrepareExtensionMethodsUpdatenow clears the cached groups under the Ruby name as well as the CLR name, once per distinct name. An exact signature tie still goes to the instance method.Tests
The fixture is a new
IronRubyTests::ExtensionMethods3namespace inClrTests_Globals.cs. Its methods are PascalCase so the Ruby and CLR names differ. The older extension tests all use a lowercasef, which is why none of them caught this.ClrExtensionMethods6covers a class, its C# and Ruby subclasses, the exact tie, theDescribespelling andmethod(:describe).ClrExtensionMethods7covers an interface and a generic class.ClrExtensionMethods8coversList[Integer]#countwithSystem::Linq.All three fail with the fix reverted. The full IronRuby.Tests suite passes on net10.0.
Found, not fixed
A classic extension method named like a property getter, such as
get_Weight(this Widget w), makesw.weightthrow a NullReferenceException once it's activated. The code that builds a property's method group seems to size its array before it drops the methods that aren't compiler-generated accessors, which leaves a null in it.Stack
using System::Linq: CLR extension methods scoped like C#'s using directive #3 scopes CLR extension methods withusing🤖 Generated with Claude Code