Skip to content

[Demangle-to-AST] Match invertible-generics extensions with no signature #72644

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

DougGregor
Copy link
Member

@DougGregor DougGregor commented Mar 28, 2024

Introduce a predicate that determines when a given extension corresponds to what one would get by existing the nominal type without spelling out any constraints. This differs from the notion of a "constrained extension" when the nominal type suppresses conformances on any of its generic parameters, e.g.,

struct X<T: ~Copyable> { ... }

// doesn't spell out any constraints, but is constrained because it
// implicitly adds T: ~Copyable.
extension X { ... }

// does spell out constraints, but is not constrained because the
// generic signature matches that of X.
extension X where T: ~Copyable { }

Use this predicate when demangling a name to metadata, because name mangling for extensions suppresses the generic signature for cases where one "doesn't spell out any constraints."

Fixes rdar://125515645, a source compatibility suite failure in swift-futures

Introduce a predicate that determines when a given extension corresponds
to what one would get by existing the nominal type without spelling out
any constraints. This differs from the notion of a "constrained
extension" when the nominal type suppresses conformances on any of its
generic parameters, e.g.,

    struct X<T: ~Copyable> { ... }

    // doesn't spell out any constraints, but is constrained because it
    // implicitly adds T: ~Copyable.
    extension X { ... }

    // does spell out constraints, but is not constrained because the
    // generic signature matches that of X.
    extension X where T: ~Copyable { }

Use this predicate when demangling a name to metadata, because name
mangling for extensions suppresses the generic signature for cases
where one "doesn't spell out any constraints."
@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor
Copy link
Member Author

@swift-ci please test source compatibility

@DougGregor
Copy link
Member Author

@swift-ci please smoke test Linux

@DougGregor DougGregor merged commit fc6011c into swiftlang:main Mar 28, 2024
@DougGregor DougGregor deleted the demangle-extensions-without-written-requirements branch March 28, 2024 06:55
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