Commit Graph

1795 Commits

Author SHA1 Message Date
Aidan Hall
88b2c1c056 Merge pull request #86846 from aidan-hall/disable-lifetime-indices
LifetimeDependence: Disable parameter indices in Swift lifetime dependence annotations
2026-02-06 22:34:52 +00:00
Aidan Hall
63da6499eb LifetimeDependence: Disable indices in Swift lifetime dependencies
Lifetime indices are never necessary in Swift, they unnecessarily expose
implementation details, and they make lifetime annotations more error-prone,
since they may need to be updated if a function's parameter list changes.

The Swift Syntax parser also cannot handle lifetime annotations where the target
is an index. The main reason the C++ parser supports them is because it is also
used for SIL.
2026-02-06 10:27:01 +00:00
Ian Anderson
6f9919edc1 Merge pull request #86906 from ian-twilightcoder/firmware-os
[Triple] Support the new target triple "os" for firmware
2026-02-04 12:15:56 -08:00
Slava Pestov
437589d1b6 Merge pull request #86950 from slavapestov/remove-more-solver-hacks
Sema: Add flag to disable more solver performance hacks
2026-02-04 08:13:31 -05:00
Slava Pestov
9623b85b7b Parse: Remove last remnants of 'operator designated types' 2026-02-03 16:34:10 -05:00
Slava Pestov
061958f970 Sema: Eagerly filter out protocol extension operators
This optimizes for the case where we have a disjunction that contains an
operator defined in a protocol, and a protocol defined in a protocol
extension, and furthermore, the protocol extension operator's type is a
refinement of the protocol requirement operator's type.

In this case, there are three possibilities:

- Either the operator requirement is witnessed by a concrete operator
  in the conforming type, in which case the solution involving the
  protocol extension operator is going to be worse, so we can skip this
  choice.

- Otherwise, the protocol requirement operator is witnessed by the same
  protocol extension operator that we skipped, in which case we will find
  the same solution if we just pick the protocol requirement operator
  anyway.

- The only other possibility is that the protocol requirement operator
  is witnessed by a protocol extension operator, but also, a more
  refined protocol extension operator exists. However, it appears that in
  this case, solution ranking _also_ picks the solution involving the
  protocol requirement operator, as the new test case demonstrates.

Thus, we gain nothing by considering these protocol extension operators.
Skip them when forming the disjunction.
2026-02-03 16:34:09 -05:00
Ian Anderson
69fa949c01 [Triple] Support the new target triple "os" for firmware
Add support for the new Firmware llvm::Triple::OSType, and make a swift::DarwinPlatformKind to go with it.

rdar://165361368
2026-02-03 13:02:44 -08:00
Meghana Gupta
e27a94af40 Diagnose when a borrow/mutate accessor is defined along with other accessors 2026-02-01 17:39:38 -08:00
Tim Kientzle
25a4744d55 Merge pull request #86698 from tbkka/tbkka-yielding_borrow-Part4
End-to-end test of yielding accessors via protocols
2026-01-23 19:33:12 -08:00
Tim Kientzle
1594ad5c70 Merge pull request #86688 from tbkka/tbkka-yielding_borrow-Part3
Preparation for switching .swiftinterface to `yielding` terminology
2026-01-22 20:12:30 -08:00
Tim Kientzle
6a518100ae Fix REQUIRES lines 2026-01-22 11:24:26 -08:00
Tim Kientzle
97f9052fbf clarify the situation with yielding mutate 2026-01-22 09:03:50 -08:00
Tim Kientzle
7887d6bd61 Correct a bunch of obvious mistakes
To see whether we can set a property on a value, we need to act
directly on a value, not indirectly on some class object inside
the value.  <sigh>
2026-01-22 09:02:37 -08:00
Tim Kientzle
bcf30edd76 Merge branch 'main' into tbkka-yielding_borrow-Part4 2026-01-21 16:59:53 -08:00
Tim Kientzle
e1b1abafcf End-to-end test of yielding accessors via protocols
Two simple tests that access yielding accessors through
a protocol.  (And a fix for the bug they revealed.)
2026-01-21 16:32:18 -08:00
Tim Kientzle
1c2bd08c77 Preparation for switching .swiftinterface to yielding terminology
For now, we write `read`/`modify` to .swiftinterface files
so they can be read by the draft implementation in current
compilers.  Here are some of the issues:

