mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
We haven't been advertising this syntax much, and it's closure form was completely broken anyway, so don't jump through hoops to provide great Fix-Its here. Swift SVN r19277
54 lines
636 B
Swift
54 lines
636 B
Swift
// RUN: %target-run-simple-swift | FileCheck %s
|
|
|
|
protocol Showable {
|
|
func show()
|
|
}
|
|
|
|
extension Int : Showable {
|
|
func show() {
|
|
println(self)
|
|
}
|
|
}
|
|
|
|
/*FIXME crashes irgen
|
|
|
|
func show_slice<T : Showable>(xs: [T]) {
|
|
for x in xs {
|
|
x.show()
|
|
}
|
|
}
|
|
*/
|
|
|
|
var s = [ 6, 0, 2, 2, 1, 4]
|
|
for x in s {
|
|
x.show()
|
|
}
|
|
// CHECK: 6
|
|
// CHECK: 0
|
|
// CHECK: 2
|
|
// CHECK: 2
|
|
// CHECK: 1
|
|
// CHECK: 4
|
|
|
|
for x in [9, 8, 1, 0, 5] {
|
|
x.show()
|
|
}
|
|
// CHECK: 9
|
|
// CHECK: 8
|
|
// CHECK: 1
|
|
// CHECK: 0
|
|
// CHECK: 5
|
|
|
|
func slice_from_varargs(xs: Int...) {
|
|
for x in xs {
|
|
x.show()
|
|
}
|
|
}
|
|
|
|
slice_from_varargs(1,6,1,8)
|
|
// CHECK: 1
|
|
// CHECK: 6
|
|
// CHECK: 1
|
|
// CHECK: 8
|
|
|