Commit Graph

3245 Commits

Author SHA1 Message Date
Guillaume Lessard
a2df540cfa Merge pull request #71369 from oscbyspro/main
BinaryInteger advanced(by:) fixes
2024-02-05 14:42:38 -08:00
Holly Borla
93b68cd9df Merge pull request #71365 from hborla/lazy-trc-extension 2024-02-05 08:06:45 -08:00
Oscar Byström Ericsson
306eaefb5b Apply suggestions from code review
- Changed 128 integer literal to Int(Int8.max)+1 in unit tests (Int8.Stride is Int).

Co-authored-by: Guillaume Lessard <glessard@users.noreply.github.com>
2024-02-04 08:27:27 +01:00
Oscar Byström Ericsson
17187e38f5 This patch fixes two unnecessary traps in BinaryInteger's advanced(to:) method.
- `Int8.min.advanced(by: 128)`, etc.
- `UInt.max.advanced(by: Int.min)`, etc.
2024-02-03 13:56:33 +01:00
Holly Borla
48eb4b7714 [Availability] Lazily expand type refinement contexts for extensions. 2024-02-02 17:34:40 -08:00
Guillaume Lessard
0ec6397053 Merge pull request #71224 from glessard/rdar121395821
[stdlib] Improve documentation for the various "String from C-string" initializers
2024-02-02 12:17:50 -08:00
Guillaume Lessard
114f235d17 Merge pull request #71167 from vanvoorden/vanvoorden/inclusive-language
[Inclusive Language][Comments][Documentation] migrate "sanity" checks to "soundness" checks
2024-02-02 10:27:34 -08:00
Guillaume Lessard
8ed59d1d2e [test] fix diagnostics tests for String-from-C-string inits 2024-02-01 15:34:18 -08:00
Philippe Hausler
ed23973e89 [Observation] Add generation for _modify to fields such that we avoid extra CoW (#71122) 2024-01-25 22:51:38 -08:00
Rick van Voorden
f8ae46b3f3 [inclusive-language] changed sanity to soundness 2024-01-25 18:18:02 -08:00
Allan Shortlidge
7449365cab Tests: Update tagged string tests in stdlib/BridgeStorage.swift.
The Swift compiler no longer supports any deployment targets that don't have
tagged NSStrings.

Resolves rdar://121343971
2024-01-24 16:50:31 -08:00
Allan Shortlidge
1e9a2bc4c9 Tests: Update stdlib/RuntimeObjC.swift to always link libswiftCoreGraphics.
The core definitions of CGPoint and other types were pushed down from
CoreGraphics to CoreFoundation. This test indirectly depends on the conformance
of those types to CustomReflectable, but nothing in the test was using those
conformances explicitly and so libswiftCoreGraphics would not be auto-linked
when the test is compiled at a high enough deployment target. Use the
conformances directly to force linkage.

Resolves rdar://121343931
2024-01-23 16:59:13 -08:00
Guillaume Lessard
50b83c8e69 Merge pull request #68423 from glessard/se0405-take2
[se-0405] rename `String.init(validatingUTF8:)`
2024-01-22 09:29:21 -08:00
Guillaume Lessard
d8c809c0ad Merge pull request #68419 from glessard/se0405-part1
[se-0405] Implement API additions
2024-01-22 09:27:27 -08:00
Slava Pestov
2246dd13e1 Merge pull request #70951 from slavapestov/sendable-type-and-more
Fix @retroactive for conditional conformances, and more
2024-01-17 18:28:45 -05:00
Slava Pestov
09087ccce8 Sema: Diagnose retroactive conditional conformances
Passing in the declared interface type to checkConformance() here
masked a silent failure where if the type declaration was generic
and the conformance conditional, the conditional requirement check
would fail. As a result, we did not diagnose the absence of
@retroactive, nor the unnecessary presence of it.

Since we only care about the existence of some conformance, we
can use lookupConformance() instead.
2024-01-17 13:08:46 -05:00
Alejandro Alonso
f0a74ecb0d Apply suggestions from code review
Co-authored-by: Guillaume Lessard <glessard@users.noreply.github.com>

fix test
2024-01-16 17:14:18 -08:00
Alejandro Alonso
fbe82822e5 Take test suggestion from Karoy
Co-authored-by: Karoy Lorentey <klorentey@apple.com>
2024-01-16 15:57:01 -08:00
Alejandro Alonso
c384b1cfc5 Avoid materializing strong references in potential dangling unmanaged opaque functions
Add test and comments
2024-01-16 15:17:49 -08:00
Guillaume Lessard
e773d9a093 Merge pull request #70911 from stephentyrone/check-alignment-not-stride 2024-01-15 11:56:03 -08:00
Stephen Canon
b8f599487f Fixup alignment on a few other allocations in the URBP tests.
Also get 80c formatting on these calls.
2024-01-15 12:13:39 -05:00
Guillaume Lessard
67d41accb5 [test] fix a memory allocation’s alignment
it seems this would have failed on 32bit with strict alignment enforcement
2024-01-15 02:23:18 -08:00
Doug Gregor
0e6a913f98 Merge pull request #70907 from DougGregor/se-0413-result-typed-throws
[SE-0413] Adopt typed throws in Result
2024-01-13 13:21:05 -08:00
Doug Gregor
7d74b3ba5c [SE-0413] Adopt typed throws in Result
Make `init(catching:)` and `get()` use typed throws. The former infers
the `Failure` type from the closure provided (once full type inference
is in place) and the latter only throws errors of the `Failure` type.
2024-01-13 06:45:08 -08:00
Mike Ash
5609103172 [Test] Add _ZNSsC2EPKcRKSaIcE to symbol-visibility-linux.test-sh
This corresponds to:

std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)