* We _cannot_ support `read`/`modify` in Swift sources without
  the user specifying a flag. That's because the idiom below occurs
  in real code, and would be broken by such support.  So when
  we enable the `CoroutineAccessors` flag by default, we _must_
  not support `read`/`modify` as accessor notations in source.

```
struct XYZ {
  // `read` method that takes a closure
  func read(_ closure: () -> ()) { ... }

  // getter that uses the above closure
  var foo: Type {
    read { ... closure ... }
  }
}
```

* .swiftinterface files don't have the above problem.
  Accessor bodies aren't stored at all by default, and
  when inlineable, we always write explicit `get`.
  So we can continue to accept `read`/`modify` notation
  in interface files.

So our strategy here is:

* We'll accept both `read`/`modify` and `yielding borrow`/`yielding mutate`
  in interface files for a lengthy transition period.

* We'll write `read`/`modify` to swiftinterface files for
  a little longer, then switch to `yielding borrow`/`yielding mutate`.

* We'll disable `read`/`modify` support in source files
  when we enable `CoroutineAccessors` by default.
  (We can't even diagnose, due to the above idiom.)

This means that early adopters will have to update their sources
to use the new terminology.  However, swiftinterface files
will be exchangeable between the new and old compilers for a little
while.
2026-01-21 07:01:46 -08:00
Meghana Gupta
5676bfc46f Add Parser support for borrow and mutate protocol constraints 2026-01-20 10:33:23 -08:00
Tim Kientzle
104dba920b [SE-0474] Implement yielding borrow and yielding mutate syntax
This does not rename all the internal variables, functions, and types
whose names were based on the old syntax.

I think it adds new syntax support everywhere it's needed while
retaining enough of the old syntax support that early adopters will
see nice deprecation messages guiding them to the new syntax.
2026-01-03 15:07:10 -08:00
Meghana Gupta
5c4ce2f942 Merge pull request #86023 from meg-gupta/miscborrowfixes
Minor fixes to borrow accessors
2025-12-16 20:03:19 -08:00
Andrew Trick
edfe1a1e47 Merge pull request #85998 from atrick/lifedep-sametype
[lifetimes] add same-type default lifetime inference
2025-12-16 11:01:09 -08:00
Rintaro Ishizaki
3de0ae6270 Merge pull request #85927 from rintaro/parser-comment-retention 2025-12-15 06:14:00 -08:00
Andrew Trick
6aaf9034ae [lifetimes] add same-type default lifetime inference
Infer @lifetime(result: copy arg) for every (result: R, arg: A) pair
such that R == A and 'arg' is not 'inout'.
2025-12-12 21:21:09 -08:00
Meghana Gupta
20b23d631c Diagnose borrow/mutate accessors in enums
We don't have support for borrowing switch on Copyable types.
It is supported for ~Copyable types, but the return expression emission for borrow accessors is not yet implemented.
Diagnose instead of crashing the compiler.
2025-12-12 11:38:37 -08:00
Artem Chikin
e593fd97a0 Add parsing for a declaration attribute '@warn' for source-level warning group behavior control 2025-12-12 10:14:14 -08:00
Ben Cohen
9dd9e96e1d Allow Hashable: ~Copyable (#85748)
Builds on #85746 which covers Equatable.
2025-12-11 14:47:36 -08:00
Rintaro Ishizaki
dffd88ee51 [Parser] Eliminate 'CommentRetentionMode::None' in Lexer
Lexer should always set `Token.CommentLength` correctly because it
necessary for restoring to the token position with comments.
Otherwise, 'Token::isAtStartOfLine()' might not correctly set.
2025-12-10 10:10:51 -08:00
Ben Cohen
fbb420f38d Allow Equatable: ~Copyable (#85746)
Under review
[here](https://forums.swift.org/t/se-0499-support-copyable-escapable-in-simple-standard-library-protocols/83297).
Multi-part version of #85079.
2025-12-03 05:45:38 -08:00
Hamish Knight
61a5ae8e01 [CS] Eagerly bind hole in recordInvalidNode
We know this is where the issue is so we can immediately bind to a hole,
ensuring we don't produce unnecessary downstream diagnostics from
things we can't infer.
2025-11-16 11:47:21 +00:00
Kavon Farvardin
314093f426 SILGen: add RValue emission for BorrowExpr 2025-11-07 14:01:35 -08:00
Alexis Laferrière
048c9276a9 Merge pull request #85122 from xymus/official-c-attr
SE-495: Make `@c` an official feature
2025-10-30 16:06:25 -07:00
Alexis Laferrière
000c2604b0 SE-495: Make @c an official feature 2025-10-29 11:55:41 -07:00
Hamish Knight
00d8774032 [Sema] Upgrade tuple shuffle warning to error in future lang mode
This has been deprecated for a while now, flip it to an error for a
future language mode.
2025-10-29 15:14:23 +00:00
Hamish Knight
24347812f5 [Diag] Reword the tuple shuffle diagnostic
"reorder" seems a bit less jargony than "shuffle", and include the 
labels that are being reordered.
2025-10-29 15:14:23 +00:00
Becca Royal-Gordon
393965090e Merge pull request #34556 from beccadax/mod-squad-2
[SE-0491] Implement lookup and diagnostics for module selectors (MyMod::someName)
2025-10-28 16:00:26 -07:00
Hamish Knight
b5627c9337 Merge pull request #85145 from a7medev/autodiff-comma-fix-its
[Diagnostics] Add missing fix-its for unexpected/expected comma in attribute arguments
2025-10-27 09:08:16 +00:00
Ahmed Mahmoud
d0c2d8b317 [Diagnostics] Add fix-its for unexpected/expected comma in auto-diff attributes 2025-10-26 23:47:19 +03:00
Becca Royal-Gordon
e6d8b02626 Make module selectors non-experimental
Approved by SE-0491.
2025-10-24 16:23:50 -07:00
Meghana Gupta
7e8d8b671f Merge pull request #85097 from meg-gupta/withdiagpr
Update borrow accessor diagnostics and synthesis
2025-10-24 15:06:19 -07:00
Kuba (Brecka) Mracek
eb23d3bc0a Merge pull request #85074 from kubamracek/section
SE-0492: Stabilize @_section/@_used into @section/@used
2025-10-24 12:29:48 -07:00
Meghana Gupta
c85e214369 Fix synthesis of get/set protocol constraints when borrow/mutate accessors are present 2025-10-24 04:29:46 -07:00
Kuba Mracek
ca737d3d97 Tweak diagnostic text on @section/@const errors 2025-10-23 17:05:41 -07:00
Kuba (Brecka) Mracek
66eef684ee Merge pull request #80212 from kubamracek/object-file-format
Add #objectFormat compilation conditional (SE-0492)
2025-10-23 12:58:23 -07:00
Kuba Mracek
4923db8761 Adjust PlatformConditionKinds.def + target #objectFormat test more precisely 2025-10-22 10:38:52 -07:00
Kuba Mracek
c3f865be4a Add #objectFormat compilation conditional (SE-0492) 2025-10-16 15:15:27 -07:00
Becca Royal-Gordon
683ce9d639 Update and test ASTGen for module selectors 2025-10-16 13:30:30 -07:00
Becca Royal-Gordon
b6e22cb6f5 Allow :: as an alias for . in scoped imports 2025-10-16 13:30:29 -07:00
Becca Royal-Gordon
f82881cc8e Parse module selectors in permitted locations 2025-10-16 13:30:29 -07:00
Becca Royal-Gordon
f1db5d3a6a [NFC] Add tok::colon_colon to parser 2025-10-16 13:30:29 -07:00
Becca Royal-Gordon
cab38afcf7 Use parseDeclNameRef in a few more places 2025-10-16 13:30:26 -07:00
Rintaro Ishizaki
9b68204f06 Merge pull request #84278 from kwikysw/parse-closure-missing-in
[Parse] Diagnose missing 'in' after closure signature
2025-10-10 11:23:04 -07:00