@@ -279,6 +279,15 @@ func passAvailableConformance1a(x: HasAvailableConformance1) {
279279 _ = UsesHorse< HasAvailableConformance1> . self
280280}
281281
282+ // Always available conformance
283+ struct HasAvailableConformance2 : Horse { }
284+
285+ // Conformance available in macOS 200
286+ struct HasAvailableConformance3 { }
287+
288+ @available ( macOS 200 , * )
289+ extension HasAvailableConformance3 : Horse { }
290+
282291// Associated conformance with unavailability
283292protocol Rider {
284293 associatedtype H : Horse
@@ -326,6 +335,58 @@ extension AssocConformanceAvailable4 : Rider {
326335 typealias H = HasAvailableConformance1
327336}
328337
338+ @available ( macOS 100 , * )
339+ protocol Saddle {
340+ associatedtype H : Horse = HasAvailableConformance1
341+ }
342+
343+ struct ConformsToSaddle1 : Saddle { }
344+
345+ struct ConformsToSaddle2 : Saddle {
346+ typealias H = HasAvailableConformance2
347+ }
348+
349+ struct ConformsToSaddle3 : Saddle {
350+ // expected-error@-1 {{conformance of 'HasAvailableConformance3' to 'Horse' is only available in macOS 200 or newer}}
351+ // expected-note@-2 {{add @available attribute to enclosing struct}}
352+ // expected-note@-3 {{in associated type 'Self.H' (inferred as 'HasAvailableConformance3'}}
353+ typealias H = HasAvailableConformance3
354+ }
355+
356+ struct ConformsToSaddle4 : Saddle {
357+ // expected-error@-1 {{conformance of 'HasAvailableConformance3' to 'Horse' is only available in macOS 200 or newer}}
358+ // expected-note@-2 {{add @available attribute to enclosing struct}}
359+ // expected-note@-3 {{in associated type 'Self.H' (inferred as 'HasAvailableConformance3'}}
360+ @available ( macOS 200 , * )
361+ typealias H = HasAvailableConformance3
362+ }
363+
364+ protocol Barn {
365+ @available ( macOS 100 , * )
366+ associatedtype H : Horse = HasAvailableConformance1
367+ }
368+
369+ struct ConformsToBarn1 : Barn { }
370+
371+ struct ConformsToBarn2 : Barn {
372+ typealias H = HasAvailableConformance2
373+ }
374+
375+ struct ConformsToBarn3 : Barn {
376+ // expected-error@-1 {{conformance of 'HasAvailableConformance3' to 'Horse' is only available in macOS 200 or newer}}
377+ // expected-note@-2 {{add @available attribute to enclosing struct}}
378+ // expected-note@-3 {{in associated type 'Self.H' (inferred as 'HasAvailableConformance3'}}
379+ typealias H = HasAvailableConformance3
380+ }
381+
382+ struct ConformsToBarn4 : Barn {
383+ // expected-error@-1 {{conformance of 'HasAvailableConformance3' to 'Horse' is only available in macOS 200 or newer}}
384+ // expected-note@-2 {{add @available attribute to enclosing struct}}
385+ // expected-note@-3 {{in associated type 'Self.H' (inferred as 'HasAvailableConformance3'}}
386+ @available ( macOS 200 , * )
387+ typealias H = HasAvailableConformance3
388+ }
389+
329390// Solution ranking should down-rank solutions involving unavailable conformances
330391protocol First { }
331392extension First {
0 commit comments