rdar://120908750
2024-01-12 14:05:00 -05:00
Alejandro Alonso
4027b954fb Remove some assertions in test 2024-01-11 09:41:21 -08:00
Guillaume Lessard
fa9c80ae08 [test] round out testing for String.init?(validating:as:) 2024-01-10 14:32:26 -08:00
Meghana Gupta
5d2454f3e3 Merge pull request #68180 from meg-gupta/lowerb4inline
Lower OwnershipModelEliminator to just before inlining
2024-01-10 13:53:34 -08:00
Alejandro Alonso
e37ecac163 Merge pull request #68857 from Azoy/atomics
[stdlib] Atomics
2024-01-10 12:03:08 -08:00
Alejandro Alonso
7756728a70 Add synchronization test feature 2024-01-09 09:53:19 -08:00
Meghana Gupta
58a19e94eb Update tests 2024-01-05 13:20:52 -08:00
Alejandro Alonso
d8604601d7 Rename AtomicValue to AtomicRepresentable 2024-01-03 13:27:47 -05:00
Alejandro Alonso
b68e864b5f Try to appease CI
more test fixes
2024-01-03 13:01:24 -05:00
Guillaume Lessard
566fbf4fec [se-0405] update availability to a realistic release target 2023-12-21 10:44:52 -08:00
Guillaume Lessard
7648210129 [test] se-0405 input-validating String initializers 2023-12-21 10:44:52 -08:00
Holly Borla
8c9eeb2edd [ASTScope] In the isBeforeInSource predicate, use the end location of the
original source location of a macro expansion when walking up the ancestor
list.

The original source range of a macro expansion buffer contains the entire
range of the code that is replaced by the expansion. In some cases, the
original code is type checked, so ASTScope needs to represent both the
original code and the macro-expanded code in the scope tree.

For accessor macros, the original code -- the initializer expression of
the property -- is type checked, but not before macro expansion, so
unqualified lookup must deal with the scope tree for the initializer and
the expanded accessors. The accessors are inserted in the tree after the
initializer scope, but the `isBeforeInSource` was using the start location
of the original source range for macro expansions, so the accessor scopes
were incorrectly considered to be ordered before a source location in the
initializer expression, which caused unqualified lookup of local variables
within the initializer to fail.
2023-12-20 15:53:02 -08:00
Alejandro Alonso
c101e19800 Switch to top level storage types 2023-12-18 14:01:16 -05:00
Alejandro Alonso
5343ebade2 Make tests import new Synchronization module 2023-12-18 14:01:16 -05:00
Alejandro Alonso
87974a83af Some documentation work, some work from review, add tests 2023-12-18 14:01:16 -05:00
Allan Shortlidge
2730c19891 Macros: Stop explicitly enabling accepted ExtensionMacros feature in tests.
NFC.
2023-12-10 10:10:15 -08:00
Mike Ash
1770b3d3d7 [Test] Disable some runtime tests in back deployment testing.
These tests are testing changes that aren't present in older runtimes:

