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 @@ -1336,13 +1336,13 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
13361336 }
13371337
13381338 if (VD->getDeclContext ()->getSelfClassDecl ()) {
1339- checkDynamicSelfType (VD, VD->getValueInterfaceType ());
1340-
13411339 if (VD->getValueInterfaceType ()->hasDynamicSelfType ()) {
13421340 if (VD->hasStorage ())
13431341 VD->diagnose (diag::dynamic_self_in_stored_property);
13441342 else if (VD->isSettable (nullptr ))
13451343 VD->diagnose (diag::dynamic_self_in_mutable_property);
1344+ else
1345+ checkDynamicSelfType (VD, VD->getValueInterfaceType ());
13461346 }
13471347 }
13481348
@@ -2153,8 +2153,11 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
21532153
21542154 checkExplicitAvailability (FD);
21552155
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 ());
21582161
21592162 checkDefaultArguments (FD->getParameters ());
21602163
Original file line number Diff line number Diff line change @@ -270,3 +270,20 @@ class Foo {
270270 Self . value * 2
271271 } ( )
272272}
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