Commit Graph

28024 Commits

Author SHA1 Message Date
Allan Shortlidge
c5e5311cc8 Merge pull request #80560 from tshortli/member-import-visibility-diags-implicit
Parse/Sema: Add source locations to implicit code for `MemberImportVisibility` diagnostics
2025-04-05 18:07:55 -07:00
Allan Shortlidge
b97ec5bbe5 Sema: Improve MemberImportVisibility diags for for-in loops.
Ensure that source locations are attached to the implicit calls to
`makeIterator()` and `next()` for diagnostics.

Partially resolves rdar://144535697.
2025-04-05 09:47:56 -07:00
Anthony Latsis
2d899d0e73 AST: Cut down on DescriptiveDeclKind usage in DiagnosticsCommon.def 2025-04-05 12:31:20 +01:00
Anthony Latsis
a0930dec31 AST: Cut down on DescriptiveDeclKind usage in DiagnosticsSema.def 2025-04-05 12:31:19 +01:00
Anthony Latsis
08d46d2542 Merge pull request #80473 from AnthonyLatsis/diag_type_attr
DiagnosticEngine: Support `TypeAttribute` diagnostic arguments
2025-04-05 12:25:45 +01:00
Anthony Latsis
3fd8f0a008 [NFC] Sema: Factor out derived conformance sources into subdirectory 2025-04-05 05:32:37 +01:00
Pavel Yaskevich
8bf8c24bf9 Merge pull request #80503 from xedin/extensible-attr
[AST/Sema] Add `@extensible` attribute on `enum` declarations
2025-04-04 09:17:56 -07:00
Slava Pestov
9148ae32bd Merge pull request #80482 from slavapestov/abstract-conformance-cleanup
AST: Simplify ProtocolConformanceRef operations a little bit
2025-04-04 10:37:49 -04:00
Pavel Yaskevich
a0ae93d3a8 [AST/Sema] Add @extensible attribute on enum declarations
This attribute controls whether cross-module access to the declaration
needs `@unknown default:` because it's allowed to gain new cases even
if the module is non-resilient.
2025-04-03 16:30:19 -07:00
Slava Pestov
ea05708716 AST: Eliminate GenericEnvironment::mapConformanceRefIntoContext() 2025-04-03 17:35:34 -04:00
Slava Pestov
ec0dfc8716 AST: Add new form of SubstitutionMap::getProtocolSubstitutions() 2025-04-03 17:35:33 -04:00
Slava Pestov
a209ff8869 AST: Remove origType parameter from ProtocolConformanceRef::subst() 2025-04-03 17:35:33 -04:00
Slava Pestov
7399eeb602 AST: Remove type parameter from ProtocolConformanceRef::getWitnessByName() 2025-04-03 17:35:33 -04:00
Slava Pestov
00766f7deb AST: Remove type parameter from ProtocolConformanceRef::getTypeWitnessByName() 2025-04-03 17:35:32 -04:00
Slava Pestov
91503710bc AST: Remove origType parameter from ProtocolConformanceRef::getTypeWitness() 2025-04-03 17:35:32 -04:00
Slava Pestov
7c7caa2088 Sema: Fix regression with 'Failure' type witness inference hack
We have a special hack to infer the 'Failure' type witness in
'AsyncIteratorProtocol' by considering the type of 'next()'
witness.

In eaf06eae0e I added a check to
fix some assertions that could happen if 'next()' was witnessed
by a declaration in a protocol extension or superclass, which
has a different generic signature.

However my check was too narrow, because it also prohibited
this form of inference when 'next()' was in a different
extension of the same nominal type.

Allow this again.

Fixes https://github.com/swiftlang/swift/issues/79367.
Fixes rdar://problem/145341658.
2025-04-03 17:34:31 -04:00
Hamish Knight
918d4b54cf Merge pull request #80461 from hamishknight/in-sequence
[ASTScope] Allow `try` in unfolded sequence to cover following elements
2025-04-03 20:23:51 +01:00
Anthony Latsis
99f63ed933 DiagnosticEngine: Support TypeAttribute diagnostic arguments 2025-04-03 01:52:38 +01:00
Allan Shortlidge
5cd5f31c9c Sema: Fix a regression in -require-explicit-availability diagnostics.
The changes in https://github.com/swiftlang/swift/pull/80040 caused the
compiler to start diagnosing extensions containing only members that are
either `@_spi`, `@_alwaysEmitIntoClient`, or unavailable when the
`-require-explicit-availability` flag is passed. Extensions should not be
diagnosed when they only contain members that would not be diagnosed
themselves.

