|
| 1 | +// RUN: %empty-directory(%t) |
| 2 | +// RUN: split-file %s %t |
| 3 | + |
| 4 | +// RUN: %target-swift-frontend -emit-module -emit-module-path %t/Library.swiftmodule -parse-as-library %t/Library.swift -enable-library-evolution |
| 5 | +// RUN: %target-swift-frontend -primary-file %t/Client.swift -I %t -emit-ir | %FileCheck %s |
| 6 | + |
| 7 | +// REQUIRES: OS=macosx |
| 8 | + |
| 9 | +//--- Library.swift |
| 10 | + |
| 11 | +public protocol P { } |
| 12 | +public protocol Q: P { } |
| 13 | + |
| 14 | +public protocol StrongProtoWithAssoc { |
| 15 | + associatedtype Assoc: P |
| 16 | +} |
| 17 | + |
| 18 | +public protocol StrongProtoWithWeakLinkedAssoc { |
| 19 | + @_weakLinked associatedtype Assoc: P |
| 20 | +} |
| 21 | + |
| 22 | +@available(macOS 10.50, *) |
| 23 | +public protocol WeakProtoWithAssoc { |
| 24 | + associatedtype Assoc: P |
| 25 | +} |
| 26 | + |
| 27 | +@available(macOS 10.50, *) |
| 28 | +public protocol WeakProtoWithStrongInheritedAssoc: StrongProtoWithAssoc where Self.Assoc: Q { } |
| 29 | + |
| 30 | + |
| 31 | +//--- Client.swift |
| 32 | + |
| 33 | +import Library |
| 34 | + |
| 35 | +struct ConformsToP: P { } |
| 36 | +struct ConformsToQ: Q { } |
| 37 | + |
| 38 | +// CHECK: @"$s7Library20StrongProtoWithAssocP0E0AC_AA1PTn" = external global %swift.protocol_requirement, align 4 |
| 39 | +struct ConformsToStrongProtoWithAssoc: StrongProtoWithAssoc { |
| 40 | + typealias Assoc = ConformsToP |
| 41 | +} |
| 42 | + |
| 43 | +// CHECK: @"$s7Library30StrongProtoWithWeakLinkedAssocP0G0AC_AA1PTn" = extern_weak global %swift.protocol_requirement, align 4 |
| 44 | +struct ConformsToStrongProtoWithWeakLinkedAssoc: StrongProtoWithWeakLinkedAssoc { |
| 45 | + typealias Assoc = ConformsToP |
| 46 | +} |
| 47 | + |
| 48 | +// CHECK: @"$s7Library18WeakProtoWithAssocP0E0AC_AA1PTn" = extern_weak global %swift.protocol_requirement, align 4 |
| 49 | +@available(macOS 10.50, *) |
| 50 | +struct ConformsToWeakProtoWithAssoc: WeakProtoWithAssoc { |
| 51 | + typealias Assoc = ConformsToP |
| 52 | +} |
| 53 | + |
| 54 | +// CHECK: @"$s7Library33WeakProtoWithStrongInheritedAssocP0G0AA0ecdG0P_AA1QTn" = extern_weak global %swift.protocol_requirement, align 4 |
| 55 | +@available(macOS 10.50, *) |
| 56 | +struct ConformsToWeakProtoWithStrongInheritedAssoc: WeakProtoWithStrongInheritedAssoc { |
| 57 | + typealias Assoc = ConformsToQ |
| 58 | +} |
0 commit comments