Commit Graph

1088 Commits

Author SHA1 Message Date
Allan Shortlidge
b71e73d04c AST: Promote RetroactiveAttribute feature to baseline. 2024-07-09 14:28:29 -07:00
Allan Shortlidge
e7ae787516 AST: Promote ConformanceSuppression feature to baseline. 2024-07-09 14:28:29 -07:00
Allan Shortlidge
b39637159c AST: Promote RethrowsProtocol feature to baseline. 2024-07-09 14:28:29 -07:00
Allan Shortlidge
8dad141136 AST: Promote Extern feature to baseline. 2024-07-09 14:28:29 -07:00
Allan Shortlidge
731d91f590 AST: Promote TypedThrows features to the baseline. 2024-07-09 14:28:29 -07:00
Allan Shortlidge
53451caf49 AST: Promote LexicalLifetimes feature to baseline. 2024-07-09 14:28:28 -07:00
Allan Shortlidge
e1082bb8be AST: Promote various macro features to baseline. 2024-07-09 14:28:28 -07:00
Allan Shortlidge
b517a44528 AST: Promote ParameterPacks feature to the baseline. 2024-07-09 14:28:28 -07:00
Allan Shortlidge
6b9b7bcd83 AST: Promote PrimaryAssociatedTypes2 feature to the baseline. 2024-07-09 14:28:28 -07:00
Allan Shortlidge
b5acc6b07d AST: Promote AsyncSequenceFailure feature to the baseline. 2024-07-09 14:28:28 -07:00
Allan Shortlidge
6f972fc275 AST: Promote AssociatedTypeAvailability feature to the baseline. 2024-07-09 14:28:28 -07:00
Allan Shortlidge
9e5a9b963f AST: Remove NoncopyableGenerics feature suppression.
It is no longer necessary to produce `.swiftinterface` files the support older
compilers that lack support for the NoncopyableGenerics feature. Cleaning this
up makes the stdlib `.swiftinterface` far more readable.
2024-07-08 17:44:24 -07:00
Allan Shortlidge
a6faa5a4bf Frontend: Only print the -project-name flag in private and package interfaces.
Resolves rdar://130992944.
2024-07-03 09:10:48 -07:00
Allan Shortlidge
7cadb0b4e3 Sema: Downgrade actor convenience initializer diagnostic to a warning in interfaces.
The `convenience` keyword is not accepted on actor initializers because the
compiler infers this status automatically and actors cannot be subclassed.
However, internally the compiler still computes whether an actor init is a
convenience init and this implicit status has been leaking through accidentally
in printed `.swiftinterface` files. This was noticed because in Swift 6 the
presence of the keyword is diagnosed as an error, making `.swiftinterface`
files unparseable for modules containing actors with convenience inits.

For Swift 6, I'm just going to suppress the error in `.swiftinterface` files
regardless of language mode. In future releases of the compiler, though, it can
stop printing the `convenience` keyword on these inits altogether, though.

Resolves rdar://130857256.
2024-07-02 08:31:23 -07:00
Ellie Shin
ea8a05399f Drop package-name if needed in SaveModuleInterfaceArgs 2024-06-28 20:24:28 -07:00
Ellie Shin
e5b4655108 Option to disable printing package-name in public or private interface.
Having package-name flag in non-package interfaces causes them to be built as if
belonging to a package, which causes an issue for a loading client outside of the
package as follows.

For example, when building X that depends on A with the following dependency chain:
  X --> A --> B --(package-only)--> C

1. X itself is not in the same package as A, B, and C.
2. When dependency scanning X, and opening up B, because the scan target is in a
   different package domain, the scanner decides that B's package-only dependency
   on C is to be ignored.
3. When then finally building A itself, it will load its dependencies, but because
   the .private.swiftinterface of A still specifies -package-name, when it loads
   B, it will then examine its dependencies and deem that this package-only dependency
   on C is required.

Because (2) and (3) disagree, we get an error now when building the private A textual interface.

