Skip to content

Sema: Implement missing part of SE-0346 #81949

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

Merged
merged 2 commits into from
Jun 4, 2025

Conversation

slavapestov
Copy link
Contributor

@slavapestov slavapestov commented Jun 3, 2025

The proposal states that this should work, but this was never implemented:

protocol P<A> {
  associatedtype A
}

struct S: P<Int> {}

@slavapestov slavapestov requested review from hborla and xedin as code owners June 3, 2025 18:03
@slavapestov slavapestov force-pushed the missing-part-of-se-0346 branch from a27fa64 to 2183880 Compare June 3, 2025 18:14
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

Copy link
Collaborator

@AnthonyLatsis AnthonyLatsis left a comment

Choose a reason for hiding this comment

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

Will we be fine (error) if there’s another kind of explicit type witness?

Comment on lines +1797 to +1801
} else if (auto *pct = inheritedTy->getAs<ProtocolCompositionType>()) {
for (auto member : pct->getMembers()) {
collectProtocolsFromInheritedEntry(entry, member,
protocolsWithRetroactiveAttr, protos);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we have a test case for a nested composition?

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'll add one

@slavapestov slavapestov force-pushed the missing-part-of-se-0346 branch from 2183880 to 235db43 Compare June 3, 2025 21:16
@slavapestov
Copy link
Contributor Author

@AnthonyLatsis it would crash on ambiguity. I added a little bit of logic that makes us now diagnose an ambiguity error.

@slavapestov slavapestov force-pushed the missing-part-of-se-0346 branch from 235db43 to 28575b0 Compare June 3, 2025 21:25
The proposal states that this should work, but this was never
implemented:

    protocol P<A> {
      associatedtype A
    }

    struct S: P<Int> {}

- Fixes swiftlang#62906.
- Fixes rdar://91842338.
@slavapestov slavapestov force-pushed the missing-part-of-se-0346 branch from 28575b0 to 185a91d Compare June 3, 2025 21:28
@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 c61a4fe into swiftlang:main Jun 4, 2025
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.

Can't inherit from a protocol with primary associated types using the "generic" notation
3 participants