File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -151,3 +151,27 @@ enum E {
151
151
return . e
152
152
}
153
153
}
154
+
155
+ class A1 {
156
+ required init ( ) { }
157
+ func copy( ) -> Self {
158
+ let copy = Self . init ( )
159
+ return copy
160
+ }
161
+
162
+ var copied : Self { // expected-error {{'Self' is only available in a protocol or as the result of a method in a class; did you mean 'A1'?}}
163
+ let copy = Self . init ( )
164
+ return copy
165
+ }
166
+ }
167
+
168
+ class B1 : A1 {
169
+ override func copy( ) -> Self {
170
+ let copy = super. copy ( ) as! Self // supported
171
+ return copy
172
+ }
173
+ override var copied : Self { // expected-error {{'Self' is only available in a protocol or as the result of a method in a class; did you mean 'B1'?}}
174
+ let copy = super. copied as! Self // unsupported
175
+ return copy
176
+ }
177
+ }
You can’t perform that action at this time.
0 commit comments