Commit Graph

174 Commits

Author SHA1 Message Date
Michael Ilseman
ccda8f33d1 [noescape by default] Proliferate @escaping
Adds an explicit @escaping throughout the standard library, validation
test suite, and tests. This will be necessary as soon as noescape is
the default for closure parameters.
2016-07-29 13:48:07 -07:00
Joe Groff
4b9e49827d Make all _toAnyHashable() implements @nonobjc. 2016-07-27 09:25:30 -07:00
Dmitri Gribenko
c0b183a208 Merge pull request #3781 from apple/stdlib-AnyHashable-for-Foundation.NSDecimalNumber
Add AnyHashable support for Foundation.Decimal
2016-07-27 09:22:48 -07:00
Dmitri Gribenko
168b563315 Foundation: stop exporting certain overlay methods to Objective-C 2016-07-27 01:14:56 -07:00
Dmitri Gribenko
ea693dd8d1 Add AnyHashable support for Foundation.Decimal
Add a custom AnyHashable representation to Foundation.Decimal, so that
it behaves like all other bridged types.
2016-07-27 01:14:16 -07:00
Joe Groff
5b3f2af297 Merge pull request #3756 from jckarter/turn-on-anyhashable
Turn on AnyHashable
2016-07-26 15:45:13 -07:00
Andrew Trick
a18d490d6a Migrate from UnsafePointer<Void> to UnsafeRawPointer. (#3773)
* Migrate from `UnsafePointer<Void>` to `UnsafeRawPointer`.

As proposed in SE-0107: UnsafeRawPointer.

`void*` imports as `UnsafeMutableRawPointer`.
`const void*` imports as `UnsafeRawPointer`.

Occurrences of `UnsafePointer<Void>` are replaced with UnsafeRawPointer.

* Migrate overlays from UnsafePointer<Void> to UnsafeRawPointer.

This requires explicit memory binding in several places,
particularly in NSData and CoreAudio.

* Fix a bunch of test cases for Void->Raw migration.

* qsort takes IUO values

* Bridge `Unsafe[Mutable]RawPointer as `void [const] *`.

* Parse #dsohandle as UnsafeMutableRawPointer

* Update a bunch of test cases for Void->Raw migration.

* Trivial fix for the SceneKit test case.

* Add an UnsafeRawPointer self initializer.

This is unfortunately necessary for assignment between types imported from C.

* Tiny simplification of the initializer.
2016-07-26 14:21:15 -07:00
Tony Parker
19998457d3 Merge pull request #3607 from phausler/UndoManager_registerUndo_naming_update
[Foundation] Update UndoManager registerUndo to adopt new naming rules
2016-07-26 14:15:02 -07:00
Joe Groff
1e8dd0e34b ClangImporter: Import unbounded NSSets and NSDictionaries using AnyHashable. 2016-07-26 13:36:05 -07:00
Joe Groff
e884ab737d Foundation: Make AnyHashable bridge to NSObject. 2016-07-26 13:36:05 -07:00
Dmitri Gribenko
a3254b7990 Foundation: add custom AnyHashable representations to NSNumber and NSString
We want NSNumbers bridged from Swift types to bridge back to the same
Swift type.
2016-07-26 03:10:52 -07:00
Andrew Trick
0ed9ee8dee Revert "Migrate from UnsafePointer<Void> to UnsafeRawPointer. (#3724)"
This reverts commit ece0951924.

This results in lldb failues on linux that I can't readily debug.
Backing out until they can be resolved.
2016-07-26 02:50:57 -07:00
Andrew Trick
ece0951924 Migrate from UnsafePointer<Void> to UnsafeRawPointer. (#3724)
* Migrate from `UnsafePointer<Void>` to `UnsafeRawPointer`.

As proposed in SE-0107: UnsafeRawPointer.

`void*` imports as `UnsafeMutableRawPointer`.
`const void*` imports as `UnsafeRawPointer`.

Occurrences of `UnsafePointer<Void>` are replaced with UnsafeRawPointer.

* Migrate overlays from UnsafePointer<Void> to UnsafeRawPointer.

This requires explicit memory binding in several places,
particularly in NSData and CoreAudio.

* Fix a bunch of test cases for Void->Raw migration.

* qsort takes IUO values

* Bridge `Unsafe[Mutable]RawPointer as `void [const] *`.

* Parse #dsohandle as UnsafeMutableRawPointer

* Update a bunch of test cases for Void->Raw migration.

* Trivial fix for the SceneKit test case.

* Add an UnsafeRawPointer self initializer.

This is unfortunately necessary for assignment between types imported from C.

* Tiny simplification of the initializer.
2016-07-26 02:18:21 -07:00
Joe Groff
32b50c624d stdlib: Remove _isBridgedToObjectiveC from _ObjectiveCBridgeable.
All generic bridgeable types can bridge for all their instantiations now. Removing this ferrets out some now-unnecessary traps that check for unbridgeable parameter types.
2016-07-25 06:01:21 -07:00
Joe Groff
95e462022d Update Foundation overlay for id-as-Any. 2016-07-25 06:01:21 -07:00
Philippe Hausler
e8639fe501 [Foundation] Update UndoManager registerUndo to adopt new naming rules
Addresses rdar://problem/26500390 registerUndoWithTarget in overlay not updated for new API names
2016-07-19 11:04:46 -07:00
Philippe Hausler
e0ca8fbd80 [Foundation] Keep NS Updates due to changes in SE-0086
Second pass at updates for SE-0086 feedback

<rdar://problem/26892977> Make sure NSOrderedSet keeps its NS
<rdar://problem/26880016> NSBundleResourceRequest should keep its NS
<rdar://problem/26892958> Make sure NSAttributedString keeps its NS
<rdar://problem/26653694> NSCoder.decodeTopLevelObjectForKey does not follow naming guidelines
<rdar://problem/27355801> Foundation should have a structural type for TextCheckingResult
<rdar://problem/26770611> NSExpression naming is a bit awkward in swift
<rdar://problem/26653451> NSCoder encodeDataObject is misleading
<rdar://problem/26653653> NSCoder decodeObjectOfClass is redundant
2016-07-15 09:56:21 -07:00
Robert Widmann
c39da37525 Merge pull request #3474 from CodaFi/postminimalist-abstract-expressionism
[SE-0115] Rename *LiteralConvertible protocols to ExpressibleBy*…
2016-07-12 21:08:52 -07:00
Tony Parker
35dd2462f4 Naming updates and hoists for SE-0086
XMLNodeOptions -> XMLNode.Options
NSTextCheckingTypes -> hoisted into NSTextCheckingResult
URLSessionTaskMetricsResourceFetchType ->
URLSessionTaskMetrics.ResourceFetchType

27235689
26995110
2016-07-12 18:08:39 -07:00
Robert Widmann
f97e5dcb0e [SE-0115][1/2] Rename *LiteralConvertible protocols to ExpressibleBy*Literal. This
change includes both the necessary protocol updates and the deprecation
warnings
suitable for migration.  A future patch will remove the renamings and
make this
a hard error.
2016-07-12 15:25:24 -07:00
Doug Gregor
823c24b355 [SE-0112] Rename ErrorProtocol to Error.
This is bullet (5) of the proposed solution in SE-0112, and the last
major piece to be implemented.
2016-07-12 10:53:52 -07:00
Mishal Shah
23b646eed2 Update master to build with Xcode 8 beta 2, OS X 10.12, iOS 10, tvOS 10, and watchOS 3 SDKs 2016-07-06 10:48:45 -07:00
Philippe Hausler
24ff368d4f [Foundation] Swift3 API naming feedback
Addresses the following issues:

rdar://problem/25992816 -[NSUserDefaults registerDefaults] is being imported as NSUserDefaults.register(), which is confusing
rdar://problem/26291437 UserDefaults has 'setURL(forKey:)' instead of 'set(_:forKey:)'
rdar://problem/26375229 FileManager overlay has old naming
rdar://problem/26090891 NSBundle methods that are overridden in the apinotes incorrectly handle the first argument pattern
rdar://problem/26271340 struct URL initializer for fileURLWithFileSystemRepresentation is incorrectly named'
rdar://problem/26443640 XMLDTDNode.Kind conflicts with XMLNode.Kind and should be renamed to XMLDTDNode.DTDKind
rdar://problem/26500390 registerUndoWithTarget in overlay not updated for new API names
rdar://problem/26653451 NSCoder encodeDataObject is misleading
rdar://problem/26653653 NSCoder decodeObjectOfClass is redundant
rdar://problem/26653694 NSCoder.decodeTopLevelObjectForKey does not follow naming guidelines
rdar://problem/26656299 SocketNativeHandle should be a hoisted type to SocketPort
https://bugs.swift.org/browse/SR-1903
2016-07-05 11:19:12 -07:00
Philippe Hausler
0db73cb80c Revert "[Foundation] Workaround for importer NS_REFINED_FOR_SWIFT failure in development environments"
This reverts commit 1bfd433d3e.
2016-07-05 11:19:12 -07:00
Chris Lattner
45f2cfaaa0 Implement SE-0099, but where the migration diagnostics are left as warnings
for now.  I'll upgrade them to errors in a week or two to give downstream
projects a chance to update.
2016-07-02 15:44:57 -07:00
Philippe Hausler
1bfd433d3e [Foundation] Workaround for importer NS_REFINED_FOR_SWIFT failure in development environments
This is just a work-around for the underlying importer failure tracked by <rdar://problem/26921178>
2016-06-21 10:28:18 -07:00
Mishal Shah
87b7bcfd3e Update master to build with Xcode 8 beta 1, OS X 10.12, iOS 10, tvOS 10, and watchOS 3 SDKs. 2016-06-14 14:53:55 -07:00
Dmitri Gribenko
974fe589fe Merge pull request #2806 from rintaro/se-0081-stdlib-migration
[SE-0081][stdlib] Apply tail style "where" clause to stdlib
2016-06-02 02:07:55 -07:00
rintaro ishizaki
d3b9d470be [Foundation] Apply tail style "where" clause to Foundation SDK overlay 2016-06-02 12:04:42 +09:00
Dmitri Gribenko
3661c398ba SDK overlay: add ABI FIXME 2016-06-01 11:05:07 -07:00
Dmitri Gribenko
d591f9cf7a stdlib: remove most uses of @warn_unused_result, which does nothing now
I kept the one on sorted(), because that one requires a less trivial
change.
2016-05-19 18:39:39 -07:00
John McCall
a1c1693529 Change the names of the object-literal initializers to be
semantically unambiguous.

We didn't actually intend to change how programmers normally
constructed these types, but the change to the object literal
syntax accidentally caused these initializers to have very
natural-seeming signatures.  These initializers also created
possible ambiguities with the actual initializers.  Renaming
them to refer to their function as literal initializers is the
right thing to do.

Unfortunately, this provided to be somewhat annoying, as the
code was written to assume that the argument tuple following
e.g. #colorLiteral could be directly passed to the initializer.
We solve this by hacking on both ends of the constraint system:
during generation we form a conversion constraint to the
original, idealized parameter type, and during application we
rewrite the argument tuple type to use the actual labels.
This nicely limits the additional complexity to just the
parts dealing with object literals.

Note that we can't just implicitly rewrite the tuple expression
because that would break invariants tying the labels to physical
source ranges.  We also don't want to just change the literal
syntax again and break compatibility with existing uses.

rdar://26148507
2016-05-13 10:33:37 -07:00
Dmitri Gribenko
b75d2b9df4 Merge remote-tracking branch 'origin/master' into swift-3-indexing-model 2016-04-25 13:50:09 -07:00
Ted Kremenek
b8bbed8c13 [WIP] Implement SE-0039 (Modernizing Playground Literals) (#2215)
* Implement the majority of parsing support for SE-0039.

* Parse old object literals names using new syntax and provide FixIt.

For example, parse "#Image(imageLiteral:...)" and provide a FixIt to
change it to "#imageLiteral(resourceName:...)".  Now we see something like:

test.swift:4:9: error: '#Image' has been renamed to '#imageLiteral
var y = #Image(imageLiteral: "image.jpg")
        ^~~~~~ ~~~~~~~~~~~~
        #imageLiteral resourceName

Handling the old syntax, and providing a FixIt for that, will be handled in a separate
commit.

Needs tests.  Will be provided in later commit once full parsing support is done.

* Add back pieces of syntax map for object literals.

* Add parsing support for old object literal syntax.

... and provide fixits to new syntax.

Full tests to come in later commit.

* Improve parsing of invalid object literals with old syntax.

* Do not include bracket in code completion results.

* Remove defunct code in SyntaxModel.

* Add tests for migration fixits.

* Add literals to code completion overload tests.

@akyrtzi told me this should be fine.

* Clean up response tests not to include full paths.

* Further adjust offsets.

* Mark initializer for _ColorLiteralConvertible in UIKit as @nonobjc.

* Put attribute in the correct place.
2016-04-25 07:19:26 -07:00
Dmitri Gribenko
c52787e900 Merge commit '9cdbec13eee72feccfc5f8b987882a8c52e8107b' into swift-3-indexing-model 2016-04-14 16:23:53 -07:00
Dmitri Gribenko
3e708a9328 Merge commit '8e292daec1bc790c96b5ee39b8d55dadcac6ce1b' into swift-3-indexing-model 2016-04-14 15:10:26 -07:00
Dmitri Gribenko
10697f939f Merge commit '510f29abf77e202780c11d5f6c7449313c819030' into swift-3-indexing-model 2016-04-14 13:45:27 -07:00
Jordan Rose
315761c4cf [ClangImporter] Don't assume inner pointers are nullable.
Some inner pointers are explicitly annotated as _Nonnull, and we
should believe that. This is important when passing, say, pointers
to arrays.
2016-04-11 20:06:41 -07:00
Jordan Rose
bc83940301 Make pointer nullability explicit using Optional.
Implements SE-0055: https://github.com/apple/swift-evolution/blob/master/proposals/0055-optional-unsafe-pointers.md

- Add NULL as an extra inhabitant of Builtin.RawPointer (currently
  hardcoded to 0 rather than being target-dependent).
- Import non-object pointers as Optional/IUO when nullable/null_unspecified
  (like everything else).
- Change the type checker's *-to-pointer conversions to handle a layer of
  optional.
- Use 'AutoreleasingUnsafeMutablePointer<NSError?>?' as the type of error
  parameters exported to Objective-C.
- Drop NilLiteralConvertible conformance for all pointer types.
- Update the standard library and then all the tests.

I've decided to leave this commit only updating existing tests; any new
tests will come in the following commits. (That may mean some additional
implementation work to follow.)

The other major piece that's missing here is migration. I'm hoping we get
a lot of that with Swift 1.1's work for optional object references, but
I still need to investigate.
2016-04-11 20:06:38 -07:00
Chris Willmore
73d5077bae Add API notes for Foundation following internal Swift 3 naming audit. 2016-04-07 20:35:18 -07:00
Manav Gabhawala
7928140f79 [SE-0046] Implements consistent function parameter labels by discarding extraneous parameter names and adding _ where necessary 2016-04-06 20:21:58 -04:00
Dmitri Gribenko
a6cd57222a Merge remote-tracking branch 'origin/master' into swift-3-indexing-model 2016-03-21 14:41:15 -07:00
Doug Gregor
67dad6041c [Runtime] Use the _ObjectiveCBridgeable._ObjectiveCType type witness directly.
This lets us eliminate the _getObjectiveCType() value witness, which
was working around the lack of proper type witness metadata in witness
tables. Boilerplate -= 1.
2016-03-18 16:11:38 -07:00
Doug Gregor
d92ae77076 Eliminate most remaining uses of _convertNSFooToFoo and _convertFooToNSFoo.
Generalized bridging has fully subsumed most of these. NSError is
still special, and _convertStringToNSString remains for the the
runtime's implementation of SwiftObject's -description method.
2016-03-18 11:42:00 -07:00
Dave Abrahams
f493b54e44 [stdlib] indexing model: Interval/Range merge
This is step 1; we still need to introduce ClosedRange.
2016-03-16 15:59:10 -07:00
Doug Gregor
1d90b044fb Really reinstate "[SILGen] Implement NSString -> String bridging through _ObjectiveCBridgeable."
This reverts commit 052d2d0a69.

The only actual issue with the original change was a missing change to
the UIApplicationMain SILGen test, which needs to build SILGen
overlays to execute properly; -enable-source-import doesn't suffice.
2016-03-15 15:44:07 -07:00
Doug Gregor
052d2d0a69 Revert "Reinstate [SILGen] Implement NSString -> String bridging through _ObjectiveCBridgeable."
This reverts commit b25019c259. The
builders are failing in ways that are clearly related to my changes
but I'm unable to replicate locally.
2016-03-15 15:00:31 -07:00
Doug Gregor
b25019c259 Reinstate [SILGen] Implement NSString -> String bridging through _ObjectiveCBridgeable.
This reverts commit 01fe7e4848.
2016-03-15 11:38:06 -07:00
Doug Gregor
01fe7e4848 Revert "[SILGen] Implement NSString -> String bridging through _ObjectiveCBridgeable."
This reverts commit aa9cc23743.
2016-03-15 06:52:27 -07:00
Doug Gregor
efede5c1c5 Revert "[SILGen] Enable protocol extension version of _unconditionallyBridgeToObjectiveC"
This reverts commit 16a5e044d9.
2016-03-15 06:51:59 -07:00