Commit Graph

64 Commits

Author SHA1 Message Date
Guillaume Lessard cb85c226c0 [StdlibUnittest] rename .requireCapability to .require 2026-05-07 15:30:25 -07:00
Guillaume Lessard a2c9886d62 [test] replace wasi-based skips with feature-based requirements 2026-05-07 13:20:40 -07:00
Guillaume Lessard a4c6bec0c2 [test] skip rather than avoid crash tests for WASI 2026-05-07 13:20:39 -07:00
Steven Wu 12f8d9c6c9 [TEST] Switch to use new swift-driver when running tests
Default to use new swift-driver to run lit tests as legacy swift driver
is deprecated for a long time. The lit tests for legacy drivers are also
disable when running new swift-driver.

Tests that relies on legacy swift driver (for example, tests merge
module) can be enabled on conditions `legacy_swift_driver`. Fix and
split up some existing tests that relies on legacy driver.
2026-03-23 09:48:45 -07:00
Alejandro Alonso 714fd26830 Add the intermediate result for every leaf component 2025-10-22 13:00:55 -07:00
Alejandro Alonso 9933d3ccb2 Update KeyPath.swift 2025-09-13 14:59:19 -07:00
Alejandro Alonso f95e9e4ee4 Correctly handle alignment and appending keypaths
Add test for overaligned keypath arguments
2025-09-13 14:59:17 -07:00
Kuba Mracek 1d48f28d84 [KeyPath] Fix regression in == on keypaths 2024-04-30 12:50:03 -07:00
Yuta Saito cadc20cf3a [test] Make KeyPath test pointer-size agnostic part 2 2023-06-29 06:02:48 +00:00
Alejandro Alonso d9d26eec9d Add support for classes in _createOffsetBasedKeyPath 2023-06-22 14:07:41 -07:00
Yuta Saito 5cf10f29e0 [test] Make KeyPath test pointer-size agnostic
The field offset of the `age` property is 16 bytes on 64-bit platforms
but not on other pointer-sized platforms.
2023-06-20 17:45:15 +00:00
Alejandro Alonso 3360e41c9c Add SPI to reroot a keypath for a given superclass 2023-04-24 17:15:28 -07:00
Alejandro Alonso 3522a338a2 Create function to create an offset based keypath at runtime 2023-04-04 09:44:18 -07:00
Anthony Latsis 52ce15ee9d Gardening: Migrate test suite to GH issues: stdlib 2022-09-22 03:21:39 +03:00
Kuba (Brecka) Mracek 2fa79689fa Turn build-swift-stdlib-static-print on for freestanding preset (#41260) 2022-02-09 05:41:04 -08:00
Max Desiatov 372ada0e24 test: add handling for Wasm/WASI (#39519)
This change adds support for WASI in stdlib tests. Some tests that expect a crash to happen had to be disabled, since there's currently no way to observe such crash from a WASI host.
2022-01-12 14:24:50 +00:00
Erik Eckstein e5e28ff4c4 SILGen: avoid reusing the same opened archetype in keypath setter and getter functions. 2021-04-14 08:36:10 +02:00
Mike Ash a84a3a8f23 [Stdlib] Fix _swift_modifyAtWritableKeyPath_impl to check for ReferenceWritableKeyPaths.
Call through to _swift_modifyAtReferenceWritableKeyPath_impl in that case. This fixes an assertion failure (or worse) when upcasting a ReferenceWritableKeyPath and then using subscript(keyPath:) to modify a value with it.

rdar://74191390
2021-02-11 13:58:34 -05:00
Mike Ash ee8480fe71 [Stdlib] Fix swift_setAtWritableKeyPath to check for ReferenceWritableKeyPaths.
Call through to swift_setAtReferenceWritableKeyPath in that case. This fixes an assertion failure (or worse) when upcasting a ReferenceWritableKeyPath and then using subscript(keyPath:) to write a value with it.

rdar://problem/70609888
2020-11-13 13:00:16 -05:00
Hamish Knight b62c9b6b01 [CS] Use getParameterType for KeyPath as function
Previously we were using `getPlainType` to match
the parameter type against the key path's base
type. This gave us the external parameter type,
which would be the element type for a variadic
parameter.  However the code we generate expects
the internal parameter type, which is provided by
`getParameterType`.

Resolves rdar://problem/59445486.
2020-03-11 17:21:28 -07:00
Arnold Schwaighofer 7a54927b03 IRGen: Fix MemoryLayout::offset(of:) for tail allocated C arrays
There is no storage but an offset.

rdar://51194713
2019-10-15 14:04:31 -07:00
Brent Royal-Gordon 66f914d20f Make keypath literal in closure only once 2019-08-06 07:52:56 -07:00
Brent Royal-Gordon 2a885a0863 Add runtime tests for key path literal closures 2019-08-06 07:52:56 -07:00
technicated b37c2d5cf2 Fixed some tests
The IRGen test had wrong offsets for inline String element on tuples kp on 32-bit platforms
The stdlib test had hardcoded offsets (assumed 64-bit host) for tuple kp elements (Memorylayout)
2019-02-20 21:46:22 +01:00
technicated d474d766e2 Added stdlib/KeyPath test
Execution tests involving generic and non-generic tuples
2019-02-18 10:22:17 +01:00
technicated 1577afee80 Added more tests (related to generic tuples) 2019-02-18 10:19:43 +01:00
technicated d7324b977e Added more tests
Testing SILGen & IRGen tuple keypath generation
Added tuple element type check in SILVerifier
2019-02-18 10:19:42 +01:00
Karoy Lorentey 666a22feff [test] Modernize hashing throughout the test suite 2018-11-29 17:38:29 +00:00
Doug Gregor d4fe6e9ff7 [Runtime] Fix a bug in handling multi-level generic environment substitutions. 2018-11-16 10:39:19 -08:00
Joe Groff 93b5de61e7 Implement the final approved syntax for SE-227 identity key paths.
`\.self` is the final chosen syntax. Implement support for this syntax, and remove the stopgap builtin and `WritableKeyPath._identity` property that were in place before.
2018-09-19 11:45:13 -07:00
Joe Groff 44b55ae197 Runtime support for identity key paths.
Make sure the implementation can handle a key path with zero components by removing inappropriate assumptions that the number of components is always non-empty. Identity key paths also need some special behavior:

- Appending an identity key path should be an identity operation for the other operand
- Identity key paths have a `MemoryLayout.offset(of:)` zero
- Identity key paths interop with KVC as key paths to `@"self"`

To be able to exercise and test this behavior, add a `Builtin.identityKeyPath()` function and `WritableKeyPath._identity` accessor in lieu of finalized syntax.
2018-08-20 14:00:46 -07:00
Joe Groff 70c60e5186 KeyPaths: Make references to let properties properly immutable. 2018-08-17 10:59:36 -07:00
Arnold Schwaighofer 2d8a1dbbfe Codesign test/stdlib 2018-08-10 06:58:40 -07:00
Joe Groff f01c731a6b KeyPaths: Fix alignment skew issue when key path pattern ends with a less-than-pointer-aligned element. 2018-07-27 13:15:49 -07:00
Joe Groff ae4d40ac85 SILGen: Fix key paths that reference internal private(set) decls from other files.
The setter needs to be given hidden linkage so that other files can still form key paths to it.
2018-07-25 10:49:29 -07:00
Joe Groff a6a792c740 Add a MemoryLayout<T>.offset(of:) method for getting the offset of inline storage.
If a key path refers to inline storage of the root type, this produces the offset in bytes between a pointer to the root and a pointer to the projected storage. Otherwise, returns nil.
2018-03-26 12:22:41 -07:00
Joe Groff 993d795152 KeyPath: Fix out-of-bounds access when instantiating keypaths with optional chaining components.
When we pre-scan the components of a key path pattern to determine its runtime type and instance size, we would short-circuit upon seeing an optional-chaining component, since that makes a key path definitely read-only, but the loop also accumulates the size of the instance we're supposed to allocate, so…bad stuff happened. Leave out the short-circuit, fixing SR-6096 | rdar://problem/34889333 .
2017-11-02 13:32:35 -07:00
Joe Groff 2ba8f57514 Remove staging flag for unimplemented key path components.
All the originally-planned component kinds are now implemented.
2017-09-15 11:55:35 -07:00
Joe Groff b7566dacdb IRGen: Lowering for key paths with indices. 2017-09-15 10:24:28 -07:00
Joe Groff 78d75428d6 SILGen: Lower key path subscript indexes.
And fill out SIL support for parsing, printing, and serializing key path
patterns with captured indexes.
2017-09-15 10:00:32 -07:00
Joe Groff 69a290edda Handle IUO unwraps in key paths.
In the type checker, we need to recognize when a member lookup succeeded through an IUO unwrap, and insert the implicit optional-unwrap component into the key path. In the standard library, we need to cope with the fact that IUO is still a first-class type with unique type metadata in a few places. Fix for rdar://problem/33230845.
2017-07-17 11:21:36 -07:00
Joe Groff 34ec20c0e4 KeyPaths: Ensure mutation accesses are ended in the correct order.
Using an Array to hold onto all the cleanup objects for an access happens to destroy the cleanup objects in FIFO order (and it's probably not a good idea to rely on Array cleaning itself up in any particular order at all). For want of proper accessor coroutines, chain the cleanup objects in a linked list so that they reliably get destroyed in the desired inside-out order. Fixes SR-5442 | rdar://problem/33267959.
2017-07-12 14:41:34 -07:00
Joe Groff eb1231b722 SILGen: Do a read-only projection of a writable KeyPath when the lvalue is only read.
If we project an lvalue using a KeyPath, but the lvalue is only read from, we don't want to trigger writebacks, observers, or other side effects that a mutable projection would normally need to induce. Fixes SR-5338 | rdar://problem/33135489.
2017-07-11 15:47:59 -07:00
Joe Groff 101788dbd4 IRGen: Support for computed properties with dependent generic context.
Use the KeyPath implementation's new support for instantiating and dealing with captures to lower the generic context required to dispatch computed accessors with dependent generics.
2017-07-06 20:07:41 -07:00
Joe Groff c142e7d953 KeyPaths: Support captured arguments in computed components.
A necessary precursor to supporting subscripts and unspecialized generic accessors in general. Give get/set components the ability to have an "argument" area that gets instantiated by copying out of the key path pattern arguments at instantiation time, and which holds "witness" information for how to copy, destroy, equate, and hash arguments.
2017-07-06 20:07:41 -07:00
Joe Groff 3c82e981f9 KeyPaths: Add support for optional chaining/forcing components.
rdar://problem/31768715
2017-06-26 09:40:31 -07:00
Robert Widmann 71bf312a25 Migrate the rest of the tests to %empty-directory 2017-06-04 11:08:39 -07:00
Joe Groff 4fc0b7df96 SILGen: Handle existential keypath root types.
SR-4917|rdar://problem/32254554
2017-05-31 16:01:02 -07:00
Joe Groff cdc7a5c945 Support application of AnyKeyPath/PartialKeyPath.
rdar://problem/32237567
2017-05-25 15:51:22 -07:00
Joe Groff faa6bc72f0 Sema: Reject unimplemented key path components during resolveKeyPathExpr.
This is a bit more robust and user-friendly than hoping more brittle recovery in SILGen or IRGen for unsupported components kicks in. rdar://problem/32200714
2017-05-15 16:10:59 -07:00