Skip to content

[NCGenerics] more work towards getting the stdlib building #69842

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 8 commits into from
Nov 30, 2023

Conversation

kavon
Copy link
Member

@kavon kavon commented Nov 14, 2023

The goal of this PR is to shake out issues with just building the existing stdlib with NoncopyableGenerics enabled. This PR does not enable that by-default, so you'll still have to add swift-stdlib-experimental-noncopyable-generics=1 to your build-script preset.

fixes rdar://118697289

This is a batch of otherwise hard-to-write-a-regression test fixes for
situations that came up while testing with the stdlib.
It's not technically correct to ask the generic signature without first
reducing the type, i.e., we really have to do this:

```
auto ty = sig->getReducedType(this)

// fast path
if (ty.isTypeParamter())
  return sig->requiresProtocol(s, copyable)

// slow path
mapTypeIntoContext(...)
```

Since reducing the type is basically what `mapTypeIntoContext` is also
going to do, it's not really worth doing this or having the fast-path at
 all. This need to reduce the type originally came while building the
 stdlib. We ran into a problem with this:

 ```
 extension Slice {
  public func initialize<S>(
    from source: S
  ) -> (unwritten: S.Iterator, index: Index)
    where S: Sequence, Base == UnsafeMutableBufferPointer<S.Element>
 }
 ```

 where we have `struct Slice<Base: Collection>` and

 ```
 extension Slice: Collection {
   typealias Index = Base.Index
   // ...
 }
 ```
@kavon
Copy link
Member Author

kavon commented Nov 14, 2023

@swift-ci smoke test

@kavon kavon force-pushed the ncgenerics-stdlib-building branch from 6aea5b2 to 03ad1c6 Compare November 14, 2023 18:22
@kavon
Copy link
Member Author

kavon commented Nov 14, 2023

@swift-ci smoke test

I was not expanding default requirements in
AbstractGenericSignatureRequest or ExistentialLayout.

Also fixes printing of composition types.
@kavon kavon force-pushed the ncgenerics-stdlib-building branch from 03ad1c6 to 2cd2989 Compare November 15, 2023 23:53
@kavon kavon changed the title [NCGenerics] get the stdlib building [NCGenerics] more work towards getting the stdlib building Nov 15, 2023
@kavon kavon marked this pull request as ready for review November 15, 2023 23:54
@kavon
Copy link
Member Author

kavon commented Nov 15, 2023

@swift-ci please test

@kavon kavon enabled auto-merge November 15, 2023 23:55
@kavon kavon disabled auto-merge November 16, 2023 01:03
After review, Slava and I decided it's not a good idea to provide a
`TypeBase::getAnyTypeDecl` method, as it is not typically what people
generally should use, as it doesn't handle all cases (type parameters
with no associated decl, for example).
@kavon
Copy link
Member Author

kavon commented Nov 29, 2023

@swift-ci please smoke test

@kavon kavon enabled auto-merge November 29, 2023 20:55
@kavon kavon merged commit 81ea998 into swiftlang:main Nov 30, 2023
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