Skip to content

Commit

Permalink
Merge pull request #16 from apple/master
Browse files Browse the repository at this point in the history
merge
  • Loading branch information
JacobMao authored Sep 12, 2019
2 parents b495847 + 7882a97 commit 1f0a78e
Show file tree
Hide file tree
Showing 1,834 changed files with 108,462 additions and 84,943 deletions.
68 changes: 56 additions & 12 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,48 @@ CHANGELOG
Swift Next
----------

* [SR-8974][]:
* [SE-0253][]:

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

```swift
struct Adder {
var base: Int
func callAsFunction(_ x: Int) -> Int {
return x + base
}
}
var adder = Adder(base: 3)
adder(10) // returns 13, same as `adder.callAsFunction(10)`
```
let dupLabels: (foo: Int, foo: Int) = (foo: 1, foo: 2)

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

will now be diagnosed as an error.
* [SR-4206][]:

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

```
func foo(bar x: Int, bar y: Int) {}
subscript(a x: Int, a y: Int) -> Int {}
protocol P {}
class Base {
func foo<T>(arg: T) {}
}
class Derived: Base {
override func foo<T: P>(arg: T) {}
}
```

will now be diagnosed as an error.

* [SR-6118][]:

Subscripts can now declare default arguments:
Expand All @@ -68,6 +88,28 @@ Swift Next
Swift 5.1
---------

* [SR-8974][]:

Duplicate tuple element labels are no longer allowed, because it leads
to incorrect behavior. For example:

```
let dupLabels: (foo: Int, foo: Int) = (foo: 1, foo: 2)
enum Foo { case bar(x: Int, x: Int) }
let f: Foo = .bar(x: 0, x: 1)
```

will now be diagnosed as an error.

Note: You can still use duplicate argument labels when declaring functions and
subscripts, as long as the internal parameter names are different. For example:

```
func foo(bar x: Int, bar y: Int) {}
subscript(a x: Int, a y: Int) -> Int {}
```

* [SE-0244][]:

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

[SR-106]: <https://bugs.swift.org/browse/SR-106>
Expand All @@ -7708,6 +7751,7 @@ Swift 1.0
[SR-2608]: <https://bugs.swift.org/browse/SR-2608>
[SR-2672]: <https://bugs.swift.org/browse/SR-2672>
[SR-2688]: <https://bugs.swift.org/browse/SR-2688>
[SR-4206]: <https://bugs.swift.org/browse/SR-4206>
[SR-4248]: <https://bugs.swift.org/browse/SR-4248>
[SR-5581]: <https://bugs.swift.org/browse/SR-5581>
[SR-5719]: <https://bugs.swift.org/browse/SR-5719>
Expand Down
58 changes: 40 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ option(SWIFT_BUILD_STATIC_SDK_OVERLAY
"Build static variants of the Swift SDK overlay"
FALSE)

option(SWIFT_BUILD_STDLIB_EXTRA_TOOLCHAIN_CONTENT
"If not building stdlib, controls whether to build 'stdlib/toolchain' content"
TRUE)

# In many cases, the CMake build system needs to determine whether to include
# a directory, or perform other actions, based on whether the stdlib or SDK is
# being built at all -- statically or dynamically. Please note that these
Expand Down Expand Up @@ -446,7 +450,7 @@ if(MSVC OR "${CMAKE_SIMULATE_ID}" STREQUAL MSVC)
endif()

if(CMAKE_SYSTEM_NAME STREQUAL Darwin OR
EXISTS ${SWIFT_PATH_TO_LIBDISPATCH_SOURCE})
EXISTS "${SWIFT_PATH_TO_LIBDISPATCH_SOURCE}")
set(SWIFT_BUILD_SYNTAXPARSERLIB_default TRUE)
set(SWIFT_BUILD_SOURCEKIT_default TRUE)
else()
Expand Down Expand Up @@ -495,6 +499,18 @@ include(CMakePushCheckState)

print_versions()

include(SwiftSharedCMakeConfig)

