Commit Graph

1487 Commits

Author SHA1 Message Date
Itai Ferber
c7feef6dec Merge pull request #16393 from itaiferber/localizedString-for-nullability-fix
Correct cast from IUO in Locale.localizedString(for:)
2018-05-07 09:11:59 -07:00
Morten Bek Ditlevsen
13c781fa9c Imitate container stack logic from box_(_ value: Encodable) in box(_ dict: [String : Encodable]) 2018-05-07 10:42:36 +02:00
Morten Bek Ditlevsen
a08cd5254f Added another marker protocol for encodable string keyed dictionaries 2018-05-05 22:36:30 +02:00
Morten Bek Ditlevsen
66d9fb3550 Ensure that keys are strings 2018-05-05 22:29:07 +02:00
Morten Bek Ditlevsen
39f9e8f79a Implemented fixes suggested by Itai 2018-05-05 22:21:27 +02:00
Morten Bek Ditlevsen
d35038e277 Merge branch 'master' into jsoncodingkeys 2018-05-05 10:23:57 +02:00
Morten Bek Ditlevsen
b94c4c512b Merge branch 'master' of https://github.com/apple/swift 2018-05-05 10:23:28 +02:00
Itai Ferber
6fa55556a3 Fix a cast to an IUO which can actually be nil. 2018-05-04 14:57:41 -07:00
Jordan Rose
fc99de452d Foundation: resolve some warnings (#16078)
- JSONEncoder.swift: tell the compiler that yes, this is supposed to
  be casting to 'T' and not 'T?'.

- NSObject.swift: mark NSKeyValueObservation members explicitly @objc
  and @nonobjc.

- NSStringAPI.swift: remove unnecessary @usableFromInline.

No intended functionality change.
2018-05-01 15:41:21 -07:00
Itai Ferber
ae8718f083 Merge pull request #16182 from itaiferber/recoverableerror-escaping-resulthandler
RecoverableError's resultHandler needs @escaping
2018-04-30 10:54:00 -07:00
Jordan Rose
f9f91ef233 Dispatch: Simplify DispatchData.append(_: UnsafeBufferPointer<T>) (#16080)
The deprecation warning guides us towards UnsafeRawBufferPointer,
so sure, let's use that.

No intended functionality change.
2018-04-30 09:22:35 -07:00
Mox Soini
d4511da4f8 Make _fastEnumerationStorageMutationsPtr internal
...and make Foundation use it's own fileprivate _fastEnumerationStorageMutationsPtr
2018-04-27 00:00:26 +03:00
Itai Ferber
c87bf17efe Mark resultHandler as @escaping 2018-04-26 10:55:40 -07:00
Morten Bek Ditlevsen
c0166bfb31 Remove unused function 2018-04-25 22:47:05 +02:00
Morten Bek Ditlevsen
8a3bc0b73b Make JSONEncoder and JSONDecoder circumvent keyEncodingStrategies and keyDecodingStrategies for String keyed Dictionaries. 2018-04-25 22:40:31 +02:00
Slava Pestov
28ce9204fe stdlib: More SE-0193 updates 2018-04-24 21:21:22 -07:00
Karoy Lorentey
7d679f8d39 [SE-0206][CoreFoundation] _CFObject: Provide default implementation for _hash(into:)
Without this change, the Hashable synthesizer attempts to add hash(into:) methods directly on CF types, which (somewhat unsurprisingly) fails with assertion below. (This situation is unique to CF types, which are imported with an implicit _CFObject conformance; we usually have an extension context or a non-imported type decl in which to put the derived methods.)

Assertion failed: (!decl->isForeign() && "Use getForeignMetadataLayout()"), function getClassMetadataLayout, file /Users/klorentey/Swift/swift/lib/IRGen/MetadataLayout.cpp, line 83.
0  swift                    0x000000010ccd29c8 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1  swift                    0x000000010ccd30d6 SignalHandler(int) + 694
2  libsystem_platform.dylib 0x00007fff600e0d9a _sigtramp + 26
3  swift                    0x000000010e04f1ed cmark_strbuf__initbuf + 122440
4  libsystem_c.dylib        0x00007fff5ffa6f79 abort + 127
5  libsystem_c.dylib        0x00007fff5ff6f090 basename_r + 0
6  swift                    0x00000001096e8f95 swift::irgen::IRGenModule::getClassMetadataLayout(swift::ClassDecl*) + 53
7  swift                    0x00000001095b9e25 swift::irgen::emitVirtualMethodValue(swift::irgen::IRGenFunction&, llvm::Value*, swift::SILDeclRef, swift::CanTypeWrapper<swift::SILFunctionType>) + 133
8  swift                    0x00000001095ba252 swift::irgen::emitVirtualMethodValue(swift::irgen::IRGenFunction&, llvm::Value*, swift::SILType, swift::SILDeclRef, swift::CanTypeWrapper<swift::SILFunctionType>, bool) + 690
9  swift                    0x00000001096bef49 swift::SILInstructionVisitor<(anonymous namespace)::IRGenSILFunction, void>::visit(swift::SILInstruction*) + 33497
10 swift                    0x00000001096b3067 swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) + 8055
11 swift                    0x00000001095c8d8b swift::irgen::IRGenerator::emitLazyDefinitions() + 1051
12 swift                    0x000000010968eb16 performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::StringRef, swift::PrimarySpecificPaths const&, llvm::LLVMContext&, swift::SourceFile*, llvm::GlobalVariable**, unsigned int) + 1382
13 swift                    0x000000010968f05e swift::performIRGeneration(swift::IRGenOptions&, swift::SourceFile&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::StringRef, swift::PrimarySpecificPaths const&, llvm::LLVMContext&, unsigned int, llvm::GlobalVariable**) + 94
14 swift                    0x000000010952cfc0 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 15488
15 swift                    0x0000000109528332 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2962
16 swift                    0x00000001094e4848 main + 2328
17 libdyld.dylib            0x00007fff5feecc41 start + 1
Stack dump:
[…]
1.	While emitting IR SIL function "@$SSo10CGColorRefas8HashableSCsACP4hash4intoys6HasherVz_tFTW".
 for 'hash(into:)' in module 'CoreGraphics'