rdar://130701866
2024-06-28 15:06:21 -07:00
Kavon Farvardin
1e2111afca NCGenerics: add flag to opt-out SE-427 strictness
This is mainly for tests to avoid the reverse condfail.
2024-06-26 17:10:33 -07:00
Kavon Farvardin
1a0fb4c545 Test: remove target flag from interface
It won't work on other machines :)
2024-06-26 14:00:40 -07:00
Kavon Farvardin
baabaa022f NCGenerics: add workaround for rev. condfail
resolves rdar://130424971
2024-06-26 11:43:52 -07:00
Kavon Farvardin
545844ce8f ASTPrinter: fix nested signatures with inverses
A generic signature's `getInnermostGenericParams` will find the generic
parameters in the innermost scope. That's not quite right for printing
inverses, since we don't want to print an inverse for `T` when emitting
the generic signature of `f` below:

```swift
    struct S<T: ~Copyable, E> {
        func f() where E == Never {}
    }
```

Since `f` has its own generic signature, but doesn't define any generic
parameters, it shouldn't have an inverse emitted. The solution here is
to filter inverses by depth of the generic parameter.

We also want to print _all_ of the inverses in other situations, rather
than just the innermost ones. This aids in debugging and other
tools like the API digester.

resolves rdar://130179698
2024-06-25 12:06:23 -07:00
Holly Borla
4bec599931 Merge pull request #74543 from hborla/promote-isolated-any
[Features] Promote `IsolatedAny` and its alias to a language feature.
2024-06-19 10:32:30 -07:00
Holly Borla
966269d31a [Features] Promote IsolatedAny and its alias to a language feature.
The proposal is accepted and implemented for Swift 6.0.
2024-06-18 22:09:16 -07:00
Karoy Lorentey
5b9e49865b [test] Update availability tests 2024-06-13 18:00:45 -07:00
Kavon Farvardin
ec4a125f3e NCGenerics: ext's might not infer invertible req's
If the extension adds conformance to an invertible protocol, it's
confusing for people to also infer conditional requirements on the
generic parameters for those invertible protocols. This came up in the
review of SE-427.
2024-06-12 14:44:22 -07:00
Yuta Saito
6a11171755 [ModuleInterface] Save -public-autolink-library module option
Serialize the `-public-autolink-library <name>` option to the
moduleinterface file because it can affect the LINK_LIBRARY entries in a
swiftmodule file. Without saving the option, the library won't be linked
when a module compiled from the moduleinterface is used.

This change marks the `-public-autolink-library` option as a module
interface option and reads it when building a swiftmodule by module
loader.
2024-06-11 02:22:31 +00:00
Becca Royal-Gordon
91afad2fb0 Merge pull request #74135 from beccadax/objcimpl-the-final-countdown
Fix two objcImpl resyntaxing bugs
2024-06-06 13:42:28 -07:00
artemcm
d70863501e [Dependency Scanning] Collect and report each module dependency's Link Libraries 2024-06-05 10:59:41 -07:00
Becca Royal-Gordon
b3e7a23e70 Fix @objc use in module interfaces for objcImpl
objcImpl extensions with final public members need to be printed into module interfaces, but with the @implementation attribute suppressed. That worked fine…but when we switched to the new syntax, we should also have suppressed the @objc attribute, and we mistakenly did not. Correct this oversight.

Fixes rdar://129178360.
2024-06-04 17:47:05 -07:00
Allan Shortlidge
7c6815ce3c Merge pull request #73898 from tshortli/nonescapable-in-swiftinterface
Sema: Relax feature check for non-escapable types in swiftinterfaces
2024-05-26 10:24:01 -07:00
Holly Borla
0773c832f2 Merge pull request #73877 from hborla/non-sendable-isolated-any
[Concurrency] `@isolated(any)` does not imply `@Sendable`.
2024-05-24 16:01:47 -07:00
Allan Shortlidge
4bc1abb4be Sema: Relax feature check for non-escapable types in swiftinterfaces.
Checking for the presence of a feature flag in order to allow syntax tends to
result in condfails when applied to `.swiftinterfaces`, since older compilers
that have this restriction may be used to compile newer interfaces where the
restriction has been lifted. Remove this restriction for non-escapable types
when typechecking an interface.

