File tree 2 files changed +24
-4
lines changed
2 files changed +24
-4
lines changed Original file line number Diff line number Diff line change @@ -1336,13 +1336,13 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
1336
1336
}
1337
1337
1338
1338
if (VD->getDeclContext ()->getSelfClassDecl ()) {
1339
- checkDynamicSelfType (VD, VD->getValueInterfaceType ());
1340
-
1341
1339
if (VD->getValueInterfaceType ()->hasDynamicSelfType ()) {
1342
1340
if (VD->hasStorage ())
1343
1341
VD->diagnose (diag::dynamic_self_in_stored_property);
1344
1342
else if (VD->isSettable (nullptr ))
1345
1343
VD->diagnose (diag::dynamic_self_in_mutable_property);
1344
+ else
1345
+ checkDynamicSelfType (VD, VD->getValueInterfaceType ());
1346
1346
}
1347
1347
}
1348
1348
@@ -2153,8 +2153,11 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
2153
2153
2154
2154
checkExplicitAvailability (FD);
2155
2155
2156
- if (FD->getDeclContext ()->getSelfClassDecl ())
2157
- checkDynamicSelfType (FD, FD->getResultInterfaceType ());
2156
+ // Skip this for accessors, since we should have diagnosed the
2157
+ // storage itself.
2158
+ if (!isa<AccessorDecl>(FD))
2159
+ if (FD->getDeclContext ()->getSelfClassDecl ())
2160
+ checkDynamicSelfType (FD, FD->getResultInterfaceType ());
2158
2161
2159
2162
checkDefaultArguments (FD->getParameters ());
2160
2163
Original file line number Diff line number Diff line change @@ -270,3 +270,20 @@ class Foo {
270
270
Self . value * 2
271
271
} ( )
272
272
}
273
+
274
+ // https://bugs.swift.org/browse/SR-11681 - duplicate diagnostics
275
+ struct Box < T> {
276
+ let boxed : T
277
+ }
278
+
279
+ class Boxer {
280
+ lazy var s = Box < Self > ( boxed: self as! Self )
281
+ // expected-error@-1 {{stored property cannot have covariant 'Self' type}}
282
+ // expected-error@-2 {{mutable property cannot have covariant 'Self' type}}
283
+
284
+ var t = Box < Self > ( boxed: Self ( ) )
285
+ // expected-error@-1 {{stored property cannot have covariant 'Self' type}}
286
+ // expected-error@-2 {{covariant 'Self' type cannot be referenced from a stored property initializer}}
287
+
288
+ required init ( ) { }
289
+ }
You can’t perform that action at this time.
0 commit comments