test/stdlib/SwiftValueNSObject.swift
test/stdlib/SwiftObjectNSObject.swift
test/stdlib/BridgeEquatableToObjC.swift

And this test looks for some wording that's different on older runtimes. This one already does availability checks, so we change the requirements to SwiftStdlib 5.11:

test/Casting/CastTraps.swift.gyb
2023-12-07 12:59:09 -05:00
Stephen Canon
d66f233839 Add concrete overload for != on all stdlib integer types. (#70043)
* Add concrete overload for  on all stdlib integer types.

* Add very basic tests for type inference of comparands.

* Add a comment explaining why these overloads are present.
2023-12-06 16:40:16 -05:00
Slava Pestov
d579a76581 Sema: Break request cycle when building TypeRefinementContexts
This fixes a recent regression introduced in the changes to make
TRC construction lazier in b33a71d64f.

Calling VarDecl::hasInitialValue() can ask for attached property
wrappers, which can trigger macro expansion. However, macro
expansion can result in TRC construction, causing a cycle.

Instead, just always build a lazy TRC for the initializer. It
might not be needed, but it's safest to not ask anything of the
VarDecl at all.

Fixes rdar://118452948.
2023-12-01 22:49:20 -05:00
Tim Kientzle
4e821f65ec Merge pull request #69464 from tbkka/tbkka-objc-equatable-hashable
Use Swift Equatable and Hashable conformances from ObjC
2023-11-10 13:46:19 -08:00
Tim Kientzle
7a920cdcbf Merge pull request #69618 from tbkka/tbkka-SwiftValue-equatable-redux
Make SwiftValue hash/equality work the same as SwiftObject

For Equatable types that are not Hashable, this proxies ObjC `-isEqual:` to Swift `Equatable` and returns a constant for ObjC `-hash`
2023-11-07 13:03:13 -08:00
Kuba (Brecka) Mracek
b8b34b3a21 Merge pull request #69673 from kubamracek/reenable-lifetimemanagement-test
Re-enable test/stdlib/LifetimeManagement.swift
2023-11-07 12:06:27 -08:00
Yuta Saito
79b3d2d626 Add underscore prefix to extern attribute
It's already guarded by a feature flag, but it would be nice to signal
users that it's not stable yet by adding an underscore prefix.
2023-11-07 02:01:02 +00:00
Kuba Mracek
d4a3c404a2 Re-enable test/stdlib/LifetimeManagement.swift 2023-11-06 09:02:45 -08:00
Tim Kientzle
5ba38e8527 Comment out a known-broken test case
This entire suite was copied wholesale from SwiftObjectNSObject.
Some of it may not apply, very little of it has been critically
evaluated.  But it should help avoid unexpected changes in SwiftValue behavior.
2023-11-03 17:06:49 -07:00
Tim Kientzle
2cbd70e531 Make SwiftValue hash/equality work the same as SwiftObject
Update PR #68720 with lessons learned in reviewing #69464

Background:

* SwiftValue can expose Swift value types (structs/enums)
  to ObjC by wrapping them in an Obj-C object on the heap

* SwiftObject is the Obj-C type that Swift class objects all
  inherit from (when viewed from Obj-C).  This allows arbitrary
  Swift class objects to be passed into Obj-C.

History:

* PR #4124 made Obj-C `-hash` and `-isEqual:` work for SwiftValue for Hashable Swift types

* PR #68720 extended SwiftValue to also support Equatable Swift types

* PR #69464 added similar support to SwiftObject

In the process of working through #69464, we found a better way
to handle an ObjC request for `-hash` for a type that is Swift
Equatable but not Hashable.  This PR updates SwiftValue to use
the same approach.  The approach considers three cases:

1. A Hashable type can forward both `-hash` and `-isEqual:` to
   the Swift object.

2. A type that is neither Equatable nor Hashable can implement
   `-isEqual:` as the identity check and `-hash` as returning
   the address of the object in memory.

3. A type is that Equatable but not Hashable is more complex.

In this last case, we can easily forward `-isEqual:` to the
Equatable conformance but ObjC also requires us to
always provide a compatible `-hash` implementation.
The only way to do this is to have `-hash` return a constant,
but that is a very bad idea in general, so we're also including
a log message whenever we see a request for `-hash` on
a Swift value that is Equatable but not Hashable.
To limit performance problems from the logging itself, we
emit the log message only once for each type.
2023-11-02 11:24:04 -07:00