Resolves rdar://128577611
2024-05-24 13:53:50 -07:00
Holly Borla
8d6f16ef4b [Concurrency] @isolated(any) does not imply @Sendable. 2024-05-24 12:22:01 -07:00
nate-chandler
33c76b6c62 Merge pull request #73843 from nate-chandler/rdar128611158
[Features] Move NoncopyableGenerics up.
2024-05-23 16:08:55 -07:00
Andrew Trick
0f332e17dd Merge pull request #73831 from atrick/remove-bitwise-lifetime-diagnostic
Remove diagnostic: lifetime_dependence_on_bitwise_copyable
2024-05-23 14:27:13 -07:00
Holly Borla
f3d4969e07 Merge pull request #73832 from hborla/task-local-macro-hack
[Macros] Ignore the `@TaskLocal` macro attached to vars with projected value vars.
2024-05-23 11:39:33 -07:00
Nate Chandler
60cdbb84a5 [Features] Move NoncopyableGenerics up.
Some compilers have the NoncopyableGenerics feature enabled via
interesting mechanisms but do not have ConformanceSuppression.  To
support such compilers, the NoncopyableGenerics feature must appear
before ConformanceSuppression in the list of features.  Otherwise, when
parsing the portion of the swiftinterface corresponding to an entity
which involves both features, the first check will be for
NoncopyableGenerics (which that old compiler has) and the code inside
will involve ConformanceSuppression (which that old compiler does not
have).

rdar://128611158
2024-05-23 10:12:01 -07:00
Holly Borla
7ded57b162 [Macros] Ignore the @TaskLocal macro attached to vars with projected values.
VarDecls with `@_projectedValueProperty` have already had the property
wrapper transform applied. This only impacts swiftinterfaces, and if
a swiftinterface was produced against a Concurrency library that does
not declare `TaskLocal` as a macro, we need to ignore the macro to avoid
producing duplicate declarations. This is only needed temporarily until
all swiftinterfaces have been built against the Concurrency library
containing the new macro declaration.
2024-05-22 18:05:49 -07:00
Andrew Trick
b5b0c75ccd Remove diagnostic: lifetime_dependence_on_bitwise_copyable
Allow lifetime depenendence on types that are BitwiseCopyable & Escapable.

This is unsafe in the sense that the compiler will not diagnose any use of the
dependent value outside of the lexcial scope of the source value. But, in
practice, dependence on an UnsafePointer is often needed. In that case, the
programmer should have already taken responsibility for ensuring the lifetime of the
pointer over all dependent uses. Typically, an unsafe pointer is valid for the
duration of a closure. Lifetime dependence prevents the dependent value from
being returned by the closure, so common usage is safe by default.

Typical example:

func decode(_ bufferRef: Span<Int>) { /*...*/ }

extension UnsafeBufferPointer {
  // The client must ensure the lifetime of the buffer across the invocation of `body`.
  // The client must ensure that no code modifies the buffer during the invocation of `body`.
  func withUnsafeSpan<Result>(_ body: (Span<Element>) throws -> Result) rethrows -> Result {
    // Construct Span using its internal, unsafe API.
    try body(Span(unsafePointer: baseAddress!, count: count))
  }
}

func decodeArrayAsUBP(array: [Int]) {
  array.withUnsafeBufferPointer { buffer in
    buffer.withUnsafeSpan {
      decode($0)
    }
  }
}

