Commit Graph

30 Commits

Author SHA1 Message Date
Ramon Asuncion
496fb661cd [Test][stdlib] Remove cat command for lit compatibility 2025-10-16 09:01:27 -07:00
Ramon Asuncion
343b86a228 [Test][stdlib] Use /dev/stderr for lit compatibility 2025-10-15 13:27:43 -07:00
Mike Ash
c928203780 [Runtime] Handle nil parameter to -[SwiftObject isEqual:]
The parameter is nullable, and isEqual: should always return nil in that case. We need to check for nil before doing anything else.

rdar://136825667
2024-10-01 14:05:39 -04:00
Tim Kientzle
48eb993349 Verify that hash/equality behavior is all consistent
It's not obvious that we can check that hash/equality behavior
is entirely correct, since there are two very different behaviors
which depend on environmental factors that are not easy to test for.

But we can do a quick probe to see whether the current environment
seems to be offering the legacy or non-legacy behavior and then
carefully verify that everything else is consistent with our initial
probe.

This gives us confidence that at least we're not getting inconsistent
behavior.
2024-07-09 13:30:13 -07:00
Artem Chikin
1f14158a1d Introduce VisionOS Platform
This change introduces a new compilation target platform to the Swift compiler - visionOS.

- Changes to the compiler build infrastrucuture to support building compiler-adjacent artifacts and test suites for the new target.
- Addition of the new platform kind definition.
- Support for the new platform in language constructs such as compile-time availability annotations or runtime OS version queries.
- Utilities to read out Darwin platform SDK info containing platform mapping data.
- Utilities to support re-mapping availability annotations from iOS to visionOS (e.g. 'updateIntroducedPlatformForFallback', 'updateDeprecatedPlatformForFallback', 'updateObsoletedPlatformForFallback').
- Additional tests exercising platform-specific availability handling and availability re-mapping fallback code-path.
- Changes to existing test suite to accomodate the new platform.
2024-04-10 09:38:02 -07:00
Tim Kientzle
eece2b024b Fix test build 2024-02-28 10:41:51 -08:00
Tim Kientzle
804800447d Document the test hacks more clearly 2024-02-27 17:46:49 -08:00
Tim Kientzle
fac88221c5 Fix hash/isEqual interop conditionals, update tests
Github PR #71620 mixed up one of the bincompat conditionals.
It also had some errors in the tests for ObjC interop.

For now, this leaves the legacy behavior in place for
all Apple platforms.
2024-02-27 17:46:49 -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
Tim Kientzle
33888255f3 Log a message when Obj-C -hash is invoked for a Swift object that is Equatable but not Hashable
This is worth telling people about:

Since we're being asked for the hash value, that probably means someone is
trying to put this object into some form of set or dictionary.  But we don't know
anything about the Equatable implementation, so the only valid hash value we can
possibly return is a constant.  And hash table implementations typically degrade
into unsorted lists when provided constant hash values.

Note: In order to avoid hammering the logs, we only emit the
warning once for each class that hits this path.
2023-11-01 14:19:12 -07:00
Tim Kientzle
716b58e956 Handle ObjC -hash differently for Equatable and non-Equatable types
For an Equatable type, we need a hash implementation that
is compatible with any possible definition of `==`.
Conservatively, that means `-hash` must return a constant.

For non-Equatable types, we know that `==` is identity based,
so we can get better hash behavior by using the object address.

Caveat:  This means that non-Equatable types will do two
protocol conformance checks on every call to `hash`.
2023-10-31 14:26:20 -07:00
Tim Kientzle
6fd39741d6 Fix a number of issues (review feedback)
* Fix how we were looking for common parent class
* Use a constant hashValue for types that are Equatable but not Hashable
2023-10-30 15:57:47 -07:00
Tim Kientzle
a840c69392 Use Swift Equatable and Hashable conformances from ObjC
If a Swift type implements Equatable and/or Hashable and
we then pass that object into ObjC, we want ObjC
`isEqual:` and `hashValue` to use that.  This allows
ObjC code to build ObjC collections of Swift objects.

* Support for Hashable struct/enum types was implemented in #4124
* Support for Equatable struct/enum types was implemented in #68720
* This implements support for Hashable and Equatable _class_ types

