Commit Graph

2342 Commits

Author SHA1 Message Date
Owen Voorhees
aaac0396f2 Delete obselete UndoManager test which inadvertently triggered driver error 2020-02-05 12:26:40 -08:00
Butta
3f4109b3a2 [android] Get build scripts working natively, fix tests and install
The build scripts assume Android cross-compilation using the NDK, so avoid
that configuration if building on an Android host. Fix or disable some tests,
and don't install a glibc.modulemap without a native sysroot prefix.
2020-02-05 11:36:33 +05:30
Kelvin
19a8759cee Merge branch 'master' into comparable-enums 2020-02-04 22:08:40 -06:00
Ravi Kandhadai
353f396ab6 Merge pull request #29630 from ravikandhadai/oslog-minor-changes
[stdlib/private][os log] Minor changes to the new os log overlay
2020-02-04 13:12:44 -08:00
Suyash Srijan
543d649278 [Diagnostics] Warn when the result of a Void-returning function is ignored (by assigning into '_') (#29576) 2020-02-04 20:19:37 +00:00
Ravi Kandhadai
e631c66e0d [stdlib/private][os log] Annotate tiny helper functions in the new
os log overlay @_transparent so that they will be inlined in their
callers even annotated as @_optimize(none).

Make the OSLogPrototypeCompileTest.swift test suite check only the
output of the OSLogOptimization pass instead of the output of the
Onone pipeline. This will make the tes more resilient to adding
mandatory optimizations later in the pass pipeline. Also, remove
a duplicate test from the OSLogPrototypeExecTest suite.
2020-02-04 11:03:38 -08:00
Karoy Lorentey
b7eb2fced0 [test] Substring: remove unnecessary expected arguments
The previous commit made these redundant.
2020-01-24 16:41:47 -08:00
Karoy Lorentey
147087ca43 [test] Adjust new Substring test
We don’t have an easy way to check for the runtime version of the stdlib, so a two-way check for behavioral changes isn’t feasible. (Checking for the OS version isn’t good enough.)

Only check for the new behavior, and only when we know for sure that it’s available.
2020-01-24 16:40:44 -08:00
kelvin13
fb4bd68653 Merge branch 'master' into comparable-enums 2020-01-22 18:38:31 -06:00
Michael Ilseman
38de918213 Merge pull request #29146 from Lukasa/cb-substring-fast-access-2
[stdlib] Re-add withContiguousStorageIfAvailable to SubString.UTF8View
2020-01-22 10:36:58 -08:00
Erik Eckstein
1a0cbbf23b tests: only run a Casts.swift test with a newer runtime
... because this test is for a fix in the runtime which will fail if run with an old runtime.
2020-01-18 16:11:54 +01:00
eeckstein
3fd9098f67 Merge pull request #29274 from eeckstein/disable-slow-tests
tests: exclude some very long running tests from jobs with a non-optimized stdlib
2020-01-18 14:59:33 +01:00
tbkka
b8c090d9c6 [SR-3871] Unwrap multiple layers of Any/AnyObject when casting to protocol type (#28835)
SR-3871: Dynamic casting of existentials stored in Obj-C references

Arbitrary Swift objects get packaged into __SwiftValue containers so
that pointers to them can be passed into Obj-C.  (Obviously, Obj-C
code can't do anything particularly useful with such pointers other
than refcount them and give them back to Swift code.)  Those values come
back into Swift as either `Any` (existential box) or `AnyObject`
(anonymous object pointer) values.  Dynamically casting those requires
first inspecting the outer value to get access to the actual type and
value in the __SwiftValue container.

The tryDynamicCastBoxedSwiftValue() function that handles this
was missing a check for the `Any` case, which is why directly
casting from `Any` would routinely fail.

Resolves SR-3871
2020-01-17 12:41:44 -08:00
Erik Eckstein
79fb67f5df tests: exclude some very long running tests from jobs with a non-optimized stdlib
Those are tests which take > 1000s on some simulator configurations with a non-optimized stdlib.
We run those tests anyway with an optimized stdlib. So we don’t lose test coverage by disabling them for debug-stdlib.

This fixes some sporadic time outs on the CI jobs.
2020-01-17 16:51:02 +01:00
Suyash Srijan
c02b95ebf9 [Runtime] A Swift Error bridged to NSError should return its description, rather than NSError.description (#29224) 2020-01-16 00:13:55 +00:00
Cory Benfield
c6dfea6fc4 [stdlib] Re-add withContiguousStorageIfAvailable to SubString.UTF8View
This is a second pass at the original patch, which broke an OS test.

Due to an oversight it seems that we never added a
withContigousStorageIfAvailable implementation to SubString.UTF8View,
which meant that if you sliced a String you lost the ability to get fast
access to the backing storage. There's no good reason for this
functionality to be missing, so this patch adds it in by delegating to
the Slice implementation.

Resolves SR-11999.
2020-01-14 14:01:06 +00:00
swift-ci
22bfebea70 Merge pull request #29138 from lorentey/accelerate-fix-availability-of-utils 2020-01-10 19:02:11 -08:00
Karoy Lorentey
1a275a45c4 [test] Accelerate: Don’t hide utility functions in an if #available block 2020-01-10 16:56:33 -08:00
Michael Ilseman
70e6db81f1 Revert "[stdlib] Add withContiguousStorageIfAvailable to SubString.UTF8View" 2020-01-10 13:28:03 -08:00
Michael Ilseman
6209c97bf7 Merge pull request #29094 from Lukasa/cb-substring-fast-access
[stdlib] Add withContiguousStorageIfAvailable to SubString.UTF8View
2020-01-10 11:16:46 -08:00
Cory Benfield
68f0816daa [stdlib] Add withContiguousStorageIfAvailable to SubString.UTF8View
Due to an oversight it seems that we never added a
withContigousStorageIfAvailable implementation to SubString.UTF8View,
which meant that if you sliced a String you lost the ability to get fast
access to the backing storage. There's no good reason for this
functionality to be missing, so this patch adds it in by delegating to
the Slice implementation.

Resolves SR-11999.
2020-01-10 09:10:09 +00:00
Erik Eckstein
66852e2bb7 tests: fix Array test
The Array/removeNonUnique test is not working with an old runtime.

rdar://problem/58471030
2020-01-10 09:50:34 +01:00
Erik Eckstein
88a9ebb9f8 stdlib: Don't request additional capacity in Array/ContiguousArray's remove.
Just copy the buffer if it's not unique.
This also implies that if there is a copy-on-write in remove, "shrink" the capacity of the new buffer to the required amount of elements (instead of copying the capacity of the original buffer).
2020-01-09 16:17:38 +01:00
kelvin13
ed2552a694 fix merge conflict and update caseless stdlib enums to use synthesized Comparable 2020-01-02 18:40:50 -06:00
Karoy Lorentey
1a9f7afdec [Foundation] Fix Data.count’s setter
Data provides a settable `count` property. Its expected behavior is undocumented, but based on the implementation, it is intended to zero-extend (or truncate) the collection to the specified length.

This does not work correctly if we start with an empty Data and we try to increase the count by a small integer:

```
import Foundation

var d = Data()
d.count = 2
print(d.count) // ⟹ 0 ⁉️

d.count = 100
print(d.count) // ⟹ 100 ✓
```

It looks like this bug was introduced with the Data overhaul that shipped in Swift 5.

(This issue was uncovered by https://github.com/apple/swift/pull/28918.)

rdar://58134026
2019-12-20 23:35:05 -08:00
David Smith
6936d0dc60 Merge pull request #28863 from Catfish-Man/ducking-types-test
Add a test for incorrectly constructing a Set from an NSArray
2019-12-18 17:24:39 -08:00
David Smith
0ce856b06c Add a test for incorrectly constructing a Set from an NSArray 2019-12-18 15:06:22 -08:00
tbkka
fdb1926421 [SR-5289] Teach Mirror how to handle unowned/unmanaged references (#28823)
SR-5289: Teach Mirror how to inspect weak, unowned, and unmanaged refs

Correctly reflect weak, unowned, and unmanaged references
to both Swift and Obj-C types (including existential references to
such types) that occur in both Swift class objects and in Swift
structs.

This includes the specific reported case (unowned reference to an
Obj-C object) and several related ones.

Related changes in this PR:

* Tweak internal bitmap used for tracking ownership modifiers
  to reject unsupported combinations.

* Move FieldType into ReflectionMirror.mm
  FieldType is really just an internal implementation detail
	of this one source file, so it does not belong in an ABI header.

* Use TypeReferenceOwnership directly to track field ownership
  This avoids bitwise copying of properties and localizes some
	of the knowledge about reference ownership

* Generate a top-level "copyFieldContents" from ReferenceStorage.def
  Adding new ownership types to ReferenceStorage.def will now
	automatically produce calls to `copy*FieldContents` - failure
	to provide a suitable implementation will fail the build.

* Add `deallocateBoxForExistentialIn` to match `allocateBoxForExistentialIn`

Caveat:  The unit tests are not as strict as I'd like.  Attempting to make them
so ran afoul of otherwise-unrelated bugs in dynamic casting.
2019-12-17 09:42:52 -08:00
Doug Gregor
23cc0790a7 [Dynamic casting] Fix overrelease on unsuccessful cast to an Error type.
Fixes SR-9207 / rdar://problem/45961622, SR-10478 / rdar://problem/49906841,
and rdar://problem/50665156.
2019-12-16 08:46:33 -08:00
Doug Gregor
169dbcdc17 Revert "Disable a test to unblock CI"
This reverts commit 29a6d1066e.
2019-12-13 23:55:13 -08:00
Doug Gregor
905c830c45 [Runtime] Handle Error bridging as a last chance to cast to NSError/NSObject.
Rather than attempting Error bridging early when trying to dynamically
cast to NSError or NSObject, treat it as the *last* thing we do when
all else fails. Push most of this code over into Objective-C-specific
handling rather than #ifdef'd into the main casting logic to make that
slightly more clear.

One oddity of Error/NSError bridging is that a class that conforms to
Error can be dynamically cast to NSObject via Error bridging. This has
always been known to the static compiler, but the runtime itself was
not always handling such a cast uniformly. Do so now,
uniformly. However, this forced us to weaken an assertion, because
casting a class type to NSError or NSObject can produce an object with
a different identity.

Fixes rdar://problem/57393991.
2019-12-13 23:55:13 -08:00
Doug Gregor
8261d6f57e [Test] Go through the runtime for the "as? NSObject" check.
This prevents runtime differences on as? from affecting this test.
2019-12-13 23:55:13 -08:00
Doug Gregor
5ed0641c59 [Runtime] Handle Error-conforming-to-NSObject casting fully.
I missed a case where an Error-conforming class is dynamically casted
to NSObject (via NSError). Fix it.
2019-12-13 23:55:13 -08:00
Mishal Shah
f5b9ed6d50 Merge pull request #28755 from lorentey/OptionSet-remove-back-deployment
[test] OptionSetTest: fix elementary logic error
2019-12-12 17:38:35 -08:00
Karoy Lorentey
0f5b9836b0 [test] OptionSetTest: fix elementary logic error 2019-12-12 12:43:38 -08:00
tbkka
cc8f8e929c SR-7732: Dynamic casting CFError to Error results in a memory leak (#28686)
* SR-7732: Dynamic casting CFError to Error results in a memory leak

The special handling for casting CFError/NSError to Swift Error
type was using cleanup code that didn't correctly handle this case.
This replaces the cleanup code with a more targeted version.

Fixes: SR-7732
Fixes: rdar://problem/40423061

* Whitespace fixes

* Don't rely on localizable strings to verify test behavior.

I've verified this simplified test still leaks with
the original code and does not leak with the fixed code.

* Don't test against old runtimes that predate this fix

* Explicitly test both NSError and CFError
2019-12-12 12:30:21 -08:00
Mishal Shah
7e2c2452ad Disable objc_mangling.swift and SwiftObjectNSObject.swift test on tvOS 2019-12-12 08:32:16 -08:00
swift-ci
b6f778ddf5 Merge pull request #28720 from lorentey/OptionSet-remove-back-deployment 2019-12-11 17:22:16 -08:00
Karoy Lorentey
b31f43c0e3 [test] Modernize test/stdlib/OptionSetTest.swift 2019-12-11 15:03:23 -08:00
Karoy Lorentey
05081eebc3 Merge pull request #28715 from lorentey/OptionSet-remove-back-deployment
[test] Protect OptionSet.remove test with future availability
2019-12-11 15:01:03 -08:00
Karoy Lorentey
b31c55be64 [test] Protect OptionSet.remove test with future availability 2019-12-11 12:43:00 -08:00
Ravi Kandhadai
d154f45f01 [stdlib-private][os log] Add new log methods for each specific logging level.
Also, add aliases for the logging levels for source compatibility with swift-server
side logging. Create a new initializer of Logger that can directly accept an
existing os log object of type `OSLog`. This aids in porting uses of existing
os_log API to the new API.
2019-12-11 11:49:02 -08:00
Ravi Kandhadai
af3aa03e0d Merge pull request #28697 from ravikandhadai/oslog-generic-operator-bug-fix
[Constant Evaluator] Fix a bug in the composition of substitution maps
2019-12-11 09:29:31 -08:00
Ravi Kandhadai
7744720df3 [Constant Evaluator] Fix a bug in the composition of substitution
maps in the handling of partial applies. In particular, when using
substMap.subst(otherSubstMap), ensure that otherSubstMap is not empty.

Also, store the partial-apply instruction in the symbolic closure,
which makes it easier to debug errors in the folding of partial applies.
2019-12-10 20:13:49 -08:00
Karoy Lorentey
2e17867774 Merge pull request #28378 from JacobMao/fix/SR-11283
SR-11283: Amend OptionSet.remove method
2019-12-10 17:41:45 -08:00
Ravi Kandhadai
f705720f1e [os log][stdlib/private] Add extensions for logging NSObjects.
The extensions for supporting NSObjects are in the file:
OSLogNSObjectType.swift. This creates a new dependency for the
OSLogPrototype overlay on the module: ObjectiveC. However,
ObjectiveC is already a dependency for the os module.

This patch includes tests for the NSObject extensions.
In addition, this patch contains a few other minor changes.
1. It makes the `osLog` function public (so that it can be
used by clients directly). 2. It fixes a lifetime-related
bug in the osLog function implementation. 3. It improves
the OSLogPrototypeExecTest suite by refactoring a few
helper functions.
2019-12-09 20:03:50 -08:00
Nate Cook
702fd84957 Use the correct test method 2019-11-26 18:25:49 -06:00
Diego Torres
a76e78d297 Add test to verify lazy filter predicate order 2019-11-26 17:37:58 -06:00
zhuowei
b9c1deff5f [stdlib] fix return type of getNumRuntimeFunctionCounters (#24182)
The return type of getNumRuntimeFunctionCounters is defined as uint64_t in RuntimeInvocationsTracking.cpp, but it has return type Int in RuntimeFunctionCounters.swift.

Found when compiling the stdlib for WebAssembly, as WebAssembly validates return types. uint64_t corresponds to i64, but Int is i32, so the program fails validation.
2019-11-22 13:44:56 -05:00
kelvin13
e4dc295d64 fix conflicts 2019-11-21 12:42:10 -06:00