Commit Graph

85 Commits

Author SHA1 Message Date
deniz dizman
f515cd72c1 [Compile Time Constant Extraction] Extraction support for force unwrapped optionals (#85047)
Adds support for extracting force unwrapped optionals. 

```
let prop: MyType = MyType()! 
```

In this case the value kind was being extracted as a Runtime value. 

resolves rdar://146046727

Co-authored-by: Deniz Dizman <ddizman@apple.com>
2025-10-23 16:13:05 -04:00
Justin (Siri) Kang
dfe8a46895 Update keypath test 2025-09-02 16:56:07 -07:00
Justin (Siri) Kang
c42aca10e3 [Compile Time Constant Extraction] Support for open existential expressions 2025-09-02 09:25:01 -07:00
James Paolantonio
a30ed9ec39 [Const Extract] Fix nil default argument being extracted as nil raw literal (#82339)
This was missed in https://github.com/swiftlang/swift/pull/78511.

Resolves rdar://153563086

Co-authored-by: James Paolantonio <j_paolantonio@apple.com>
2025-07-08 09:16:19 -04:00
Anthony Latsis
2cd90bdd69 AST: Quote attributes more consistently in DiagnosticsSema.def 2025-04-22 18:23:36 +01:00
Hamish Knight
bc5c8f51bd [test] Fix extension macros in test suite
Make sure we're using `providingExtensionsOf` as the extended type,
previously we were just using the unqualified name of the decl.
2025-03-28 21:35:59 +00:00
Pavel Yaskevich
51c833f2a9 Merge pull request #79617 from xedin/isolate-buildBlock-in-if-and-case-statements
[BuilderTransform] Type-check `buildBlock` of each condition body separately from "join" operation
2025-02-27 16:45:22 -08:00
Pavel Yaskevich
d70f14e936 [BuilderTransform] If: Save result of buildBlock into a variable before using in buildEither
Similar to `case` statements, if chain is non-optional, let's
isolate `buildBlock` of every branch into a separate type variable.
2025-02-25 13:09:35 -08:00
Venkatesh Sriram
2eaaf5193a [Compile Time Constant Extraction] Handle cases where variables with attached result builders are initialized without builder syntax 2025-02-14 10:36:06 -08:00
Venkatesh Sriram
a5cc53f356 Merge pull request #78511 from venkatesh5789/null-value-optional-extraction
[Compile Time Constant Extraction] Extract Nil Values for Optionals
2025-01-16 18:43:07 +05:30
Venkatesh Sriram
c6c8526b87 [Compile Time Constant Extraction] Extract Nil Values for Optionals 2025-01-16 12:04:03 +05:30
Venkatesh Sriram
14a5207f48 [Compile Time Constant Extraction] Extract Partial Keypath Expressions 2025-01-07 16:46:05 +05:30
Daniel Rodríguez Troitiño
ba68faaed5 [test] Mark tests that use experimental/upcoming features as such
Find all the usages of `--enable-experimental-feature` or
`--enable-upcoming-feature` in the tests and replace some of the
`REQUIRES: asserts` to use `REQUIRES: swift-feature-Foo` instead, which
should correctly apply to depending on the asserts/noasserts mode of the
toolchain for each feature.

Remove some comments that talked about enabling asserts since they don't
apply anymore (but I might had miss some).

All this was done with an automated script, so some formatting weirdness
might happen, but I hope I fixed most of those.

There might be some tests that were `REQUIRES: asserts` that might run
in `noasserts` toolchains now. This will normally be because their
feature went from experimental to upcoming/base and the tests were not
updated.
2024-11-02 11:46:46 -07:00
Venkatesh Sriram
0d9e62e143 Merge pull request #76917 from venkatesh5789/external-conformance-info
[Compile Time Constant Extraction] Add information about where a particular conformance has been defined
2024-10-17 10:19:07 -07:00
Venkatesh Sriram
9ca55fdf89 [Compile Time Constant Extraction] Add information about where a particular conformance has been defined 2024-10-15 15:46:21 -07:00
James Paolantonio
5e1de491b6 [Const extract] Extract static function calls (#76251)
Co-authored-by: James Paolantonio <j_paolantonio@apple.com>
2024-10-10 09:59:20 -04:00
Venkatesh Sriram
f04486db3e [Compile Time Constant Extraction] Extract listed Availability Attributes for buildLimitedAvailability in Result Builders 2024-09-26 14:14:10 -07:00
Venkatesh Sriram
82f85d83c2 Merge pull request #75219 from venkatesh5789/result-builder-extraction
[Compile Time Constant Extraction] Extract Result Builder Expressions
2024-07-24 18:27:17 -07:00
Venkatesh Sriram
4c3439f942 [Compile Time Constant Extraction] Extract Result Builder Expressions 2024-07-24 10:08:24 -07:00
Artem Chikin
3e8e44d34e Merge pull request #74698 from artemcm/ConstExtractConformanceExtractionFix
[Compile Time Constant Extraction] Query nominal type *conformances* to get at the protocols, instead of `getAllProtocols()`.
2024-06-27 09:56:27 -07:00
Venkatesh Sriram
465634cada Merge pull request #74491 from venkatesh5789/interpolated-string-extraction
[Compile Time Constant Extraction] Extract Interpolated String Literals
2024-06-26 10:34:42 -07:00
Artem Chikin
1be5dbba38 [Compile Time Constant Extraction] Ensure macro-expanded declarations are visited in WMO
Resolves rdar://130036855
2024-06-25 14:23:41 -07:00
Artem Chikin
f5f0c0043d [Compile Time Constant Extraction] Query nominal type conformances to get at the protocols, instead of getAllProtocols.
As it stands, for extension macros which add protocol conformances, the list of protocols specified on the macro's 'conformances:' parameter gets added in its entirety to the list of a nominal type's protocols in 'ConformanceLookupTable::addMacroGeneratedProtocols'. Whereas the macro itself, may only add *some* of the specified conformances. This means that `getAllProtocols` may contain a super-set of protocols captured in `getAllConformances`, some of which may not actually be generated by the macro.

This change narrowly fixes ConstExtract to query actual generated conformances. Though, potentially we should make 'ConformanceLookupTable::addMacroGeneratedProtocols' behave in a way that reflects the protocols the macro actually adds the conformances to, instead of the ones it may add conformances to.

Resolves rdar://130316531
2024-06-25 12:29:29 -07:00
Venkatesh Sriram
9820865a80 [Compile Time Constant Extraction] Extract Interpolated String Literals 2024-06-25 11:11:20 -07:00
artemcm
e7ba93f20f Restrict preserve_conformance_metadata_attr_macros.swift test to OS supported by binary metadata reading tooling 2024-05-24 09:15:53 -07:00
Artem Chikin
b005ae1a30 Merge pull request #73851 from artemcm/RestrictExtractionTest
Restrict 'ExtractFromMacroExpansion.swift' test to OS supported by binary metadata reading tooling
2024-05-23 16:23:38 -07:00
Artem Chikin
1359bea5be Restrict 'ExtractFromMacroExpansion.swift' test to OS supported by binary metadata reading tooling 2024-05-23 10:19:10 -07:00
Venkatesh Sriram
a0d62d972e Merge pull request #73718 from venkatesh5789/keypath-extraction
[Compile Time Constant Extraction] Extract KeyPath Expressions
2024-05-23 10:01:36 -07:00
Venkatesh Sriram
6e797f5047 [Compile Time Constant Extraction] Extract KeyPath Expressions 2024-05-22 11:24:48 -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
981233ad37 Merge pull request #73128 from beccadax/objcimpl-resilient
Handle resilient stored properties in objcImpl
2024-04-30 20:50:33 -07:00
Becca Royal-Gordon
2947e6c96c Add target to failing objcImpl test 2024-04-30 12:03:46 -07:00
Nate Chandler
b1fbe4ea91 [BitwiseCopyable] Remove underscore. 2024-04-25 11:44:15 -07:00
artemcm
486654eb58 [Const Extract] Extract property wrapper details even when no default init is present 2024-04-25 11:42:51 -07:00
Apollo Zhu
708fb13c5b Extract decl in macro added extensions 2024-03-18 22:58:17 -07:00
Apollo Zhu
87bde4048a Test macro added vars/extensions are extracted 2024-03-18 20:17:51 -07:00
Slava Pestov
37dbd05354 ConstExtract: Update for noncopyable generics (sort of) 2024-03-01 11:05:54 -05:00
Kavon Farvardin
f296d8e158 NCGenerics: mass XFAIL tests
It's easier to get a handle on regressions while working through
failures if the tests that are known to not pass are XFAIL'd for
NoncopyableGenerics.
2024-02-20 18:26:05 -05:00
Apollo Zhu
9f9b3abeaa [Compile Time Constant Extraction] Extract from macro expansions
Fix logic for @_objcImplementation
2023-12-06 16:08:02 -08:00
Apollo Zhu
a8fd83703b Allow extractConstantsFromMembers on all nominal decls 2023-11-30 18:35:17 -08:00
Nuri Amari
fa6f6db02e Require asserts in tests enabling ExtractConstantsFromMembers feature
The feature is experimental and thus tests using it must require
asserts, lets they fail if run with a non assert toolchain.
2023-11-29 13:19:07 -08:00
Zhiyu Zhu/朱智语
6d3017cde3 [Compile Time Constant Extraction] Extract from extensions of types not declared in the same file/module (#70081)
Resolves rdar://118904022
2023-11-29 09:07:52 -08:00
Zhiyu Zhu/朱智语
9d1a92eb72 [Compile Time Constant Extraction] Add @extractConstantsFromMembers (#69944)
Add @extractConstantsFromMembers attribute under ExtractConstantsFromMembers experimental feature flag
2023-11-29 08:49:57 -08:00
Artem Chikin
faa9751c37 [Compile Time Constant Extraction] Emit underlying types for typealias types
Resolves rdar://113402135
2023-08-18 10:44:46 -07:00
Pavel Yaskevich
4bd60aeb4e [Tests] NFC: Remove/adjust runtime metadata related test cases 2023-08-15 12:17:31 -07:00
Artem Chikin
f39d62f65d Merge pull request #67692 from artemcm/ConstExtractPrintTypesOutOfContext
[Compile Time Constant Extraction] Map types with archetypes out of context, before mangling them for printing.
2023-08-03 11:08:58 -07:00
Artem Chikin
8fb4294507 [Compile Time Constant Extraction] Map types with archetypes out of context, before mangling them for printing.
Matching logic in the ASTPrinter. Otherwise we attempt to mangle types with archetypes in them, which cannot be done, and causes the compiler to crash.

Resolves rdar://113039215
2023-08-02 17:37:59 -07:00
Artem Chikin
0ea41efded [Compile Time Constant Extraction] Deprecated extraction of property mangled
names. It can often be more complex than the code can currently handle (e.g.
properties whose types include archetypes), and we
do not have a good motivating use-case to extract them.

Resolves rdar://113039215
2023-08-01 15:52:52 -07:00
Artem Chikin
72ed4e37ff [Compile Time Constant Extraction] Refactor collection of opaque type requirements
To reduce duplication of logic with other parts of the compiler, instead of destructuring the constraint type, write the requirements in the opaque type declaration's generic signature.
2023-06-30 11:02:24 -07:00
Artem Chikin
3f0c0f0553 [Compile Time Constant Extraction] Add extraction of all conformances and type aliases of applicable nominal types
This change adds to the extracted type metadata the following fields:
- Conformances: this is a list of all protocols that the given nominal type conforms to
- associated type aliases: this is a list of all associated types across all conformances that the given nominal type substitutes with concrete types. For a given associated type, we gather:
  - Associated type name
  - Substituted type's fully-qualified name
  - Substituted type's mangled name
  - If the substituted type is opaque:
    - List of conformance requirements of this opaque type
    - List of same-type requirements of this opaque type
2023-06-22 07:13:24 -07:00