Caveats:
1. This does a lot of dynamic lookup work for each operation, so is
   inherently rather slow.  Unlike the struct/enum case, there is no convenient
   place to cache the conformance information, so it's not clear that there is a
   viable way to make it significantly faster.
2. This is a behavioral change to low-level support code.  There is a
   risk of breaking code that may be relying on the old behavior.
2023-10-27 12:01:44 -07:00
Mishal Shah
d5c40bf231 Revert "Disable objc_mangling.swift and SwiftObjectNSObject.swift test on tvOS"
This reverts commit 7e2c2452ad.
2020-05-28 14:10:40 -07:00
Mishal Shah
7e2c2452ad Disable objc_mangling.swift and SwiftObjectNSObject.swift test on tvOS 2019-12-12 08:32:16 -08:00
Mike Ash
7d4bf753f4 [Test] Don't test demangling of SwiftObject's name, as it's subject to change.
rdar://problem/57163094
2019-11-15 12:56:24 -05:00
Mishal Shah
c2c8cf5903 Disable objc_mangling and SwiftObjectNSObject test for watchOS (56959761) 2019-11-06 16:43:54 -08:00
Mike Ash
47766ab6bc [Stdlib] Make SwiftObjectNSObject actually pass on older OSes where the real test is disabled.
It helps to print the fake messages where FileCheck will actually be looking for them.

rdar://problem/48421324
2019-02-27 13:55:50 -05:00
Mike Ash
4abec981c0 [Stdlib] Disable SwiftObjectNSObject test on iOS <10 and macOS <10.12 until we can figure out why it's failing there.
rdar://problem/47870743
2019-02-25 12:28:11 -05:00
Jordan Rose
b475568f29 [test] Separate stdout and stderr in SwiftObjectNSObject.swift
remote-run doesn't always preserve the interleaving, but we don't need
stdout at all given what's being checked; it's just used to show how
far the test got before failing. The output being FileChecked is going
through NSLog, which uses stderr.

Part of rdar://problem/44866579
2018-09-30 20:17:17 -07:00
Arnold Schwaighofer
2d8a1dbbfe Codesign test/stdlib 2018-08-10 06:58:40 -07:00
Greg Parker
072e9827aa Use SwiftObject's old name when building for the pre-stable ABI.
rdar://35554345
2018-03-26 14:04:30 -07:00
Greg Parker
9637b4a6e1 [runtime] Rename class SwiftObject to Swift._SwiftObject. (#13748)
SwiftObject needs to be renamed to avoid ObjC class name collisions between
the Swift stable ABI and older Swift apps.

rdar://35554345
2018-01-09 16:16:55 -08:00
Bob Wilson
65f1324393 Update a test so that it is not broken by function merging.
Something has changed with newer versions of LLVM so that the
stdlib/SwiftObjectNSObject.swift test fails on the master-next branch
because the @objc thunk functions all get merged together. That is a good
thing for code size but it breaks some of the checks in this test that
compare the function pointers to verify that overrides are correct.
Make each function different so they cannot be merged.
2017-11-18 17:17:28 -08:00
Greg Parker
0bae31c1f0 [runtime] Add some missing -isNSWhatever__ methods to SwiftObject. (#11891)
SR-5636, rdar://33764085
2017-09-13 03:01:37 -07:00
Greg Parker
f3bd55eb52 [runtime] Implement SwiftObject -methodForSelector: and +instanceMethodForSelector:.
Fixes SR-5577 and rdar://33606034.
2017-08-23 17:11:47 -07:00
Dmitri Gribenko
486cab447d tests: replace 'rm -rf %t && mkdir -p %t' with '%empty-directory(%t)'
These changes were made using a script.
2017-06-04 11:08:39 -07:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
practicalswift
797b80765f [gardening] Use the correct base URL (https://swift.org) in references to the Swift website
Remove all references to the old non-TLS enabled base URL (http://swift.org)
2016-11-20 17:36:03 +01:00
Max Moiseev
9fc37efee4 [test] renaming test/1_stdlib to just test/stdlib 2016-09-01 16:51:43 -07:00