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) {
4982
4982
return Diagnostic (diag::availability_decl_no_unavailable, D);
4983
4983
}
4984
4984
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
+
4985
4990
if (auto *VD = dyn_cast<VarDecl>(D)) {
4986
4991
if (!VD->hasStorageOrWrapsStorage ())
4987
4992
return std::nullopt;
Original file line number Diff line number Diff line change @@ -84,3 +84,11 @@ extension ModelP2 {
84
84
// expected-error@-1{{'B' is only available in macOS 14 or newer}}
85
85
// expected-note@-2{{add @available attribute to enclosing instance method}}
86
86
}
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
91
91
// expected-error@-1 {{unavailable instance method 'req()' was used to satisfy a requirement of protocol 'Unavail': write it yourself}}
92
92
typealias T = SelfT
93
93
}
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