Skip to content

Conversation

Xazax-hun
Copy link
Contributor

The overload resolution generated a constraint that tried to bind outer.inline_inner to outer. This constraint failed. This PR attempts to recognize this scenario and make the constraint succeed, inserting a MetatypeConversionExpr that is later ignored by SILGen.

rdar://158401346

@Xazax-hun
Copy link
Contributor Author

@xedin could you take a look? This is just a first stab and I am not sure at all if this is the right approach here.

@Xazax-hun Xazax-hun force-pushed the fix-inline-namespaces branch from ffcae60 to 4e69463 Compare August 15, 2025 13:18
auto nominal1 = cast<NominalType>(desugar1);
auto nominal2 = cast<NominalType>(desugar2);

if (isa<EnumType>(nominal1) && kind == ConstraintKind::Bind) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Note for posterity: we have discussed this offline and a better approach here might be to - check whether the base type of the lookup is inline namespace or not and based on that adjust the reference type for each found member if it was found in an inline namespace.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I implemented this in the step when we generate the constraints. Unfortunately, I could not push the logic earlier as the lookup itself finds declarations, not types. Let me know if I am missing something.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After talking offline, it turns it it was not sufficient to just update the type in the constraint. I had to update the opened type that was used for the selected overload.

@Xazax-hun Xazax-hun force-pushed the fix-inline-namespaces branch 2 times, most recently from fa14547 to 56d8b6f Compare September 26, 2025 14:03
@Xazax-hun Xazax-hun force-pushed the fix-inline-namespaces branch from 56d8b6f to 07f0d52 Compare October 7, 2025 10:26
The overload resolution generated a constraint that tried to bind
outer.inline_inner to outer. This constraint failed. This PR attempts to
recognize this scenario and make the constraint succeed.

rdar://158401346
@Xazax-hun Xazax-hun force-pushed the fix-inline-namespaces branch from 07f0d52 to 0e56809 Compare October 7, 2025 10:39
@Xazax-hun
Copy link
Contributor Author

@swift-ci please smoke test

@Xazax-hun Xazax-hun merged commit 7159b12 into swiftlang:main Oct 8, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ interop Feature: Interoperability with C++

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants