Skip to content

Commit 1f0a78e

Browse files
authored
Merge pull request #16 from apple/master
merge
2 parents b495847 + 7882a97 commit 1f0a78e

File tree

1,834 files changed

+108462
-84943
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,834 files changed

+108462
-84943
lines changed

CHANGELOG.md

Lines changed: 56 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,48 @@ CHANGELOG
2626
Swift Next
2727
----------
2828

29-
* [SR-8974][]:
29+
* [SE-0253][]:
3030

31-
Duplicate tuple element labels are no longer allowed, because it leads
32-
to incorrect behavior. For example:
31+
Values of types that declare `func callAsFunction` methods can be called
32+
like functions. The call syntax is shorthand for applying
33+
`func callAsFunction` methods.
3334

35+
```swift
36+
struct Adder {
37+
var base: Int
38+
func callAsFunction(_ x: Int) -> Int {
39+
return x + base
40+
}
41+
}
42+
var adder = Adder(base: 3)
43+
adder(10) // returns 13, same as `adder.callAsFunction(10)`
3444
```
35-
let dupLabels: (foo: Int, foo: Int) = (foo: 1, foo: 2)
3645

37-
enum Foo { case bar(x: Int, x: Int) }
38-
let f: Foo = .bar(x: 0, x: 1)
39-
```
46+
* `func callAsFunction` argument labels are required at call sites.
47+
* Multiple `func callAsFunction` methods on a single type are supported.
48+
* `mutating func callAsFunction` is supported.
49+
* `func callAsFunction` works with `throws` and `rethrows`.
50+
* `func callAsFunction` works with trailing closures.
4051

41-
will now be diagnosed as an error.
52+
* [SR-4206][]:
4253

43-
Note: You can still use duplicate labels when declaring functions and
44-
subscripts, as long as the internal labels are different. For example:
54+
A method override is no longer allowed to have a generic signature with
55+
requirements not imposed by the base method. For example:
4556

4657
```
47-
func foo(bar x: Int, bar y: Int) {}
48-
subscript(a x: Int, a y: Int) -> Int {}
58+
protocol P {}
59+
60+
class Base {
61+
func foo<T>(arg: T) {}
62+
}
63+
64+
class Derived: Base {
65+
override func foo<T: P>(arg: T) {}
66+
}
4967
```
5068

69+
will now be diagnosed as an error.
70+
5171
* [SR-6118][]:
5272

5373
Subscripts can now declare default arguments:
@@ -68,6 +88,28 @@ Swift Next
6888
Swift 5.1
6989
---------
7090

91+
* [SR-8974][]:
92+
93+
Duplicate tuple element labels are no longer allowed, because it leads
94+
to incorrect behavior. For example:
95+
96+
```
97+
let dupLabels: (foo: Int, foo: Int) = (foo: 1, foo: 2)
98+
99+
enum Foo { case bar(x: Int, x: Int) }
100+
let f: Foo = .bar(x: 0, x: 1)
101+
```
102+
103+
will now be diagnosed as an error.
104+
105+
Note: You can still use duplicate argument labels when declaring functions and
106+
subscripts, as long as the internal parameter names are different. For example:
107+
108+
```
109+
func foo(bar x: Int, bar y: Int) {}
110+
subscript(a x: Int, a y: Int) -> Int {}
111+
```
112+
71113
* [SE-0244][]:
72114

73115
Functions can now hide their concrete return type by declaring what protocols
@@ -7692,6 +7734,7 @@ Swift 1.0
76927734
[SE-0244]: <https://github.com/apple/swift-evolution/blob/master/proposals/0244-opaque-result-types.md>
76937735
[SE-0245]: <https://github.com/apple/swift-evolution/blob/master/proposals/0245-array-uninitialized-initializer.md>
76947736
[SE-0252]: <https://github.com/apple/swift-evolution/blob/master/proposals/0252-keypath-dynamic-member-lookup.md>
7737+
[SE-0253]: <https://github.com/apple/swift-evolution/blob/master/proposals/0253-callable.md>
76957738
[SE-0254]: <https://github.com/apple/swift-evolution/blob/master/proposals/0254-static-subscripts.md>
76967739

76977740
[SR-106]: <https://bugs.swift.org/browse/SR-106>
@@ -7708,6 +7751,7 @@ Swift 1.0
77087751
[SR-2608]: <https://bugs.swift.org/browse/SR-2608>
77097752
[SR-2672]: <https://bugs.swift.org/browse/SR-2672>
77107753
[SR-2688]: <https://bugs.swift.org/browse/SR-2688>
7754+
[SR-4206]: <https://bugs.swift.org/browse/SR-4206>
77117755
[SR-4248]: <https://bugs.swift.org/browse/SR-4248>
77127756
[SR-5581]: <https://bugs.swift.org/browse/SR-5581>
77137757
[SR-5719]: <https://bugs.swift.org/browse/SR-5719>

CMakeLists.txt

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ option(SWIFT_BUILD_STATIC_SDK_OVERLAY
6161
"Build static variants of the Swift SDK overlay"
6262
FALSE)
6363

64+
option(SWIFT_BUILD_STDLIB_EXTRA_TOOLCHAIN_CONTENT
65+
"If not building stdlib, controls whether to build 'stdlib/toolchain' content"
66+
TRUE)
67+
6468
# In many cases, the CMake build system needs to determine whether to include
6569
# a directory, or perform other actions, based on whether the stdlib or SDK is
6670
# being built at all -- statically or dynamically. Please note that these
@@ -446,7 +450,7 @@ if(MSVC OR "${CMAKE_SIMULATE_ID}" STREQUAL MSVC)
446450
endif()
447451

448452
if(CMAKE_SYSTEM_NAME STREQUAL Darwin OR
449-
EXISTS ${SWIFT_PATH_TO_LIBDISPATCH_SOURCE})
453+
EXISTS "${SWIFT_PATH_TO_LIBDISPATCH_SOURCE}")
450454
set(SWIFT_BUILD_SYNTAXPARSERLIB_default TRUE)
451455
set(SWIFT_BUILD_SOURCEKIT_default TRUE)
452456
else()
@@ -495,6 +499,18 @@ include(CMakePushCheckState)
495499

496500
print_versions()
497501

502+
include(SwiftSharedCMakeConfig)
503+
504+
# NOTE: We include this before SwiftComponents as it relies on some LLVM CMake
505+
# functionality.
506+
# Support building Swift as a standalone project, using LLVM as an
507+
# external library.
508+
if(SWIFT_BUILT_STANDALONE)
509+
swift_common_standalone_build_config(SWIFT)
510+
else()
511+
swift_common_unified_build_config(SWIFT)
512+
endif()
513+
498514
include(SwiftComponents)
499515
include(SwiftHandleGybSources)
500516
include(SwiftSetIfArchBitness)
@@ -523,16 +539,6 @@ if(NOT CMAKE_CROSSCOMPILING AND CMAKE_SYSTEM_PROCESSOR STREQUAL "i386")
523539
OUTPUT_STRIP_TRAILING_WHITESPACE)
524540
endif()
525541

526-
include(SwiftSharedCMakeConfig)
527-
528-
# Support building Swift as a standalone project, using LLVM as an
529-
# external library.
530-
if(SWIFT_BUILT_STANDALONE)
531-
swift_common_standalone_build_config(SWIFT)
532-
else()
533-
swift_common_unified_build_config(SWIFT)
534-
endif()
535-
536542
get_filename_component(SWIFT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} REALPATH)
537543
set(SWIFT_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
538544
set(SWIFT_CMAKE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
@@ -599,7 +605,13 @@ if(SWIFT_HOST_VARIANT_SDK)
599605
set(SWIFT_HOST_VARIANT_SDK_default "${SWIFT_HOST_VARIANT_SDK}")
600606
else()
601607
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
602-
set(SWIFT_HOST_VARIANT_SDK_default "LINUX")
608+
# CMake on an Android host sets this to Linux, so check for the ANDROID_DATA
609+
# environment variable to see if we're building on Android.
610+
if(NOT "$ENV{ANDROID_DATA}" STREQUAL "")
611+
set(SWIFT_HOST_VARIANT_SDK_default "ANDROID")
612+
else()
613+
set(SWIFT_HOST_VARIANT_SDK_default "LINUX")
614+
endif()
603615
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD")
604616
set(SWIFT_HOST_VARIANT_SDK_default "FREEBSD")
605617
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "CYGWIN")
@@ -609,6 +621,7 @@ else()
609621
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Haiku")
610622
set(SWIFT_HOST_VARIANT_SDK_default "HAIKU")
611623
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Android")
624+
# CMAKE_SYSTEM_NAME might be set this way when cross-compiling to Android.
612625
set(SWIFT_HOST_VARIANT_SDK_default "ANDROID")
613626
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
614627
set(SWIFT_HOST_VARIANT_SDK_default "OSX")
@@ -673,7 +686,7 @@ endif()
673686

674687
# FIXME: the parameters we specify in SWIFT_SDKS are lacking architecture specifics,
675688
# so we need to hard-code it. For example, the SDK for Android is just 'ANDROID',
676-
# which we assume below to be armv7.
689+
# and we have to specify SWIFT_SDK_ANDROID_ARCHITECTURES separately.
677690
# The iOS SDKs all have their architectures hardcoded because they are just specified by name (e.g. 'IOS' or 'WATCHOS').
678691
# We can't cross-compile the standard library for another linux architecture,
679692
# because the SDK list would just be 'LINUX' and we couldn't disambiguate it from the host.
@@ -735,9 +748,16 @@ elseif("${SWIFT_HOST_VARIANT_SDK}" STREQUAL "HAIKU")
735748
elseif("${SWIFT_HOST_VARIANT_SDK}" STREQUAL "ANDROID")
736749

737750
set(SWIFT_HOST_VARIANT "android" CACHE STRING
738-
"Deployment OS for Swift host tools (the compiler) [android].")
751+
"Deployment OS for Swift host tools (the compiler) [android]")
752+
753+
set(SWIFT_ANDROID_NATIVE_SYSROOT "/data/data/com.termux/files" CACHE STRING
754+
"Path to Android sysroot, default initialized to the Termux app's layout")
739755

740-
configure_sdk_unix("Android" "${SWIFT_HOST_VARIANT_ARCH}")
756+
if("${SWIFT_SDK_ANDROID_ARCHITECTURES}" STREQUAL "")
757+
set(SWIFT_SDK_ANDROID_ARCHITECTURES ${SWIFT_HOST_VARIANT_ARCH})
758+
endif()
759+
760+
configure_sdk_unix("Android" "${SWIFT_SDK_ANDROID_ARCHITECTURES}")
741761
set(SWIFT_PRIMARY_VARIANT_SDK_default "${SWIFT_HOST_VARIANT_SDK}")
742762
set(SWIFT_PRIMARY_VARIANT_ARCH_default "${SWIFT_HOST_VARIANT_ARCH}")
743763

@@ -1033,6 +1053,7 @@ if(SWIFT_NEED_EXPLICIT_LIBDISPATCH)
10331053
else()
10341054
set(SOURCEKIT_RUNTIME_DIR lib)
10351055
endif()
1056+
add_dependencies(sourcekit-inproc BlocksRuntime dispatch)
10361057
swift_install_in_component(FILES
10371058
$<TARGET_FILE:dispatch>
10381059
$<TARGET_FILE:BlocksRuntime>
@@ -1065,8 +1086,7 @@ endif()
10651086
#
10661087
# We must include stdlib/ before tools/ because stdlib/CMakeLists.txt
10671088
# declares the swift-stdlib-* set of targets. These targets will then
1068-
# implicitly depend on any targets declared with IS_STDLIB or
1069-
# TARGET_LIBRARY.
1089+
# implicitly depend on any targets declared with IS_STDLIB.
10701090
#
10711091
# One such library that declares IS_STDLIB is SwiftSyntax, living in
10721092
# tools/SwiftSyntax. If we include stdlib/ after tools/,
@@ -1078,7 +1098,9 @@ endif()
10781098
if(SWIFT_BUILD_STDLIB)
10791099
add_subdirectory(stdlib)
10801100
else()
1081-
add_subdirectory(stdlib/public/legacy_layouts)
1101+
if(SWIFT_BUILD_STDLIB_EXTRA_TOOLCHAIN_CONTENT)
1102+
add_subdirectory(stdlib/toolchain)
1103+
endif()
10821104

10831105
# Some tools (e.g. swift-reflection-dump) rely on a host swiftReflection, so
10841106
# ensure we build that when building tools.

README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,17 @@ modules, eliminating the need for headers and the code duplication they entail.
4242

4343
To learn more about the programming language, visit [swift.org](https://swift.org/documentation/).
4444

45+
- [Contributing to Swift](#contributing-to-swift)
46+
- [Getting Started](#getting-started)
47+
- [System Requirements](#system-requirements)
48+
- [Getting Sources for Swift and Related Projects](#getting-sources-for-swift-and-related-projects)
49+
- [Building Swift](#building-swift)
50+
- [Swift Toolchains](#swift-toolchains)
51+
- [Build Failures](#build-failures)
52+
- [Testing Swift](#testing-swift)
53+
- [Learning More](#learning-more)
54+
- [Build Dependencies](#build-dependencies)
55+
4556
## Contributing to Swift
4657

4758
Contributions to Swift are welcomed and encouraged! Please see the
@@ -76,7 +87,7 @@ Please make sure you use Python 2.x. Python 3.x is not supported currently.
7687

7788
#### macOS
7889

79-
To build for macOS, you need [Xcode 11 beta](https://developer.apple.com/xcode/downloads/).
90+
To build for macOS, you need [Xcode 11 beta 6](https://developer.apple.com/xcode/downloads/).
8091
The required version of Xcode changes frequently, and is often a beta release.
8192
Check this document or the host information on <https://ci.swift.org> for the
8293
current required version.

apinotes/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ add_custom_target("copy_apinotes" ALL
2626
COMMENT "Copying API notes to ${output_dir}"
2727
SOURCES "${sources}")
2828

29+
add_dependencies(compiler copy_apinotes)
2930
swift_install_in_component(DIRECTORY "${output_dir}"
3031
DESTINATION "lib/swift/"
3132
COMPONENT compiler)

benchmark/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,15 @@ set(SWIFT_BENCH_MODULES
7979
single-source/DictionarySubscriptDefault
8080
single-source/DictionarySwap
8181
single-source/Diffing
82+
single-source/DiffingMyers
8283
single-source/DropFirst
8384
single-source/DropLast
8485
single-source/DropWhile
8586
single-source/ErrorHandling
8687
single-source/Exclusivity
8788
single-source/ExistentialPerformance
8889
single-source/Fibonacci
90+
single-source/FindStringNaive
8991
single-source/FlattenList
9092
single-source/FloatingPointParsing
9193
single-source/FloatingPointPrinting
@@ -105,7 +107,6 @@ set(SWIFT_BENCH_MODULES
105107
single-source/Memset
106108
single-source/MonteCarloE
107109
single-source/MonteCarloPi
108-
single-source/Myers
109110
single-source/NSDictionaryCastToSwift
110111
single-source/NSError
111112
single-source/NSStringConversion
@@ -130,6 +131,7 @@ set(SWIFT_BENCH_MODULES
130131
single-source/Prefix
131132
single-source/PrefixWhile
132133
single-source/Prims
134+
single-source/PrimsNonStrongRef
133135
single-source/ProtocolDispatch
134136
single-source/ProtocolDispatch2
135137
single-source/Queue
@@ -151,6 +153,7 @@ set(SWIFT_BENCH_MODULES
151153
single-source/SetTests
152154
single-source/SevenBoom
153155
single-source/Sim2DArray
156+
single-source/SortArrayInClass
154157
single-source/SortIntPyramids
155158
single-source/SortLargeExistentials
156159
single-source/SortLettersInPlace
@@ -166,6 +169,7 @@ set(SWIFT_BENCH_MODULES
166169
single-source/StringInterpolation
167170
single-source/StringMatch
168171
single-source/StringRemoveDupes
172+
single-source/StringReplaceSubrange
169173
single-source/StringTests
170174
single-source/StringWalk
171175
single-source/Substring

0 commit comments

Comments
 (0)