Commit Graph

261 Commits

Author SHA1 Message Date
Erik Eckstein
62e4cfbea7 AST: add Type.interfaceTypeOfArchetype and some related APIs 2025-08-28 07:17:54 +02:00
Erik Eckstein
e84228baf4 Swift AST: add some Type APIs 2025-08-28 07:17:53 +02:00
Doug Gregor
6e419b6345 Revert "[6.2] Accept @cdecl global functions and enums, behind experimental feature flags" 2025-07-16 10:05:35 -07:00
Alexis Laferrière
3b33531ff7 ASTGen: Accept @cdecl 2025-07-03 14:11:27 -07:00
Meghana Gupta
a9b831788d Update spelling for representing lifetime dependencies to @_lifetime 2025-06-11 08:03:39 -07:00
Pavel Yaskevich
8da356a1c2 [ASTGen] Implement bridging for using declaration
(cherry picked from commit 4b5105df5e)
2025-06-04 13:16:55 -07:00
Pavel Yaskevich
e12201769d [AST/Sema/SIL] Implement @_inheritActorContext(always)
- Extend `@_inheritActorContext` attribute to support optional `always` modifier.
  The new modifier will make closure context isolated even if the parameter is not
  captured by the closure.
- Implementation `@_inheritActorContext` attribute validation - it could only be
  used on parameter that have `@Sendable` or `sending` and `@isolated(any)` or
  `async` function type (downgraded to a warning until future major Swift mode
  to avoid source compatibility issues).
- Add a new language feature that guards use of `@_inheritActorContext(always)` in swift interface files
- Update `getLoweredLocalCaptures` to add an entry for isolation parameter implicitly captured by `@_inheritActorContext(always)`
- Update serialization code to store `always` modifier

(cherry picked from commit 04d46760bb)
(cherry picked from commit c050e8f75a)
(cherry picked from commit c0aca5384b)
(cherry picked from commit a4f6d710cf)
(cherry picked from commit 6c911f5d42)
(cherry picked from commit 17b8f7ef12)
2025-05-22 11:32:35 -07:00
Michael Gottesman
e04e15f125 [swift-settings] Now that we aren't using it immediately, remove it from tree.
We can always get it back from the git history.

rdar://150695113
(cherry picked from commit 9d59dbed17)

Conflicts:
	include/swift/AST/DiagnosticsSema.def
	include/swift/Basic/Features.def
	test/abi/macOS/arm64/concurrency.swift
	test/abi/macOS/x86_64/concurrency.swift