# NOTE: We include this before SwiftComponents as it relies on some LLVM CMake
# functionality.
# Support building Swift as a standalone project, using LLVM as an
# external library.
if(SWIFT_BUILT_STANDALONE)
swift_common_standalone_build_config(SWIFT)
else()
swift_common_unified_build_config(SWIFT)
endif()

include(SwiftComponents)
include(SwiftHandleGybSources)
include(SwiftSetIfArchBitness)
Expand Down Expand Up @@ -523,16 +539,6 @@ if(NOT CMAKE_CROSSCOMPILING AND CMAKE_SYSTEM_PROCESSOR STREQUAL "i386")
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()

include(SwiftSharedCMakeConfig)

# Support building Swift as a standalone project, using LLVM as an
# external library.
if(SWIFT_BUILT_STANDALONE)
swift_common_standalone_build_config(SWIFT)
else()
swift_common_unified_build_config(SWIFT)
endif()

get_filename_component(SWIFT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} REALPATH)
set(SWIFT_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
set(SWIFT_CMAKE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
Expand Down Expand Up @@ -599,7 +605,13 @@ if(SWIFT_HOST_VARIANT_SDK)
set(SWIFT_HOST_VARIANT_SDK_default "${SWIFT_HOST_VARIANT_SDK}")
else()
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
set(SWIFT_HOST_VARIANT_SDK_default "LINUX")
# CMake on an Android host sets this to Linux, so check for the ANDROID_DATA
# environment variable to see if we're building on Android.
if(NOT "$ENV{ANDROID_DATA}" STREQUAL "")
set(SWIFT_HOST_VARIANT_SDK_default "ANDROID")
else()
set(SWIFT_HOST_VARIANT_SDK_default "LINUX")
endif()
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD")
set(SWIFT_HOST_VARIANT_SDK_default "FREEBSD")
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "CYGWIN")
Expand All @@ -609,6 +621,7 @@ else()
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Haiku")
set(SWIFT_HOST_VARIANT_SDK_default "HAIKU")
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Android")
# CMAKE_SYSTEM_NAME might be set this way when cross-compiling to Android.
set(SWIFT_HOST_VARIANT_SDK_default "ANDROID")
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
set(SWIFT_HOST_VARIANT_SDK_default "OSX")
Expand Down Expand Up @@ -673,7 +686,7 @@ endif()

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

set(SWIFT_HOST_VARIANT "android" CACHE STRING
"Deployment OS for Swift host tools (the compiler) [android].")
"Deployment OS for Swift host tools (the compiler) [android]")

set(SWIFT_ANDROID_NATIVE_SYSROOT "/data/data/com.termux/files" CACHE STRING
"Path to Android sysroot, default initialized to the Termux app's layout")

configure_sdk_unix("Android" "${SWIFT_HOST_VARIANT_ARCH}")
if("${SWIFT_SDK_ANDROID_ARCHITECTURES}" STREQUAL "")
set(SWIFT_SDK_ANDROID_ARCHITECTURES ${SWIFT_HOST_VARIANT_ARCH})
endif()

configure_sdk_unix("Android" "${SWIFT_SDK_ANDROID_ARCHITECTURES}")
set(SWIFT_PRIMARY_VARIANT_SDK_default "${SWIFT_HOST_VARIANT_SDK}")
set(SWIFT_PRIMARY_VARIANT_ARCH_default "${SWIFT_HOST_VARIANT_ARCH}")