In the future, we may add SILGen support for tracking the lexical scope of
BitwiseCopyable values. That would allow them to have the same dependence
behavior as other source values.
2024-05-22 17:10:56 -07:00
Kavon Farvardin
6edc0ad1e9 Merge pull request #73777 from kavon/expand-swiftskell
Test: Implement a functional-style noncopyable List
2024-05-21 12:42:54 -07:00
Kavon Farvardin
b72824d167 Test: start implementing List 2024-05-20 22:53:45 -07:00
Kavon Farvardin
210cfb2b55 ASTPrinter: handle inverses in compositions
The basic inheritance clause emission in ASTPrinter operates on
InheritedEntry's, but does not canonicalize types. It's been
designed to consider an entire composition unprintable because one
member is unprintable (e.g., the protocol is not public).

This rejection is what was causing `~Copyable` in some compositions to
be missing from interface files (rdar://126090425). Fixing that is the
purpose of this patch.

What happens, then, if you mix public and nonpublic protocols in a
composition? A second facility called the InheritedProtocolCollector
later does find the public protocols, and emits extensions at the end of
the interface file to declare the additional conformances the ininitial
declaration printer missed.

We can't generally emit `~Copyable` on an extension, so the fix can't
happening there. Refactoring things so there's one source of truth about
the protocols being printed is a sizable refactoring that I will defer
for another time.

resolves rdar://126090425
2024-05-20 17:10:44 -07:00
Joe Groff
10f9289ef8 Enable 'BorrowingSwitch' feature. 2024-05-14 07:31:59 -07:00
Kavon Farvardin
ad1375ee7e NCGenerics: add test for feature flag
Ensure that when using noncopyable generics when building a module,
the compiler can re-ingest it and will pick the part guarded by
$NoncopyableGenerics.

verifies the concern in rdar://127701059
2024-05-13 10:43:25 -07:00
nate-chandler
387e8d3ff1 Merge pull request #73516 from nate-chandler/rdar127755503
[BitwiseCopyable] Avoid a condfail.
2024-05-09 07:00:01 -07:00
Kavon Farvardin
7177d9009d Merge pull request #73492 from kavon/ncgeneric-avoid-spam
NCGenerics: avoid feature-guarding in some cases
2024-05-08 18:42:09 -07:00
Nate Chandler
2671652085 [BitwiseCopyable] Avoid a condfail.
The standard library defines
```
protocol BitwiseCopyable {}
typealias _BitwiseCopyable = BitwiseCopyable
```
For current compilers, `BitwiseCopyable` is a "known protocol".

For older compilers, it is not; instead `_BitwiseCopyable` is.  So
print the following into the swiftinterface for those older compilers:
```
protocol _BitwiseCopyable {}
typealias BitwiseCopyable = _BitwiseCopyable
```

rdar://127755503
2024-05-08 16:53:14 -07:00
Kavon Farvardin
f0f91eedc9 NCGenerics: avoid feature-guarding in some cases
With the generalization of Optional to support noncopyable types, our
feature-guarding in swiftinterface files would double-print functions
that simply refer to the Optional type.

Since NoncopyableGenerics is a suppressible feature, by default
a second version of Optional and UnsafePointer are emitted into
swiftinterface files, where the ~Copyable generalization is stripped
away.

We can rely on that to avoid double-printing the function, if the types
substituted for the generic parameters are all Copyable.

We need a bit more checking for when
`@_disallowFeatureSuppression(NoncopyableGenerics)` is used, since this
trick relies on there always being a definition of the type we refer to,
whether the feature is enabled or not.

resolves rdar://127389991
2024-05-08 15:48:54 -07:00
Kavon Farvardin
0420310623 NCGenerics: it's no longer "experimental"
resolves rdar://127701059
2024-05-08 10:49:12 -07:00
nate-chandler
bcd08c0c9a Merge pull request #73235 from nate-chandler/bitwise-copyable/enable
[BitwiseCopyable] Promote to feature.
2024-05-04 10:16:40 -07:00
Becca Royal-Gordon
6d3e1ad794 Fix -target in several objcImpl tests 2024-04-30 12:03:46 -07:00