Skip to content

Conversation

@slavapestov
Copy link
Contributor

We noticed that a project failed to build with prepared overloads enabled, but built successfully with prepared overloads disabled.

It turns out that the code clearly should never have been accepted in the first place, because the type checker was making an arbitrary choice between two nominal type declarations with the same name.

Further inspection revealed this was because of a FIXME added in 2013 which was far too broad. Tighten up the logic here to only disambiguate if at least one of the two declarations is a type alias, and it has the same underlying type as the other one. A choice between unrelated nominal type declarations should always be ambiguous.

This still isn't perfect, because we might have two generic type aliases that are referenced in both solutions with different substitution maps, in which case we will still erroneously pick the first one. But this is better than the old logic, at least.

Fixes rdar://165863775.

@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

…arations

We noticed that a project failed to build with prepared overloads enabled,
but built successfully with prepared overloads disabled.

It turns out that the code clearly should never have been accepted in the
first place, because the type checker was making an arbitrary choice between
two nominal type declarations with the same name.

Further inspection revealed this was because of a FIXME added in 2013 which
was far too broad. Tighten up the logic here to only disambiguate if at least
one of the two declarations is a type alias, and it has the same underlying
type as the other one. A choice between unrelated nominal type declarations
should always be ambiguous.

This still isn't perfect, because we might have two generic type aliases
that are referenced in both solutions with different substitution maps,
in which case we will still erroneously pick the first one. But this
is better than the old logic, at least.

Fixes rdar://165863775.
@slavapestov slavapestov force-pushed the 12-year-old-fixme-strikes-back branch from c78ab8f to 6701e5b Compare December 10, 2025 03:55
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

@slavapestov slavapestov merged commit 3dcd9bb into swiftlang:main Dec 10, 2025
3 of 5 checks passed
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