Commit Graph

21528 Commits

Author SHA1 Message Date
Arnold Schwaighofer
7ac551636b Merge pull request #81714 from aschwaighofer/se0460
SE-0460: Introduce @specialized attribute
2025-05-28 12:03:48 -07:00
Joe Groff
22eb7e62d9 SILGen: Emit property descriptors for conditionally Copyable and Escapable types.
Key paths can't reference non-escapable or non-copyable storage declarations,
so we don't need to refer to them resiliently, and can elide their property
descriptors.

However, declarations may still be conditionally Copyable and Escapable, and
if so, then they still need a property descriptor for resilient key path
references. When a property or subscript can be used in a context where it
is fully Copyable and Escapable, emit the property descriptor in a generic
environment constrained by the necessary conditional constraints.

Fixes rdar://151628396.
2025-05-27 09:35:40 -07:00
Slava Pestov
52f54534f3 Merge pull request #76705 from slavapestov/existential-parameterized-composition
Allow existential parameterized compositions: `any P<A> & Q`
2025-05-23 21:26:50 -04:00
Arnold Schwaighofer
13ff5abdb8 Introduce @specialized attribute
Implements SE-0460 -- the non-underscored version of @specialized.

It allows to specify "internal" (not abi affecting) specializations.

rdar://150033316
2025-05-23 13:12:47 -07:00
Slava Pestov
4338a55154 ASTDemangler: Add support for constrained existential compositions 2025-05-23 14:14:23 -04:00
Hamish Knight
89f7a82c39 Merge pull request #81673 from hamishknight/macrotrail
[IDE] Better handle macro trailing closures
2025-05-22 20:01:31 +01:00
Artem Chikin
24f2975db6 Merge pull request #81510 from artemcm/ConstSyntacticVerify
[Compile Time Values] Add syntactic verification of valid expressions in `@const` contexts
2025-05-21 13:22:05 -07:00
Andrew Trick
e240dd55d3 Merge pull request #81656 from atrick/lifedep-inout-infer
Allow passing MutableSpan 'inout' without an experimental feature.
2025-05-21 11:47:58 -07:00
Hamish Knight
7522a3ea5b [SourceKit] Handle CustomAttrs arguments for placeholder expansion
Introduce a new ASTWalker option for walking CustomAttrs and use it
for the placeholder scanner to ensure we can expand placeholders in
attribute arguments.
2025-05-21 18:06:54 +01:00
Anthony Latsis
de15dc6ddd Merge pull request #81671 from AnthonyLatsis/caranx-melampygus
InFlightDiagnostic: Minor improvement to `fixItAddAttribute`
2025-05-21 17:06:17 +01:00
Anthony Latsis
eedc774fca InFlightDiagnostic: Minor improvement to fixItAddAttribute
Do not follow `in` keyword with a space unless the first token inside
the body begins with the next char after `{`.
2025-05-21 12:11:19 +01:00
Andrew Trick
754edc7b8c Type checker: ignore LifetimeDependenceRequest in cycle diagnostic
When reporting the declarations that lead to a cycle, we end up printing an
extra "through reference here" on the function declaration:

class C2: C1, P {
   |       |- note: through reference here
   |       `- note: through reference here
15 |     // expected-note@-1 2{{through reference here}}
16 |     override func run(a: A) {}
   |                   |   |  `- note: while resolving type 'A'
   |                   |   `- note: through reference here
   |                   |- error: circular reference
   |                   |- note: through reference here
   |                   `- note: through reference here
2025-05-21 00:25:00 -07:00
Andrew Trick
f66c04056f Allow passing MutableSpan 'inout' without an experimental feature.
This adds a new lifetime inference rule, loosening the requirement for @lifetime
annotations even when the experimental LifetimeDependence mode is
enabled. Additionally, it enables this new inference rule even when the
experimental mode is disabled. All other inference rules continue to require the
experimental feature. The rule is:

If a function or method has a single inout non-Escapable parameter other than
'self' and has no other non-Escapable parameters including 'self', then infer a
single @lifetime(copy) dependency on the inout parameter from its own incoming
value.

This supports the common case in which the user of a non-Escapable type,
such as MutableSpan, wants to modify the span's contents without modifying
the span value itself. It should be possible to use MutableSpan this way
without requiring any knowledge of lifetime annotations. The tradeoff is
that it makes authoring non-Escapable types less safe. For example, a
MutableSpan method could update the underlying unsafe pointer and forget to
declare a dependence on the incoming pointer.

Disallowing other non-Escapable parameters rules out the easy mistake of
programmers attempting to trivially reassign the inout parameter. There's
is no way to rule out the possibility that they derive another
non-Escapable value from an Escapable parameteter. So users can still write
the following:

