Skip to content

[cpyrt] Detect enum arguments by type in overload priority - #75

Open
aaronj0 wants to merge 1 commit into
compiler-research:mainfrom
aaronj0:enum-args-by-type-priority
Open

[cpyrt] Detect enum arguments by type in overload priority#75
aaronj0 wants to merge 1 commit into
compiler-research:mainfrom
aaronj0:enum-args-by-type-priority

Conversation

@aaronj0

@aaronj0 aaronj0 commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

GetPriority() deprioritizes enum arguments so that a competing integer overload wins, since C++ has no implicit int->enum conversion, but it detected them with IsEnumScope(GetScope(name)). GetScope does not resolve an enum name to a scope, so the penalty never applied. Query the argument type with IsEnumType as well, per the existing FIXME.

GetPriority() deprioritizes enum arguments so that a competing integer
overload wins, since C++ has no implicit int->enum conversion, but it
detected them with IsEnumScope(GetScope(name)). GetScope does not
resolve an enum name to a scope, so the penalty never applied. Query the
argument type with IsEnumType as well, per the existing FIXME.
@aaronj0
aaronj0 force-pushed the enum-args-by-type-priority branch from d9a8c10 to 0770238 Compare September 8, 2026 08:56

@guitargeek guitargeek left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks, this goes in the right direction! pick(2) now returns 2, penalty fires via IsEnumType(GetMethodArgType(...)). One remaining problem though: the penalty is argument-agnostic, so pick(Color.Green) now returns 2: previously 1, and C++ overload resolution would also give 1. An enum object is an exact match for the enum overload.

I think this is a behavioral regression that needs to be fixed and locked in to the unit test.

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.

2 participants