Resolves rdar://148275432.
2025-04-02 17:12:38 -07:00
Joe Groff
562d7dc832 Merge pull request #80438 from jckarter/substitute-away-escapable-lifetime-deps
Type substitution eliminates dependencies with Escapable targets.
2025-04-02 16:56:54 -07:00
Pavel Yaskevich
f61a3c941b Merge pull request #80443 from xedin/rdar-148256978
[CSBindings] Avoid delaying leading-dot inference only if chain is di…
2025-04-02 11:08:44 -07:00
Allan Shortlidge
192da54004 Merge pull request #80450 from tshortli/fix-parentheses-warning 2025-04-02 10:40:17 -07:00
Pavel Yaskevich
75f4ca78ce Merge pull request #80397 from jameesbrown/pack-exp-overload
[CS] Dont wrap packexp in extra layer of expansion
2025-04-02 09:45:01 -07:00
Joe Groff
6b605f41cb Type substitution eliminates dependencies with Escapable targets.
When a generic function has potentially Escapable outputs, those outputs
declare lifetime dependencies, which have no effect when substitution
leads to those types becoming `Escapable` in a concrete context.
This means that type substitution should canonically eliminate lifetime
dependencies targeting Escapable parameters or returns, and that
type checking should allow a function value with potentially-Escapable
lifetime dependencies to bind to a function type without those dependencies
when the target of the dependencies is Escapable.

Fixes rdar://147533059.
2025-04-02 08:54:45 -07:00
Slava Pestov
03d8fd7ceb Merge pull request #80445 from slavapestov/fix-issue-80288
Sema: Fix handling of getter typed throws in witness matching
2025-04-02 08:01:10 -04:00
Hamish Knight
d958c0e080 [AST] Introduce Expr::isAlwaysLeftFolded
Use this to query for `try`-like expressions when it comes to binary
operator folding.
2025-04-02 12:29:45 +01:00
Pavel Yaskevich
bf2d01e562 Merge pull request #80419 from xedin/revert-pr-79397
Revert "Sema: Allow optional-to-optional CGFloat <-> Double conversion"
2025-04-02 00:10:23 -07:00
Allan Shortlidge
8819d6db9e Distributed: Squash a -Wparentheses warning.
The following warning was being  emitted by newer versions of clang:

```
comparisons like 'X<=Y<=Z' don't have their mathematical meaning [-Wparentheses]
```

This code needs to be reworked to ensure that the conditions that are meant to
be asserted are true.
2025-04-01 16:47:56 -07:00
Allan Shortlidge
14147bf87d Merge pull request #80428 from tshortli/custom-availability-domain-scopes
AST: Build availability scopes for custom domain conditionals
2025-04-01 16:43:19 -07:00
Slava Pestov
b26c59962b Sema: Fix handling of getter typed throws in associated type inference
We must replace type parameters with archetypes in the thrown error type
of the witness. The requirement type remains an interface type.
2025-04-01 17:21:32 -04:00
Slava Pestov
de3cf4d982 Sema: Visit getter throws type in ReferencedAssociatedTypesRequest 2025-04-01 14:53:49 -04:00
Slava Pestov
b30006837e Sema: Fix handling of getter typed throws in witness matching
Witness matching didn't handle the case where either the
requirement or the witness is a property with a throwing
getter, and the thrown error type contains a type parameter.

We must open the thrown error types first, replacing type
parameters with type variables, for the matching to work.

Associated type inference needs a similar fix. I'll land a
combined test case for both once I fix that.

Fixes https://github.com/swiftlang/swift/issues/80288.
Fixes rdar://problem/147874955.
2025-04-01 14:53:49 -04:00
Anthony Latsis
4bddb3a705 Merge pull request #80427 from AnthonyLatsis/alcer-americanus
[SE-0461] Consistently diagnose protocol requirements in migration (adoption) mode
2025-04-01 19:53:22 +01:00
Pavel Yaskevich
d34222d461 [CSBindings] Avoid delaying leading-dot inference only if chain is directly connected to a contextual type
Additional restrictions on when protocol inference could be considered
viable. If the chain is connected directly to a contextual type there
cannot be any other inference sources for the base type.

