File tree Expand file tree Collapse file tree 1 file changed +54
-0
lines changed Expand file tree Collapse file tree 1 file changed +54
-0
lines changed Original file line number Diff line number Diff line change
1
+ // RUN: %target-typecheck-verify-swift -enable-experimental-associated-type-inference
2
+ // RUN: not %target-typecheck-verify-swift
3
+
4
+ public protocol FakeCopyable { }
5
+
6
+ extension Int : FakeCopyable { }
7
+
8
+ // Remove both 'FakeCopyable' requirements below and
9
+ // inference for Element in Hello succeeds.
10
+
11
+ public protocol MyIteratorProtocol < Element> {
12
+ associatedtype Element : FakeCopyable
13
+
14
+ mutating func next( ) -> Element ?
15
+ }
16
+
17
+ public protocol MySequence < Element> {
18
+ associatedtype Element : FakeCopyable
19
+
20
+ associatedtype Iterator : MyIteratorProtocol where Iterator. Element == Element
21
+
22
+ __consuming func makeIterator( ) -> Iterator
23
+
24
+ func _customContainsEquatableElement(
25
+ _ element: Element
26
+ ) -> Bool ?
27
+ }
28
+
29
+ extension MySequence {
30
+ @usableFromInline
31
+ func _customContainsEquatableElement(
32
+ _ element: Iterator . Element
33
+ ) -> Bool ? { return nil }
34
+ }
35
+
36
+ extension MySequence where Self. Iterator == Self {
37
+ @inlinable
38
+ public __consuming func makeIterator( ) -> Self {
39
+ return self
40
+ }
41
+ }
42
+
43
+ // ------------
44
+
45
+ internal struct Hello { }
46
+
47
+ extension Hello : MySequence , MyIteratorProtocol {
48
+ // Inferred:
49
+ // typealias Element = Int
50
+
51
+ internal mutating func next( ) -> Int ? {
52
+ return nil
53
+ }
54
+ }
You can’t perform that action at this time.
0 commit comments