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
45 lines
892 B
Swift
45 lines
892 B
Swift
// RUN: %target-parse-verify-swift
|
|
|
|
func acceptInt(inout _ : Int) {}
|
|
func acceptDouble(inout _ : Double) {}
|
|
|
|
var i1 = 1
|
|
acceptInt(&i1)
|
|
var i2 = 1 + 2.0 + 1
|
|
acceptDouble(&i2)
|
|
|
|
|
|
func ternary<T>(cond: Bool,
|
|
@autoclosure _ ifTrue: () -> T,
|
|
@autoclosure _ ifFalse: () -> T) -> T {}
|
|
ternary(false, 1, 2.5)
|
|
ternary(false, 2.5, 1)
|
|
|
|
// <rdar://problem/18447543>
|
|
ternary(false, 1, 2 as Int32)
|
|
ternary(false, 1, 2 as Float)
|
|
|
|
func genericFloatingLiteral<T : FloatLiteralConvertible>(x: T) {
|
|
var x2 : T = 2.5
|
|
}
|
|
|
|
var d = 3.5
|
|
genericFloatingLiteral(d)
|
|
|
|
extension UInt32 {
|
|
func asChar() -> UnicodeScalar { return UnicodeScalar(self) }
|
|
}
|
|
var ch = UInt32(65).asChar()
|
|
|
|
// <rdar://problem/14634379>
|
|
extension Int {
|
|
func call0() {}
|
|
typealias Signature = (a: String, b: String)
|
|
func call(x: Signature) {}
|
|
}
|
|
|
|
3.call((a: "foo", b: "bar"))
|
|
|
|
|
|
var (div, mod) = (9 / 4, 9 % 4)
|