Resolves: rdar://148256978
2025-04-01 10:33:30 -07:00
Allan Shortlidge
cce02961f9 AST/SILGen: Make availability ranges stored by PoundAvailableInfo optional.
Rather than representing a missing availability range on `PoundAvailableInfo`
with a default-constructed `AvailabilityRange` (empty), store the ranges as
optionals instead. This allows an empty range to represent an availability
condition which is known to be false at compile time, which will be necessary
when generating SIL for `if #available` queries that check custom availability
domains.
2025-04-01 07:46:46 -07:00
Allan Shortlidge
b6a425ab6a Sema: Avoid diagnosing required availability in swiftinterface files.
The `-require-explicit-availability` compiler flag is designed to help
developers find declarations that they've written with missing availability.
The flag is not printed in swiftinterface files, though, so if a module has
both `-library-level=api` and also has `-require-explicity-availability=ignore`
(as the Swift stdlib does) then the result is that superfluous diagnostics are
emitted when typechecking the emitted module interface that should have been
suppressed by the `ignore` flag. Suppress these diagnostics when typechecking
swiftinterface files since they are only designed to be seen by the owner of
the module when they are building the module from source and they don't have
much value in the context of interface verification.
2025-04-01 07:12:50 -07:00
Artem Chikin
66334f8f1b Merge pull request #79290 from artemcm/ConstProtoSIL
[Compile Time Values] Implement a mandatory SIL pass to verify '@const' values
2025-04-01 00:12:27 -07:00
Anthony Latsis
e9406e04e5 [SE-0461] Consistently diagnose protocol requirements in migration (adoption) mode 2025-04-01 04:03:55 +01:00
Pavel Yaskevich
05798e5f45 Revert "Sema: Remove dead diagnostic"
This reverts commit d56d7045a2.
2025-03-31 14:39:44 -07:00
Pavel Yaskevich
35077a01d1 Revert "Sema: Allow optional-to-optional CGFloat <-> Double conversion"
This reverts commit f0f5ffcebf.
2025-03-31 13:58:38 -07:00
Michael Gottesman
918756f854 Merge pull request #80374 from gottesmm/pr-ee297e6b432cd07483ec86444ffd6a8b5334c203
[concurrency] Fix a few issues with @execution(caller)/@execution(concurrent).
2025-03-31 09:20:01 -07:00
James Brown
913733f508 [CS] Dont wrap packexp in extra layer of expansion
Arguments that were already pack expansions were being wrapped in a
second layer--preventing some would-be unambiguous overloads from
resolving. This adds a check to avoid doing that.
2025-03-31 11:07:33 -04:00
Michael Gottesman
f245389bb3 [concurrency] Fix a few issues with @execution(caller)/@execution(concurrent).
Specifically:

1. I made it so that thunks from caller -> concurrent properly ignore the
isolated parameter of the thunk when calling the concurrent function.

rdar://148112362

2. I made it so that thunks from concurrent -> caller properly create a
Optional<any Actor>.none and pass that into the caller function.

rdar://148112384

3. I made it so that in cases where we are assigning an @Sendable caller to a
non-sendable caller variable, we allow for the conversion as long as the
parameters/results are sendable as well.

rdar://148112532

4. I made it so that when we generate a thunk from @execution(caller) ->
@GlobalActor, we mangle in @GlobalActor into the thunk.

rdar://148112569

5. I discovered that due to the way we handle function conversion expr/decl ref
expr, we were emitted two thunks when we assigned a global @caller function to a
local @caller variable. The result is that we would first cast from @caller ->
@concurrent and then back to @caller. The result of this would be that the
@caller function would always be called on the global queue.

rdar://148112646

I also added a bunch of basic tests as well that showed that this behavior was
broken.
2025-03-30 20:00:05 -07:00
Allan Shortlidge
e5d0cd4e51 Merge pull request #80322 from tshortli/allow-swift-runtime-symbol-declarations 2025-03-30 16:14:40 -07:00
Allan Shortlidge
8f2d5a759e Merge pull request #80321 from tshortli/warnings 2025-03-30 16:14:21 -07:00
Allan Shortlidge
2fb76a468a Merge pull request #80333 from tshortli/clock-measure-unsafe-inherit-executor 2025-03-30 16:14:07 -07:00
Anthony Latsis
880d7e5621 Merge pull request #80342 from AnthonyLatsis/andrias-japonicus
Diag: Handle `CustomAttr` in `formatDiagnosticArgument`
2025-03-29 20:36:48 +00:00
Hamish Knight
4efe08e3ae Merge pull request #80379 from hamishknight/extendable-expansion 2025-03-29 17:55:59 +00:00
Doug Gregor
813f1dcb85 Merge pull request #80384 from DougGregor/isolated-conformances-checkedcast-enable
Prohibit isolated conformances for checked casts to potentially-SendableMetatype types
2025-03-29 01:27:31 -07:00
Holly Borla
68b95f8764 Merge pull request #80382 from hborla/isolation-crash
[Concurrency] When expanding `#isolation` create a type-checked type expr for global actors.
2025-03-28 22:30:32 -07:00