-
Notifications
You must be signed in to change notification settings - Fork 10.5k
/
Copy pathrdar118998138.swift
53 lines (38 loc) · 1.07 KB
/
rdar118998138.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// RUN: %target-typecheck-verify-swift
public protocol FakeCopyable {}
extension Int: FakeCopyable {}
// Remove both 'FakeCopyable' requirements below and
// inference for Element in Hello succeeds.
public protocol MyIteratorProtocol<Element> {
associatedtype Element : FakeCopyable
mutating func next() -> Element?
}
public protocol MySequence<Element> {
associatedtype Element : FakeCopyable
associatedtype Iterator: MyIteratorProtocol where Iterator.Element == Element
__consuming func makeIterator() -> Iterator
func _customContainsEquatableElement(
_ element: Element
) -> Bool?
}
extension MySequence {
@usableFromInline
func _customContainsEquatableElement(
_ element: Iterator.Element
) -> Bool? { return nil }
}
extension MySequence where Self.Iterator == Self {
@inlinable
public __consuming func makeIterator() -> Self {
return self
}
}
// ------------
internal struct Hello {}
extension Hello: MySequence, MyIteratorProtocol {
// Inferred:
// typealias Element = Int
internal mutating func next() -> Int? {
return nil
}
}