File tree Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -4982,6 +4982,11 @@ TypeChecker::diagnosticIfDeclCannotBeUnavailable(const Decl *D) {
49824982 return Diagnostic (diag::availability_decl_no_unavailable, D);
49834983 }
49844984
4985+ // The conformance checker does not know what to do with unavailable
4986+ // associated types.
4987+ if (auto *AT = dyn_cast<AssociatedTypeDecl>(D))
4988+ return Diagnostic (diag::availability_decl_no_unavailable, D);
4989+
49854990 if (auto *VD = dyn_cast<VarDecl>(D)) {
49864991 if (!VD->hasStorageOrWrapsStorage ())
49874992 return std::nullopt ;
Original file line number Diff line number Diff line change @@ -84,3 +84,11 @@ extension ModelP2 {
8484 // expected-error@-1{{'B' is only available in macOS 14 or newer}}
8585 // expected-note@-2{{add @available attribute to enclosing instance method}}
8686}
87+
88+ protocol P3 {
89+ @available ( macOS, obsoleted: 12 ) // expected-error{{associated type cannot be marked unavailable with '@available'}}
90+ associatedtype A1
91+
92+ @available ( macOS, obsoleted: 99 ) // FIXME: this should probably be diagnosed
93+ associatedtype A2
94+ }
Original file line number Diff line number Diff line change @@ -91,3 +91,11 @@ struct SelfT: Unavail { // expected-error {{type 'SelfT' does not conform to pro
9191 // expected-error@-1 {{unavailable instance method 'req()' was used to satisfy a requirement of protocol 'Unavail': write it yourself}}
9292 typealias T = SelfT
9393}
94+
95+ protocol UnavailableAssoc {
96+ @available ( * , unavailable) // expected-error {{associated type cannot be marked unavailable with '@available'}}
97+ associatedtype A1
98+
99+ @available ( swift, introduced: 99 ) // expected-error {{associated type cannot be marked unavailable with '@available'}}
100+ associatedtype A2
101+ }
You can’t perform that action at this time.
0 commit comments