File tree Expand file tree Collapse file tree 2 files changed +24
-4
lines changed Expand file tree Collapse file tree 2 files changed +24
-4
lines changed Original file line number Diff line number Diff line change @@ -1283,13 +1283,13 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
1283
1283
}
1284
1284
1285
1285
if (VD->getDeclContext ()->getSelfClassDecl ()) {
1286
- checkDynamicSelfType (VD, VD->getValueInterfaceType ());
1287
-
1288
1286
if (VD->getValueInterfaceType ()->hasDynamicSelfType ()) {
1289
1287
if (VD->hasStorage ())
1290
1288
VD->diagnose (diag::dynamic_self_in_stored_property);
1291
1289
else if (VD->isSettable (nullptr ))
1292
1290
VD->diagnose (diag::dynamic_self_in_mutable_property);
1291
+ else
1292
+ checkDynamicSelfType (VD, VD->getValueInterfaceType ());
1293
1293
}
1294
1294
}
1295
1295
@@ -2098,8 +2098,11 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
2098
2098
2099
2099
checkExplicitAvailability (FD);
2100
2100
2101
- if (FD->getDeclContext ()->getSelfClassDecl ())
2102
- checkDynamicSelfType (FD, FD->getResultInterfaceType ());
2101
+ // Skip this for accessors, since we should have diagnosed the
2102
+ // storage itself.
2103
+ if (!isa<AccessorDecl>(FD))
2104
+ if (FD->getDeclContext ()->getSelfClassDecl ())
2105
+ checkDynamicSelfType (FD, FD->getResultInterfaceType ());
2103
2106
2104
2107
checkDefaultArguments (FD->getParameters ());
2105
2108
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