Expand Down Expand Up @@ -1033,6 +1053,7 @@ if(SWIFT_NEED_EXPLICIT_LIBDISPATCH)
else()
set(SOURCEKIT_RUNTIME_DIR lib)
endif()
add_dependencies(sourcekit-inproc BlocksRuntime dispatch)
swift_install_in_component(FILES
$<TARGET_FILE:dispatch>
$<TARGET_FILE:BlocksRuntime>
Expand Down Expand Up @@ -1065,8 +1086,7 @@ endif()
#
# We must include stdlib/ before tools/ because stdlib/CMakeLists.txt
# declares the swift-stdlib-* set of targets. These targets will then
# implicitly depend on any targets declared with IS_STDLIB or
# TARGET_LIBRARY.
# implicitly depend on any targets declared with IS_STDLIB.
#
# One such library that declares IS_STDLIB is SwiftSyntax, living in
# tools/SwiftSyntax. If we include stdlib/ after tools/,
Expand All @@ -1078,7 +1098,9 @@ endif()
if(SWIFT_BUILD_STDLIB)
add_subdirectory(stdlib)
else()
add_subdirectory(stdlib/public/legacy_layouts)
if(SWIFT_BUILD_STDLIB_EXTRA_TOOLCHAIN_CONTENT)
add_subdirectory(stdlib/toolchain)
endif()

# Some tools (e.g. swift-reflection-dump) rely on a host swiftReflection, so
# ensure we build that when building tools.
Expand Down
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,17 @@ modules, eliminating the need for headers and the code duplication they entail.

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

- [Contributing to Swift](#contributing-to-swift)
- [Getting Started](#getting-started)
- [System Requirements](#system-requirements)
- [Getting Sources for Swift and Related Projects](#getting-sources-for-swift-and-related-projects)
- [Building Swift](#building-swift)
- [Swift Toolchains](#swift-toolchains)
- [Build Failures](#build-failures)
- [Testing Swift](#testing-swift)
- [Learning More](#learning-more)
- [Build Dependencies](#build-dependencies)

## Contributing to Swift

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

#### macOS

To build for macOS, you need [Xcode 11 beta](https://developer.apple.com/xcode/downloads/).
To build for macOS, you need [Xcode 11 beta 6](https://developer.apple.com/xcode/downloads/).
The required version of Xcode changes frequently, and is often a beta release.
Check this document or the host information on <https://ci.swift.org> for the
current required version.
Expand Down
1 change: 1 addition & 0 deletions apinotes/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ add_custom_target("copy_apinotes" ALL
COMMENT "Copying API notes to ${output_dir}"
SOURCES "${sources}")

add_dependencies(compiler copy_apinotes)
swift_install_in_component(DIRECTORY "${output_dir}"
DESTINATION "lib/swift/"
COMPONENT compiler)
6 changes: 5 additions & 1 deletion benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,15 @@ set(SWIFT_BENCH_MODULES
single-source/DictionarySubscriptDefault
single-source/DictionarySwap
single-source/Diffing
single-source/DiffingMyers
single-source/DropFirst
single-source/DropLast
single-source/DropWhile
single-source/ErrorHandling
single-source/Exclusivity
single-source/ExistentialPerformance
single-source/Fibonacci
single-source/FindStringNaive
single-source/FlattenList
single-source/FloatingPointParsing
single-source/FloatingPointPrinting
Expand All @@ -105,7 +107,6 @@ set(SWIFT_BENCH_MODULES
single-source/Memset
single-source/MonteCarloE
single-source/MonteCarloPi
single-source/Myers
single-source/NSDictionaryCastToSwift
single-source/NSError
single-source/NSStringConversion
Expand All @@ -130,6 +131,7 @@ set(SWIFT_BENCH_MODULES
single-source/Prefix
single-source/PrefixWhile
single-source/Prims
single-source/PrimsNonStrongRef
single-source/ProtocolDispatch
single-source/ProtocolDispatch2
single-source/Queue
Expand All @@ -151,6 +153,7 @@ set(SWIFT_BENCH_MODULES
single-source/SetTests
single-source/SevenBoom
single-source/Sim2DArray
single-source/SortArrayInClass
single-source/SortIntPyramids
single-source/SortLargeExistentials
single-source/SortLettersInPlace
Expand All @@ -166,6 +169,7 @@ set(SWIFT_BENCH_MODULES
single-source/StringInterpolation
single-source/StringMatch
single-source/StringRemoveDupes
single-source/StringReplaceSubrange
single-source/StringTests
single-source/StringWalk
single-source/Substring
Expand Down
Loading

0 comments on commit 1f0a78e

Please sign in to comment.