2018-04-24 17:42:42 +01:00
Morten Bek Ditlevsen
a5a68ca25d Fix negation of 0 length Decimal (#15986)
A Decimal value with _length 0 and _isNegative set to 1 is interpreted as a NaN. The 'negate()' function however, flipped the _isNegative flag without regard for the _length 0 case. This meant that -0 would become NaN. The fix checks for the _length 0 special case. In NSDecimalSubtract() the same check was performed. Since this now happens in negate(), it is removed from the NSDecimalSubtract() function.
2018-04-18 10:18:34 -07:00
Philippe Hausler
57d0ea8013 [Foundation] Guard Data access to NSData._isCompact under availability guards 2018-04-12 09:53:34 -07:00
Devin Coughlin
302d82731a [Foundation] Address exclusivity violation in Data
Address an exclusivity violation in Data's Iterator.next() by changing two private
'let' stored properties to be 'var'.

Making the properties 'var' changes code generation of next() so that the stored
properties are read independently of the other contents of the struct. This
prevents an exclusivity violation when reading '_endIdx' and '_data' while
simultaneously mutating '_buffer' with the call to withUnsafeMutablePointer().

The 'let' pattern is an idiom we would eventually like to support (see SR-7396),
but for now we need to remove the exclusivity violation.
2018-04-09 16:18:17 -07:00
Sho Ikeda
9efd347100 [gardening][Overlay] Use isEmpty in Data.swift 2018-04-05 17:50:20 +09:00
Kevin Ballard
e66f2b121f Make URL.init(resolvingBookmarkData:…) non-failable
The NSURL method can't return `nil` unless it's throwing an error, so
the Swift initializer shouldn't be failable.

SR-3705
2018-04-04 11:40:25 -07:00
Sho Ikeda
68e76535bc [gardening][Calendar] No need to discard the retrun value of insert(_:) which is discardable 2018-04-04 19:29:42 +09:00
Xi Ge
d93e0dfa01 Merge pull request #15636 from Fidetro/master
Fixed JSONEncoder code style issues
2018-04-01 08:39:04 -07:00
swift-ci
6c42bcccbd Merge pull request #15507 from devincoughlin/foundation-datecomponents-exclusivity-warnings 2018-03-31 10:47:38 -07:00
swift-ci
ee57586822 Merge pull request #15652 from brennanMKE/semicolon 2018-03-31 08:19:28 -07:00
brennanMKE
fb2f55f558 [stdlib] remove trailing semicolon in stdlib source 2018-03-30 22:44:05 -07:00
Slava Pestov
e1f50b2d36 SE-0193: Rename @_inlineable to @inlinable, @_versioned to @usableFromInline 2018-03-30 21:55:30 -07:00
fidetro
2bf6b88585 Fixed code style issues 2018-03-31 05:00:46 +08:00
Max Moiseev
a582a7628c Remove the underscored public protocols from overlays
These protocols were introduced to work around the problem where
compiler could not correctly handle instance of multiple @available
attributes (one for the language version and another for teh OS version)
applied to the same member.

Now that the compiler issues has been fixed, it is the right time to get
rid of the workarounds.

Addresses: <rdar://problem/36556261>
2018-03-30 13:43:41 -07:00
Karoy Lorentey
e485c1506b Merge pull request #15382 from lorentey/conditional-hashable2
[SE-0143][stdlib] Conditionally conform stdlib types to Hashable
2018-03-28 21:45:02 +01:00
Sho Ikeda
1c3909e03d [Dispatch][gardening] Use Optional.map over flatMap where appropriate
The initializers used here are not optional ones, so there is no need to use `flatMap`.
2018-03-27 23:22:25 +09:00
Devin Coughlin
524f273d99 [Foundation] Fix exclusivity warnings in DateComponents
DateComponents has a number of exclusivity warnings that all result from the same idiom
for applying mutation in computed properties:

    public var era: Int? {
        get { return _handle.map { _getter($0.era) } }
        set { _applyMutation { $0.era = _setter(newValue) } }
    }

Here _applyMutation() is a mutating method, so it requires exclusive access to 'self'
for the duration of the call. However, calling the _setter() method in the block
requires access to read 'self', which conflicts with the already in-progress modifying
access begun by _applyMutation().

A fix is to change _setter() to be a static function, so it doesn't require access to
'self'.
2018-03-25 19:47:50 -07:00
Karoy Lorentey
18e7470ae7 [Foundation] NSArray, NSDictionary: Add custom AnyHashable representations
Now that Array and Dictionary conform to Hashable, we need to make sure that their bridged counterparts provide the same hash values when converted to AnyHashable.
2018-03-23 19:08:39 +00:00
Sho Ikeda
c076316722 [gardening][Overlay] Prefer macOS over OSX for @available 2018-03-23 13:36:59 +09:00
Stephen Canon
8e11af4012 Make the naming of underlying builtin for FP + Vector match Integer. (#15430)
* Make the underlying builtins for FP + Vector match Integer.

For stdlib integer types, these are named `_value` and `init(_ _value: Builtin.xxx)`. This patch adopts the same scheme for stdlib floating point and SDK overlay vector types, and removes a legacy init for integers that was only needed to support them. There should be no changes visible outside of the stdlib, and no functional change within the stdlib; the naming of some implementation details is simply more uniform now.
2018-03-22 16:43:20 -04:00
Jordan Rose
d150f96967 Merge pull request #14945 from jrose-apple/frozen-enums
Implementation for /most/ of SE-0192 (frozen and non-frozen enums)
2018-03-21 11:06:31 -07:00
Sho Ikeda
c133e09015 Merge pull request #15326 from ikesyo/use-isempty-over-count
[gardening][Data] Prefer `!isEmpty` over `count > 0`
2018-03-21 09:54:39 +09:00
Jordan Rose
3866535e04 [stdlib] Add '@_frozen' to overlay enums that need it
That's just ARCamera.TrackingState and DispatchTimeoutResult.
Verified with the framework owners at Apple.
2018-03-20 14:53:55 -07:00
Max Moiseev
ad43838bb4 Merge pull request #15354 from moiseev/colortable-size
[overlay] Fix the CGColorSpace.colorTable size calculation
2018-03-20 14:03:41 -07:00
Jordan Rose
f7bb041e0f Remove 'public' from a few NSError-bridging-related symbols (#14731)
We're still using most of this, but not all of it has to be public.

rdar://problem/35230025
2018-03-20 13:02:21 -07:00
Stephen Canon
d3cb915abb Updates to tgmath functions for CGFloat (#15360)
* Updates to tgmath functions for CGFloat

These changes bring CGFloat in line with the other FloatingPoint types.  Some of this stuff is now defined at the protocol level, so we can get rid of it at the concrete type level.  A couple other functions have been deprecated for all types, with protocol or tgmath replacements.
2018-03-20 11:14:57 -04:00
Itai Ferber
feae8bd0b0 Merge pull request #15335 from ikesyo/use-isempty-over-count-2
[gardening][(JSON|Plist)Encoder] Prefer `!isEmpty` over `count > 0`
2018-03-20 08:02:38 -07:00
Sho Ikeda
e0eadc26bb [gardening][Foundation] Prefer macOS over OSX for @available 2018-03-20 21:35:58 +09:00
Max Moiseev
243df7e035 [overlay] Fix the CGColorSpace.colorTable size calculation
Fixes: <rdar://problem/38150404>
2018-03-19 16:01:17 -07:00
Sho Ikeda
a63df4daa1 [gardening][(JSON|Plist)Encoder] Prefer !isEmpty over count > 0 2018-03-19 13:42:31 +09:00
Sho Ikeda
ba3a62b725 [gardening][Data] Prefer !isEmpty over count > 0 2018-03-18 00:58:57 +09:00
Sho Ikeda
70ab828d9f [gardening][Dispatch] Prefer macOS over OSX for @available 2018-03-16 13:30:01 +09:00
Jordan Rose
520d6b9b91 Make NS_TYPED_ENUMS ObjectiveCBridgeable when they wrap an object (#15270)
This allows them to be used in generic arguments for NSArray et al.
We already do this for the ones that wrap bridged values (like
NSString/String), but failed to do it for objects that /weren't/
bridged to Swift values (class instances and protocol compositions),
or for Error-which-is-special.

In addition to this being a sensible thing to do, /not/ doing this led
to IRGen getting very confused (i.e. crashing) when we imported a
Objective-C protocol that actually used an NS_TYPED_ENUM in this way.

(We actually shouldn't be using Swift's IRGen logic to emit protocol
descriptors for imported protocols at all, because it's possible we
weren't able to import all the requirements. But that's a separate
issue.)

https://bugs.swift.org/browse/SR-6844
2018-03-15 16:17:38 -07:00
Jordan Rose
74a4adc54c [stdlib] Remove ignored platform-agnostic '@available' from extensions
It looks like we exposed a bunch of Metal APIs to Swift 3 that we
didn't mean to; at this point it would be a source-breaking change to
hide them. Oops.
2018-03-14 16:37:40 -07:00