Commit Graph

34 Commits

Author SHA1 Message Date
Mike Ash
01300a6f86 [Runtime] Fix memory leak in -[__SwiftNativeNSError description] for large error values.
Balance the call to allocateBufferIn with a call to deallocateBufferIn. When an error value is small, the missing deallocateBufferIn doesn't do anything. But when the error value is a larger struct that doesn't fit inline, we need deallocateBufferIn to avoid leaking the allocation.

rdar://109933822
2023-06-01 12:54:19 -04:00
Anthony Latsis
52ce15ee9d Gardening: Migrate test suite to GH issues: stdlib 2022-09-22 03:21:39 +03:00
Karoy Lorentey
e2cfab4f28 [stdlib][test] Adopt availability macros in tests 2021-10-31 15:00:58 -07:00
Luciano Almeida
c29fbb5528 [test] Adjusting test files where class syntax is used for protocol inheritance 2020-11-29 21:43:50 -03:00
Mishal Shah
a3cd8bc9e9 [Tests] Codesign the binary before executing the test 2020-08-07 00:26:07 -07:00
Mishal Shah
272c466e47 Update master to build with Xcode 12 beta 2020-06-22 15:43:20 -07:00
Mishal Shah
e7cd5ab17f Update master to build with Xcode 11.4 2020-03-24 11:30:45 -07:00
Mike Ash
2763e13a9a [Stdlib] Fix an overrelease in -[__SwiftNativeNSError description].
getDescription takes its argument at +1, but the implementation was passing the value directly. This caused the contained error value to be destroyed.

rdar://problem/59512630
2020-02-18 11:30:03 -05: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
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
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
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
Doug Gregor
72ef0b1043 Remove extraneous function from test 2019-11-20 16:26:04 -08:00
Doug Gregor
c8df9cd234 [Test] Introduce appropriate runtime availability check 2019-11-20 16:23:38 -08:00
Doug Gregor
9975572781 [Runtime] Add test for casting an Error type to NSObject 2019-11-20 15:56:24 -08:00
Brent Royal-Gordon
bc5d59ecb7 Revert "[Runtime] Handle dynamic casting to NSObject via error bridging." 2019-11-20 10:38:44 -08:00
Doug Gregor
76591217fe [Runtime] Add test for casting an Error type to NSObject 2019-11-19 08:46:28 -08:00
Brent Royal-Gordon
1875783734 Use more robust Swift type names for error domains
getErrorDomainStringForObjC() now includes the parent types in the error domain string. Its implementation does not support generic types or private discriminators, but those types can’t be PrintAsObjC’d anyway, so we should never see them.
2018-12-21 15:45:23 -08:00
Brent Royal-Gordon
2eed5374db Only generate domains for PrintAsObjC-able types
Otherwise we generate a call to String(reflecting:), which correctly handles many things we may not be able to (like private types), and which matches the default implementation of Error._domain.
2018-12-21 15:45:21 -08:00
Itai Ferber
d8d6c7812c Add #available checks for NSKeyedArchiver methods in tests 2018-12-13 12:55:57 -08:00
Slava Pestov
38fdb6b7ff Update various tests to not use Swift 3 code
Completely mechanical changes:

- Explicit @objc in a few places
- Some imported APIs changed
- For the mix-and-match tests, just test version 4/5 instead of 3/4
2018-10-26 20:15:01 -04:00
Ben Cohen
e338344bae Remove overloads that were needed pre-conditional conformance 2018-09-11 21:00:36 -07:00
Doug Gregor
ecf752d54b Revert "Revert " [Foundation] Collapse (SignedInteger|UnsignedInteger) reqts into FixedWidthInteger"" 2018-08-29 13:18:44 -07:00
Mike Ash
8a9065a369 Revert " [Foundation] Collapse (SignedInteger|UnsignedInteger) reqts into FixedWidthInteger" 2018-08-29 13:55:20 -04:00
Doug Gregor
4acd723d16 [Foundation] Handle unsigned error codes without trapping.
When working with Error types with unsigned raw values, numeric-cast into
a UInt and then map the bits over to an Int so we preserve values not
representable in an Int without wrapping.

Thanks to @jrose-apple for pointing this out!
2018-08-28 10:49:01 -07:00
Mike Ash
e992f46764 [Runtime] Extend ObjC bridging casts to convert NSError to Error when nested in a container type.
rdar://problem/39349762
2018-06-28 13:35:25 -04:00
Slava Pestov
5d2752f7d2 Run tests with -swift-version 4 by default
Some test now fail, so add an explicit -swift-version 3.
2018-06-19 23:24:19 -07:00
Greg Parker
7e38792bdd [stdlib] Thou shalt not call objc_msgSend() without a function pointer cast.
Fixes test stdlib/ErrorBridged.swift on arm64.

rdar://30900987
2017-03-14 12:33:10 -07:00
Kevin Ballard
aa0cfa33af Better default domain for CustomNSError
We were creating domains that looked like `"main.SomeError.Type"`
instead of the expected `"main.SomeError"`. Fix this and add some basic
tests.
2017-01-16 15:50:35 -08:00
ben-cohen
ce0d713cd6 fixed where clauses, Optional-as-Any and unused vars 2016-12-29 07:58:12 -08: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
Dmitri Gribenko
243a35cd65 Migrate callsites from 'expectEmpty()' to 'expectNil()' 2016-09-10 20:05:42 -07:00
Doug Gregor
73e2143213 [SE-0112] Provide default implementations for CustomNSError requirements.
Provide default implementations for all of the CustomNSError requirements:
  * errorDomain: default to the name of the enum type
  * errorCode: default to the same thing "_code" gets, e.g., the enum tag or
    raw value
  * errorUserInfo: default to empty

This makes it significantly easier to customize just one aspect of the
NSError view of an error type, e.g., just the user-info dictionary,
without having to write boilerplate for the others. This was actually
part of SE-0112, but I missed it in the original implementation and we
thought it was an amendment.

Fixes rdar://problem/23511842.
2016-09-02 10:33:15 -07:00
Max Moiseev
9fc37efee4 [test] renaming test/1_stdlib to just test/stdlib 2016-09-01 16:51:43 -07:00