Skip to content

Commit 1c99238

Browse files
committed
Test compatibility shim
1 parent 37b0f4e commit 1c99238

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// RUN: %target-typecheck-verify-swift
2+
3+
struct Int64Distance<Element>: Collection {
4+
let _storage: [Element]
5+
6+
typealias Index = Int64
7+
typealias IndexDistance = Int64
8+
9+
var startIndex: Index { return Int64(_storage.startIndex) }
10+
var endIndex: Index { return Int64(_storage.startIndex) }
11+
func index(after i: Index) -> Index { return i + 1 }
12+
13+
subscript(i: Index) -> Element { return _storage[Int(i)] }
14+
}
15+
16+
let c = Int64Distance(_storage: [1,2,3])
17+
18+
let i64: Int64 = 2
19+
_ = c.index(c.startIndex, offsetBy: i64) // expected-warning {{'index(_:offsetBy:)' is deprecated: all index distances are now of type Int}}
20+
21+
let _: Int64 = c.distance(from: c.startIndex, to: c.endIndex) // expected-warning {{distance(from:to:)' is deprecated: all index distances are now of type Int}}
22+

0 commit comments

Comments
 (0)