2025-05-06 14:12:23 -07:00
Meghana Gupta
5885421c06 Bridge getSwiftMutableSpanDecl() and isBuiltinType() 2025-04-30 14:39:44 -07:00
Andrew Trick
9b9a4056bd [NFC] SwiftCompilerSource: bridge Function.accessorKindName
(cherry picked from commit 25e9cbf3f1)
2025-04-30 00:09:39 -07:00
Pavel Yaskevich
06f880e65c [AST/ASTGen/Sema/Serialization] Remove @execution attribute
Complete the transition from `@execution` to `@concurrent` and `nonisolated(nonsending)`
2025-04-16 13:18:52 -07:00
Pavel Yaskevich
fde841704c [AST/Parse] Implement nonisolated(nonsending) type modifier 2025-04-16 10:06:08 -07:00
Pavel Yaskevich
d8c64c1ff0 [AST/Sema] Intoduce nonisolated(nonsending) as a replacement for @execution(caller) 2025-04-16 10:06:08 -07:00
Pavel Yaskevich
4a973f7b4b [AST/Sema] Replace @execution(concurrent) with @concurrent 2025-04-16 10:06:08 -07:00
Meghana Gupta
96aeea9f2b Rename ParsedLifetimeDependenceKind::Scope -> ParsedLifetimeDependenceKind::Borrow 2025-04-09 10:18:11 -07:00
Meghana Gupta
91ad1451ce Add support for @lifetime(&arg) 2025-04-09 10:18:11 -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
Doug Gregor
74fb36f9bc Translate Fix-Its from the C++ diagnostics into swift-syntax diagnostics
The swift-syntax diagnostic formatter doesn't actually print Fix-Its,
but at least they're available now.
2025-03-28 13:20:57 -07:00
Artem Chikin
281f84da0f [Compile Time Values] Rewrite the 'Diagnose Unknown Compile Time Values' diagnostic pass in Swift 2025-03-28 10:30:07 -07:00
Erik Eckstein
ac55dae26c AST: add the possibility to compare SubstitutionMaps 2025-03-26 08:45:38 +01:00
Erik Eckstein
b39a6cdd22 AST: add var GenericSignature.genericParameters 2025-03-26 07:30:11 +01:00
Erik Eckstein
42bba8f484 AST: add some Declaration APIs
* `var Declaration.parentModule`
* `var AbstractFunctionDecl.isOverridden`
2025-03-26 07:30:11 +01:00
Erik Eckstein
d523e303c3 SIL/AST: move some SIL.Type APIs to the TypeProperties protocol which makes them also available for AST.Type and AST.CanonicalType 2025-03-26 07:30:10 +01:00
Hamish Knight
f8ab391737 Introduce type sugar for InlineArray (#80087)
* [CS] Decline to handle InlineArray in shrink

Previously we would try the contextual type `(<int>, <element>)`,
which is wrong. Given we want to eliminate shrink, let's just bail.

* [Sema] Sink `ValueMatchVisitor` into `applyUnboundGenericArguments`

Make sure it's called for sugar code paths too. Also let's just always
run it since it should be a pretty cheap check.

* [Sema] Diagnose passing integer to non-integer type parameter

This was previously missed, though would have been diagnosed later
as a requirement failure.

* [Parse] Split up `canParseType` 

While here, address the FIXME in `canParseTypeSimpleOrComposition`
and only check to see if we can parse a type-simple, including
`each`, `some`, and `any` for better recovery.

* Introduce type sugar for InlineArray

Parse e.g `[3 x Int]` as type sugar for InlineArray. Gated behind
an experimental feature flag for now.
2025-03-23 15:31:37 -07:00
Rintaro Ishizaki
92a6fece48 [ASTGen] ObjC improvements
* Generate `#selector(...)` expression
* Generate `#keyPath(...)` expression
* Implicit `@objc` attribute for `@_objcImplementation` attribute
2025-03-20 05:04:58 -07:00
Slava Pestov
8bcd09aaa4 SIL: Preliminary refactoring of SILWitnessTable::AssociatedConformanceWitness
The Protocol field isn't really necessary, because the conformance
stores the protocol. But we do need the substituted subject type
of the requirement, just temporarily, until an abstract conformance
stores its own subject type too.
2025-03-18 19:38:42 -04:00
Rintaro Ishizaki
7add493002 [ASTGen] Generate '@_spi_available' attribute 2025-03-16 17:41:21 -07:00
Rintaro Ishizaki
607d122fe9 [ASTGen] Handle several missing syntax
* MissingExpr: Generate ErrorExpr with previous token location
* MissingType: Generate ErrorTypeRepr with previous token location
* MissingPattern: Generate implicit '_' pattern for recovery
2025-03-16 17:41:21 -07:00
Rintaro Ishizaki
ddd5b12661 [ASTGen] Handle trailing where clause in macro declarations 2025-03-16 17:41:21 -07:00
Rintaro Ishizaki
a2e40d6c31 [ASTGen] Generate @_typeEraser attribute 2025-03-16 15:18:59 -07:00
Rintaro Ishizaki
d1f892cbdc [ASTGen] Generate '@reasync' and '@rethrows'
Also, fallback 'shouldBeRejectedByParser' attribute names to
'CustomAttr'.
2025-03-16 15:14:27 -07:00
Rintaro Ishizaki
9fc8bba26d [ASTGen] Fix 'RawDocCommentAttr' generation
* Generate only when 'AttachCommentsToDecls' lang option is enabled.
* Fix the range.
2025-03-16 15:00:29 -07:00
Rintaro Ishizaki
c90768f36e [ASTGen] Fix NamedOpaqueReturnTypeRepr
Generic parameter list was missing
2025-03-16 14:59:43 -07:00
Rintaro Ishizaki
bc668b6232 [ASTGen] Fix nullability
For 'arbitrary' macro names
2025-03-16 14:48:00 -07:00
Rintaro Ishizaki
996e72061a [ASTGen] Gnerate PlaceholderTypeRepr 2025-03-16 14:38:32 -07:00
eeckstein
418bd2208d Merge pull request #80013 from eeckstein/simplify-sil-type
AST/SIL: Refactor and cleanup `AST.Type`, `AST.CanonicalType` and `SIL.Type`
2025-03-14 18:10:25 +01:00
Erik Eckstein
d52f7d1619 AST/SIL: Refactor and simplify AST.Type, AST.CanonicalType and SIL.Type
* let `SIL.Type` conform to `TypeProperties` to share the implementation of common type properties between the AST types and `SIL.Type`
* call references to an `AST.Type` `rawType` (instead of just `type`)
* remove unneeded stuff
* add comments
2025-03-14 09:40:22 +01:00
Rintaro Ishizaki
ac80775201 [ASTGen] Generate miscellaneous builtin pound
`#error`, `#warning`, and `#assert`.
Also #_hasSymbol statement condition
2025-03-13 20:28:46 -07:00
eeckstein
ca76efabb4 Merge pull request #79908 from eeckstein/fix-witness-table-specialization
embedded: fix specialization of associated conformance entries in witness tables
2025-03-11 18:16:23 +01:00
eeckstein
19c51e2ae2 Merge pull request #79872 from WeZZard/bugfix/unchecked-ref-casting-with-optional-any-object
[SILOptimizer] Fixes the ValueDefUseWalker to handle potential unchecked_ref_cast between optional and non-optional class types.
2025-03-11 17:15:10 +01:00
Erik Eckstein
5212d92b57 Swift AST: add Conformance.getAssociatedConformance 2025-03-11 11:17:00 +01:00
Michael Gottesman
04bb69f426 Merge pull request #79727 from gottesmm/pr-025c1133954b74e7b4eda77e1a6f3bcafd4eb6cf
[concurrency] Add initial support for SwiftSettings to control defaultIsolation at the file level.
2025-03-10 22:35:00 -07:00
WeZZard
2237faca04 [SILOptimizer] Refines the implementation of of the bridged SILType for Swift. 2025-03-11 09:29:11 +08:00
Michael Gottesman
f64dd5a8d5 [concurrency] Add initial support for SwiftSettings to control defaultIsolation at the file level.
We introduce a new macro called #SwiftSettings that can be used in conjunction
with a new stdlib type called SwiftSetting to control the default isolation at
the file level. It overrides the current default isolation whether it is the
current nonisolated state or main actor (when -enable-experimental-feature
UnspecifiedMeansMainActorIsolated is set).
2025-03-10 17:33:45 -07:00
eeckstein
737b5ec924 Merge pull request #79674 from eeckstein/simplify-open-existential-metatype
Optimizer: Rework peephole optimizations to replace existential (archetypes) with concrete types
2025-03-10 08:18:52 +01:00
Rintaro Ishizaki
b6918a300a Merge pull request #79843 from rintaro/astgen-misc
[ASTGen] Misc fixes
2025-03-07 16:58:44 -08:00
Rintaro Ishizaki
a506bae136 [ASTGen] Generate 'IsExpansionPattern' generic requirements
E.g. `where repeat each T: Comparable`
2025-03-07 10:28:47 -08:00
Rintaro Ishizaki
c669004e4c [ASTGen] Clone expanded AvailabilitySpec to set macro location 2025-03-07 07:18:39 -08:00
Rintaro Ishizaki
0a56198879 [ASTGen] Remove BridgedAvailabilityDomain 2025-03-07 07:18:23 -08:00
Erik Eckstein
26c7310a9a Swift AST: Fix debug description of Type
Don't get the swift source version string, but the debug dump string
2025-03-07 15:59:35 +01:00