    func reassign(s: inout MutableSpan<Int>, a: [Int]) {
      s = a.mutableSpan
    }

The 'reassign' declaration will type check, but it's implementation will
diagnose a lifetime error on 's'.

Fixes rdar://150557314 ([nonescapable] Declaration of inout MutableSpan
parameter requires LifetimeDependence experimental feature)
2025-05-21 00:25:00 -07:00
eeckstein
0ceb5171ff Merge pull request #81649 from eeckstein/global-inlinearray-initialization
Allow more complex InlineArray initializations to end up in a statically initialized global
2025-05-21 06:24:28 +02:00
Augusto Noronha
c8eba86c3e Merge pull request #79171 from augusto2112/debug-info-witness-table
[DebugInfo] Emit debug info for witness tables
2025-05-21 09:23:04 +09:00
Erik Eckstein
9052652651 add the prepareInitialization builtin.
It is like `zeroInitializer`, but does not actually initialize the memory.
It only indicates to mandatory passes that the memory is going to be initialized.
2025-05-20 20:46:33 +02:00
Stephen Canon
3aa7b592b6 Implement Builtin.select binding llvm select instruction (#81598)
Not used (yet), but needed to implement SIMD.replacing(with:where:) idiomatically, and probably useful otherwise.
2025-05-20 13:30:59 -04:00
Artem Chikin
d8176a7e89 [Compile Time Values] Add syntactic verification of valid expressions in '@const' contexts
Syntactically verify that initializer expressions of '@const' variables and argument expressions to '@const' parameters consist strictly of syntactically-verifiable set of basic values and operations
2025-05-20 09:38:36 -07:00
Hamish Knight
edca7c85ad Adopt ABORT throughout the compiler
Convert a bunch of places where we're dumping to stderr and calling
`abort` over to using `ABORT` such that the message gets printed to
the pretty stack trace. This ensures it gets picked up by
CrashReporter.
2025-05-19 20:55:01 +01:00
Hamish Knight
b8fc71c684 [AST] Fix an accidental use of llvm::errs 2025-05-19 20:55:01 +01:00
Hamish Knight
bdd74e717e [AST] Remove redundant logging in validateGenericSignature
We already setup a PrettyStackTrace to include the generic signature
on a crash.
2025-05-19 20:55:01 +01:00
Hamish Knight
d672f750e7 [Basic] Rename abortWithPrettyStackTraceMessage to ABORT
Turn it into a wrapping macro that includes the file location, and
move into `Assertions.h`.
2025-05-19 20:55:01 +01:00
Rintaro Ishizaki
f57e2d7676 Merge pull request #81547 from rintaro/macros-wait-1
[Macros] Revert the 'wait' timeout update back to 1 second
2025-05-16 11:21:01 -07:00
Anthony Latsis
4313f8f262 Merge pull request #81538 from AnthonyLatsis/pinus-sibirica
AST, Sema: Fix 2 `NonisolatedNonsendingByDefault` bugs
2025-05-16 09:42:52 +01:00
Rintaro Ishizaki
8474d27b2f Revert "[Macros] Mitigate plugin process 'wait' failure"
This reverts commit be25ea2584.
2025-05-15 16:15:25 -07:00
Slava Pestov
2eceb299c9 Merge pull request #81516 from slavapestov/fix-pack-task-dealloc
IRGen: Fix out-of-order task_dealloc with parameter pack metadata
2025-05-15 17:02:08 -04:00
Anthony Latsis
d90c7cb57a DiagnosticEngine: Fix attribute insertion location for closures with capture lists 2025-05-15 20:17:42 +01:00
Rintaro Ishizaki
a0aad5c0b0 Merge pull request #81517 from rintaro/macros-wait-rdar150474701
[Macros] Mitigate plugin process 'wait' failure
2025-05-15 11:06:18 -07:00
Slava Pestov
be860a8e9c AST: Fix latent bug in TypeTransformer::transformPackElementType() 2025-05-15 12:22:21 -04:00
Slava Pestov
fe31c61b14 AST: Remove stray assert
A pack archetype from an outer expansion here is treated as a scalar.
2025-05-15 12:22:21 -04:00
Pavel Yaskevich
917524de94 Merge pull request #81496 from xedin/inheritActorContext-alwayse
[AST/Sema/SIL] Implement `@_inheritActorContext(always)`
2025-05-15 08:17:30 -07:00
Slava Pestov
ccaf7e149f Merge pull request #81522 from slavapestov/fix-rdar151162470
AST: Fix two bugs with SelfProtocolConformance
2025-05-15 07:44:35 -04:00
eeckstein
0d3edd629b Merge pull request #81502 from eeckstein/debug-info-in-embedded
embedded: fix source location of diagnostics which appear in imported modules
2025-05-15 06:58:54 +02:00
Slava Pestov
52afa15a74 AST: Fix two bugs with SelfProtocolConformance
There were two problems that have been there for years:

- SubstitutionMap::lookupConformance() assumes that every concrete conformance
  in the path has a root normal conformance. But calling getRootNormalConformance()
  on a self conformance would assert.

- SelfProtocolConformance::getAssociatedConformance() was not implemented. While
  self-conforming protocols do not have associated types, they can inherit from
  other protocols, and we model this with an associated conformance requirement
  having a subject type of `Self`.

Both problems were hidden by the fact that ProtocolConformanceRef::subst()
directly handled self-conforming existentials without calling into the
substitution map. But that is the wrong place for other reasons. The refactoring
in a209ff8869 exposed both of the above issues.

Fixes rdar://problem/151162470.
2025-05-14 23:34:53 -04:00
Pavel Yaskevich
a4f6d710cf [Sema] Start propagating @_inheritActorContext(always) attribute to closures 2025-05-14 20:08:00 -07:00
Pavel Yaskevich
c0aca5384b [ASTGen] Transform @_inheritActorContext into a custom attribute with an optional modifier 2025-05-14 20:07:59 -07:00
Pavel Yaskevich
c050e8f75a [AST] Protect declarations with @_inheritActorContext(always) by a feature flag
This is going to avoid condfails when declarations are printed
in the swiftinterface files.
2025-05-14 20:07:59 -07:00
Pavel Yaskevich
04d46760bb [AST] Extend @_inheritActorContext attribute to support optional always modifier
By default (currently) the closure passed to a parameter with `@_inheritActorContext`
would only inherit isolation from `nonisolated`, global actor isolated or actor
context when "self" is captured by the closure. `always` changes this behavior to
always inherit actor isolation from context regardless of whether it's captured
or not.
2025-05-14 20:07:57 -07:00
Becca Royal-Gordon
36de3a85e9 Merge pull request #81459 from beccadax/mod-squad-serialize 2025-05-14 19:25:22 -07:00
Steven Wu
f2ef2d3d86 Merge pull request #81494 from cachemeifyoucan/eng/PR-remove-clang-module-cas-fs
[Caching] Remove CASFS based clang module implementation
2025-05-14 15:55:17 -07:00
Rintaro Ishizaki
4a62ef86d4 [Macros] Terminate macro plugin
Instead of expecting the plugin read `EOF` and exit, proactively
terminate the plugin and `wait` to reap it.
2025-05-14 13:09:43 -07:00
Rintaro Ishizaki
be25ea2584 [Macros] Mitigate plugin process 'wait' failure
Previously, the compiler waited the plugin process with
`llvm::sys::Wait(pid, /*SecondsToWait=*/1)`. But in the `Wait`
implementation, it sets the `alarm(SecondsToWait)`, then
`wait4(pid, ..)` so if the alarm fires before the `wait4` call,
it may miss the timeout and can wait indefinitely. To mitigate that
risk,use `10` for the timeout value.

rdar://150474701
2025-05-14 12:38:28 -07:00
Becca Royal-Gordon
e71f837b1f [NFC] Stub module selector DeclNameRef/Loc members 2025-05-14 11:16:02 -07:00
Becca Royal-Gordon
c3a61bee0e Add experimental feature for module selector 2025-05-14 11:16:02 -07:00
Steven Wu
3c81c1ca9f [Caching] Remove CASFS clang module implemenation
Remove the CASFS based clang module implemenation as it is not longer
used.
2025-05-14 09:35:03 -07:00
Hamish Knight
93c37b49c5 Merge pull request #81028 from hamishknight/fix-completion-sourceranges
[IDE] Avoid uses of `isBeforeInBuffer` in `TypeCheckASTNodeAtLocRequest`
2025-05-14 16:26:56 +01:00
Holly Borla
40b57094da Merge pull request #81022 from nickolas-pohilets/mpokhylets/fix-80992
Fixed no copying IsIsolated flag when cloning subscript params
2025-05-14 08:09:40 -07:00
Joe Groff
52d7781758 Merge pull request #81424 from jckarter/same-type-constraint-stop-copyable
Sema: Allow `T == NonCopyableOrEscapable` same-type constraints without a redundant `T: ~Copyable`.
2025-05-14 08:09:05 -07:00
Hamish Knight
d00f45a0c6 [AST] Switch FuncDecl::get{Start,End}Loc to using early return 2025-05-14 11:42:26 +01:00
Hamish Knight
84febf639d [AST] Remove a couple of checks from FuncDecl::getSourceRange
These don't appear to be necessary, let's mirror the logic in
`getStartLoc` and remove them.
2025-05-14 11:15:42 +01:00