|
| 1 | +// RUN: %empty-directory(%t/src) |
| 2 | +// RUN: split-file %s %t/src |
| 3 | + |
| 4 | +/// Build LibA |
| 5 | +// RUN: %host-build-swift %t/src/LibA.swift -swift-version 5 -emit-module -emit-library -enable-library-evolution -module-name LibA -o %t/%target-library-name(LibA) -emit-module-interface-path %t/LibA.swiftinterface |
| 6 | + |
| 7 | +// Build LibB |
| 8 | +// RUN: %target-build-swift %t/src/LibB.swift -I %t -L %t -l LibA -swift-version 5 -emit-module -emit-library -module-name LibB -o %t/%target-library-name(LibB) |
| 9 | + |
| 10 | +// Build LibC |
| 11 | +// RUN: %target-build-swift %t/src/LibC.swift -I %t -L %t -l LibA -swift-version 5 -emit-module -emit-library -module-name LibC -o %t/%target-library-name(LibC) |
| 12 | + |
| 13 | +// Build & run main.swift |
| 14 | +// RUN: %target-build-swift -I %t -L %t -l LibA -l LibB -l LibC %t/src/main.swift -o %t/a.out |
| 15 | +// RUN: %target-codesign %t/%target-library-name(LibA) |
| 16 | +// RUN: %target-codesign %t/%target-library-name(LibB) |
| 17 | +// RUN: %target-codesign %t/%target-library-name(LibC) |
| 18 | +// RUN: %target-codesign %t/a.out |
| 19 | +// RUN: %target-run %t/a.out | %FileCheck %s |
| 20 | + |
| 21 | +// REQUIRES: executable_test |
| 22 | + |
| 23 | +//--- LibA.swift |
| 24 | +public struct AStruct { |
| 25 | + public static var property1: Int = 1 |
| 26 | + public static var property2: Int = 2 |
| 27 | + private(set) public static var property3: Int = 1 |
| 28 | + private(set) public static var property4: Int = 4 |
| 29 | +} |
| 30 | + |
| 31 | +//--- LibB.swift |
| 32 | +import LibA |
| 33 | + |
| 34 | +public let keyPath1FromLibB = \AStruct.Type.property1 |
| 35 | +public let keyPath2FromLibB = \AStruct.Type.property2 |
| 36 | +public let keyPath3FromLibB = \AStruct.Type.property3 |
| 37 | +public let keyPath4FromLibB = \AStruct.Type.property4 |
| 38 | +public var keyPath5FromLibB = \AStruct.Type.property1 // WritableKeyPath with public setter |
| 39 | + |
| 40 | +//--- LibC.swift |
| 41 | +import LibA |
| 42 | + |
| 43 | +public let keyPath1FromLibC = \AStruct.Type.property1 |
| 44 | +public let keyPath2FromLibC = \AStruct.Type.property2 |
| 45 | +public let keyPath3FromLibC = \AStruct.Type.property3 // Read-only with private setter |
| 46 | +public let keyPath4FromLibC = \AStruct.Type.property4 |
| 47 | + |
| 48 | +//--- main.swift |
| 49 | +import LibB |
| 50 | +import LibC |
| 51 | + |
| 52 | +// CHECK: true |
| 53 | +print(keyPath1FromLibB == keyPath1FromLibC) |
| 54 | +// CHECK: true |
| 55 | +print(keyPath1FromLibB != keyPath2FromLibC) |
| 56 | + |
| 57 | +// CHECK: true |
| 58 | +print(keyPath3FromLibB == keyPath3FromLibC) |
| 59 | +// CHECK: true |
| 60 | +print(keyPath3FromLibB != keyPath4FromLibC) |
| 61 | + |
| 62 | +// CHECK: false |
| 63 | +print(keyPath5FromLibB == keyPath3FromLibC) |
0 commit comments