mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
The rule changes are as follows: * All functions (introduced with the 'func' keyword) have argument labels for arguments beyond the first, by default. Methods are no longer special in this regard. * The presence of a default argument no longer implies an argument label. The actual changes to the parser and printer are fairly simple; the rest of the noise is updating the standard library, overlays, tests, etc. With the standard library, this change is intended to be API neutral: I've added/removed #'s and _'s as appropriate to keep the user interface the same. If we want to separately consider using argument labels for more free functions now that the defaults in the language have shifted, we can tackle that separately. Fixes rdar://problem/17218256. Swift SVN r27704
67 lines
1.3 KiB
Swift
67 lines
1.3 KiB
Swift
public func getZero() -> Int {
|
|
return 0
|
|
}
|
|
|
|
public func getInput(#x: Int) -> Int {
|
|
return x
|
|
}
|
|
|
|
public func getSecond(Int, y: Int) -> Int {
|
|
return y
|
|
}
|
|
|
|
public func useNested((x: Int, y: Int), n: Int) {}
|
|
|
|
public func variadic(#x: Double, _ y: Int...) {}
|
|
|
|
public func slice(#x: [Int]) {}
|
|
public func optional(#x: Int?) {}
|
|
|
|
public func overloaded(#x: Int) {}
|
|
public func overloaded(#x: Bool) {}
|
|
|
|
// Generic functions.
|
|
public func makePair<A, B>(#a: A, b: B) -> (A, B) {
|
|
return (a, b)
|
|
}
|
|
|
|
public func different<T : Equatable>(#a: T, b: T) -> Bool {
|
|
return a != b
|
|
}
|
|
|
|
public func different2<T where T : Equatable>(#a: T, b: T) -> Bool {
|
|
return a != b
|
|
}
|
|
|
|
public func selectorFunc1(#a: Int, b x: Int) {}
|
|
|
|
public protocol Wrapped {
|
|
typealias Value : Equatable
|
|
|
|
//var value : Value
|
|
func getValue() -> Value
|
|
}
|
|
|
|
public func differentWrapped<
|
|
T : Wrapped, U : Wrapped
|
|
where
|
|
T.Value == U.Value
|
|
>(#a: T, b: U) -> Bool {
|
|
return a.getValue() != b.getValue()
|
|
}
|
|
|
|
@noreturn @asmname("exit") public func exit ()->()
|
|
|
|
@noreturn public func testNoReturnAttr() -> () { exit() }
|
|
@noreturn public func testNoReturnAttrPoly<T>(#x: T) -> () { exit() }
|
|
|
|
|
|
@asmname("primitive") public func primitive()
|
|
|
|
public protocol EqualOperator {
|
|
func ==(x: Self, y: Self) -> Bool
|
|
}
|
|
|
|
public func throws1() throws {}
|
|
public func throws2<T>(t: T) throws -> T { return t }
|