Skip to content

Sema: Allow T == NonCopyableOrEscapable same-type constraints without a redundant T: ~Copyable. #81424

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

Conversation

jckarter
Copy link
Contributor

@jckarter jckarter commented May 9, 2025

Enhance the logic in applyInverses to also take into account same-type constraints spelled in the generic signature, so that same-type-constraining a type parameter to a type that is itself not Copyable or Escapable suppresses the default application of those constraints on the type parameter. Fixes rdar://147757973.

@jckarter
Copy link
Contributor Author

jckarter commented May 9, 2025

@swift-ci Please test

@@ -802,15 +803,122 @@ void swift::rewriting::applyInverses(
ASTContext &ctx,
ArrayRef<Type> gps,
ArrayRef<InverseRequirement> inverseList,
ArrayRef<StructuralRequirement> explicitRequirements,
Copy link
Contributor

Choose a reason for hiding this comment

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

You can probably move this function into its own file because it’s horrible but also self-contained. That’s what I did with ConcreteContraction.cpp

@jckarter
Copy link
Contributor Author

@swift-ci Please test Windows

@jckarter jckarter force-pushed the same-type-constraint-stop-copyable branch from 21a72bb to 0be2900 Compare May 12, 2025 22:36
@jckarter
Copy link
Contributor Author

@swift-ci Please test

@slavapestov
Copy link
Contributor

Your change here also moves realizeInheritedRequirements() and StructuralRequirementsRequest::evaluate() to the new file. I was imagining it would just contain the applyInverses() function and nothing else (the circular dependency with RequirementLowering.cpp is fine).

…ut a redundant `T: ~Copyable`.

Enhance the logic in `applyInverses` to also take into account same-type constraints spelled in
the generic signature, so that same-type-constraining a type parameter to a type that is itself
not `Copyable` or `Escapable` suppresses the default application of those constraints on the
type parameter. Fixes rdar://147757973.
@jckarter jckarter force-pushed the same-type-constraint-stop-copyable branch from 0be2900 to e4a6faa Compare May 13, 2025 18:31
@jckarter
Copy link
Contributor Author

Sorry, I grabbed too much in my cut and paste. It should be fixed now.

@jckarter
Copy link
Contributor Author

@swift-ci Please test

@jckarter jckarter merged commit 52d7781 into swiftlang:main May 14, 2025
5 checks passed
hamishknight added a commit to hamishknight/swift that referenced this pull request May 22, 2025
…nstraint-stop-copyable"

This reverts commit 52d7781.
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