You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: test/decl/protocol/conforms/inherited.swift
+5-5Lines changed: 5 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -5,15 +5,15 @@ protocol P1 {
5
5
func f1(_ x:Self?)->Bool
6
6
}
7
7
8
-
// Never inheritable: property with 'Self' in its signature.
8
+
// Inheritable: property with 'Self' in its signature.
9
9
protocolP2{
10
10
varprop2:Self{getset}
11
11
}
12
12
protocolP2a{
13
13
varprop2a:Self{getset}
14
14
}
15
15
16
-
// Never inheritable: subscript with 'Self' in its result type.
16
+
// Inheritable: subscript with 'Self' in its result type.
17
17
protocolP3{
18
18
subscript (i:Int)->Self{get}
19
19
}
@@ -94,7 +94,7 @@ class A : P1, P2, P3, P4, P5, P6, P7, P8, P9, P10 {
94
94
func f1(_ x:A?)->Bool{returntrue}
95
95
96
96
// P2
97
-
varprop2:A{ // expected-error{{protocol 'P2' requirement 'prop2' cannot be satisfied by a non-final class ('A') because it uses 'Self' in a non-parameter, non-result type position}}
97
+
varprop2:A{ // expected-error{{property 'prop2' in non-final class 'A' must specify type 'Self' to conform to protocol 'P2'}}
98
98
get{returnself}
99
99
set{}
100
100
}
@@ -106,7 +106,7 @@ class A : P1, P2, P3, P4, P5, P6, P7, P8, P9, P10 {
106
106
}
107
107
108
108
// P3
109
-
subscript (i:Int)->A{ // expected-error{{protocol 'P3' requirement 'subscript(_:)' cannot be satisfied by a non-final class ('A') because it uses 'Self' in a non-parameter, non-result type position}}
109
+
subscript (i:Int)->A{ // expected-error{{subscript 'subscript(_:)' in non-final class 'A' must return 'Self' to conform to protocol 'P3'}}
110
110
get{
111
111
returnself
112
112
}
@@ -145,7 +145,7 @@ class A : P1, P2, P3, P4, P5, P6, P7, P8, P9, P10 {
145
145
}
146
146
147
147
extensionA:P2a,P5a,P10a{}
148
-
// expected-error@-1 {{protocol 'P2a' requirement 'prop2a' cannot be satisfied by a non-final class ('A') because it uses 'Self' in a non-parameter, non-result type position}}
148
+
// expected-error@-1 {{property 'prop2a' in non-final class 'A' must specify type 'Self' to conform to protocol 'P2a'}}
149
149
// expected-error@-2 {{method 'f5a()' in non-final class 'A' must return 'Self' to conform to protocol 'P5a'}}
150
150
// expected-error@-3 {{protocol 'P10a' requirement 'f10a' cannot be satisfied by a non-final class ('A') because it uses 'Self' in a non-parameter, non-result type position}}
classClass:P{} // expected-error {{method 'returnsSelfTakesT' in non-final class 'Class' cannot be implemented in a protocol extension because it returns 'Self' and has associated type requirements}}
31
+
classClass:P{}
32
+
// expected-error@-1 {{method 'returnsSelfTakesT' in non-final class 'Class' cannot be implemented in a protocol extension because it returns 'Self' and has associated type requirements}}
33
+
// expected-error@-2 {{subscript 'subscript(_:)' in non-final class 'Class' cannot be implemented in a protocol extension because it returns 'Self' and has associated type requirements}}
28
34
29
35
// This succeeds, because the class is final
30
36
finalclassFinalClass:P{}
31
37
32
-
// This succeeds, because we're not using the default implementation
38
+
// This succeeds, because we're not using the default implementations
33
39
classNonFinalClass:P{
40
+
// FIXME: An explicit type witness is necessary to avoid an unrelated
41
+
// associated type inference bug.
42
+
typealiasT=Never
43
+
34
44
func returnsSelfTakesT(_:T)->Self{
35
45
returnself
36
46
}
47
+
48
+
subscript(_:T)->Self{self}
37
49
}
38
50
39
51
// Test for default implementation that comes from a constrained extension
0 commit comments