|
| 1 | +// RUN: %empty-directory(%t) |
| 2 | +// RUN: split-file --leading-lines %s %t |
| 3 | + |
| 4 | +/// Build the libraries. |
| 5 | +// RUN: %target-swift-frontend -emit-module %t/PublicLib.swift -o %t \ |
| 6 | +// RUN: -enable-library-evolution |
| 7 | +// RUN: %target-swift-frontend -emit-module %t/PackageLib.swift -o %t \ |
| 8 | +// RUN: -enable-library-evolution |
| 9 | +// RUN: %target-swift-frontend -emit-module %t/InternalLib.swift -o %t \ |
| 10 | +// RUN: -enable-library-evolution |
| 11 | +// RUN: %target-swift-frontend -emit-module %t/FileprivateLib.swift -o %t \ |
| 12 | +// RUN: -enable-library-evolution |
| 13 | +// RUN: %target-swift-frontend -emit-module %t/PrivateLib.swift -o %t \ |
| 14 | +// RUN: -enable-library-evolution |
| 15 | + |
| 16 | +/// Check diagnostics. |
| 17 | +// RUN: %target-swift-frontend -typecheck %t/Client.swift -I %t \ |
| 18 | +// RUN: -package-name TestPackage -swift-version 5 \ |
| 19 | +// RUN: -enable-experimental-feature AccessLevelOnImport -verify |
| 20 | + |
| 21 | +/// Check diagnostics with library-evolution. |
| 22 | +// RUN: %target-swift-frontend -typecheck %t/Client.swift -I %t \ |
| 23 | +// RUN: -package-name TestPackage -swift-version 5 \ |
| 24 | +// RUN: -enable-library-evolution \ |
| 25 | +// RUN: -enable-experimental-feature AccessLevelOnImport -verify |
| 26 | + |
| 27 | +//--- PublicLib.swift |
| 28 | +public struct PublicImportType { |
| 29 | + public init() {} |
| 30 | +} |
| 31 | + |
| 32 | +//--- PackageLib.swift |
| 33 | +public struct PackageImportType { |
| 34 | + public init() {} |
| 35 | +} |
| 36 | + |
| 37 | +//--- InternalLib.swift |
| 38 | +public struct InternalImportType { |
| 39 | + public init() {} |
| 40 | +} |
| 41 | + |
| 42 | +//--- FileprivateLib.swift |
| 43 | +public struct FileprivateImportType { |
| 44 | + public init() {} |
| 45 | +} |
| 46 | + |
| 47 | +//--- PrivateLib.swift |
| 48 | +public struct PrivateImportType { |
| 49 | + public init() {} |
| 50 | +} |
| 51 | + |
| 52 | +//--- Client.swift |
| 53 | +public import PublicLib |
| 54 | +package import PackageLib // expected-note 2 {{struct 'PackageImportType' imported as 'package' from 'PackageLib' here}} |
| 55 | +internal import InternalLib // expected-note 2 {{struct 'InternalImportType' imported as 'internal' from 'InternalLib' here}} |
| 56 | +fileprivate import FileprivateLib // expected-note 2 {{struct 'FileprivateImportType' imported as 'fileprivate' from 'FileprivateLib' here}} |
| 57 | +private import PrivateLib // expected-note 2 {{struct 'PrivateImportType' imported as 'private' from 'PrivateLib' here}} |
| 58 | + |
| 59 | +public protocol PublicConstrainedExtensionProto {} |
| 60 | +extension Array: PublicConstrainedExtensionProto where Element == PublicImportType {} |
| 61 | +extension PublicImportType { |
| 62 | + public func publicMethod() {} |
| 63 | +} |
| 64 | + |
| 65 | +package protocol PublicConstrainedExtensionProtoInPackage {} |
| 66 | +extension Array: PublicConstrainedExtensionProtoInPackage where Element == PackageImportType {} |
| 67 | +extension PublicImportType { |
| 68 | + package func packageMethod() {} |
| 69 | +} |
| 70 | + |
| 71 | +internal protocol PublicConstrainedExtensionProtoInInternal {} |
| 72 | +extension Array: PublicConstrainedExtensionProtoInInternal where Element == PublicImportType {} |
| 73 | +extension PublicImportType { |
| 74 | + internal func internalMethod() {} |
| 75 | +} |
| 76 | + |
| 77 | +fileprivate protocol PublicConstrainedExtensionProtoInFileprivate {} |
| 78 | +extension Array: PublicConstrainedExtensionProtoInFileprivate where Element == PublicImportType {} |
| 79 | +extension PublicImportType { |
| 80 | + fileprivate func fileprivateMethod() {} |
| 81 | +} |
| 82 | + |
| 83 | +private protocol PublicConstrainedExtensionProtoInPrivate {} |
| 84 | +extension Array: PublicConstrainedExtensionProtoInPrivate where Element == PublicImportType {} |
| 85 | +extension PublicImportType { |
| 86 | + private func privateMethod() {} |
| 87 | +} |
| 88 | + |
| 89 | +public protocol PackageConstrainedExtensionProto {} |
| 90 | +extension Array: PackageConstrainedExtensionProto where Element == PackageImportType {} // expected-error {{cannot use struct 'PackageImportType' in an extension with conditional conformances; 'PackageLib' was not imported publicly}} |
| 91 | +extension PackageImportType { // expected-error {{cannot use struct 'PackageImportType' in an extension with public or '@usableFromInline' members; 'PackageLib' was not imported publicly}} |
| 92 | + public func publicMethod() {} |
| 93 | +} |
| 94 | + |
| 95 | +package protocol PackageConstrainedExtensionProtoInPackage {} |
| 96 | +extension Array: PackageConstrainedExtensionProtoInPackage where Element == PackageImportType {} |
| 97 | +extension PackageImportType { |
| 98 | + package func packageMethod() {} |
| 99 | +} |
| 100 | + |
| 101 | +internal protocol PackageConstrainedExtensionProtoInInternal {} |
| 102 | +extension Array: PackageConstrainedExtensionProtoInInternal where Element == PackageImportType {} |
| 103 | +extension PackageImportType { |
| 104 | + internal func internalMethod() {} |
| 105 | +} |
| 106 | + |
| 107 | +fileprivate protocol PackageConstrainedExtensionProtoInFileprivate {} |
| 108 | +extension Array: PackageConstrainedExtensionProtoInFileprivate where Element == PackageImportType {} |
| 109 | +extension PackageImportType { |
| 110 | + fileprivate func fileprivateMethod() {} |
| 111 | +} |
| 112 | + |
| 113 | +private protocol PackageConstrainedExtensionProtoInPrivate {} |
| 114 | +extension Array: PackageConstrainedExtensionProtoInPrivate where Element == PackageImportType {} |
| 115 | +extension PackageImportType { |
| 116 | + private func privateMethod() {} |
| 117 | +} |
| 118 | + |
| 119 | +public protocol InternalConstrainedExtensionProto {} |
| 120 | +extension Array: InternalConstrainedExtensionProto where Element == InternalImportType {} // expected-error {{cannot use struct 'InternalImportType' in an extension with conditional conformances; 'InternalLib' was not imported publicly}} |
| 121 | +extension InternalImportType { // expected-error {{cannot use struct 'InternalImportType' in an extension with public or '@usableFromInline' members; 'InternalLib' was not imported publicly}} |
| 122 | + public func foo() {} |
| 123 | +} |
| 124 | + |
| 125 | +package protocol InternalConstrainedExtensionProtoInPackage {} |
| 126 | +extension Array: InternalConstrainedExtensionProtoInPackage where Element == InternalImportType {} |
| 127 | +extension InternalImportType { |
| 128 | + package func packageMethod() {} |
| 129 | +} |
| 130 | + |
| 131 | +internal protocol InternalConstrainedExtensionProtoInInternal {} |
| 132 | +extension Array: InternalConstrainedExtensionProtoInInternal where Element == InternalImportType {} |
| 133 | +extension InternalImportType { |
| 134 | + internal func internalMethod() {} |
| 135 | +} |
| 136 | + |
| 137 | +fileprivate protocol InternalConstrainedExtensionProtoInFileprivate {} |
| 138 | +extension Array: InternalConstrainedExtensionProtoInFileprivate where Element == InternalImportType {} |
| 139 | +extension InternalImportType { |
| 140 | + fileprivate func fileprivateMethod() {} |
| 141 | +} |
| 142 | + |
| 143 | +private protocol InternalConstrainedExtensionProtoInPrivate {} |
| 144 | +extension Array: InternalConstrainedExtensionProtoInPrivate where Element == InternalImportType {} |
| 145 | +extension InternalImportType { |
| 146 | + private func privateMethod() {} |
| 147 | +} |
| 148 | + |
| 149 | +public protocol FileprivateConstrainedExtensionProto {} |
| 150 | +extension Array: FileprivateConstrainedExtensionProto where Element == FileprivateImportType {} // expected-error {{cannot use struct 'FileprivateImportType' in an extension with conditional conformances; 'FileprivateLib' was not imported publicly}} |
| 151 | +extension FileprivateImportType { // expected-error {{cannot use struct 'FileprivateImportType' in an extension with public or '@usableFromInline' members; 'FileprivateLib' was not imported publicly}} |
| 152 | + public func foo() {} |
| 153 | +} |
| 154 | + |
| 155 | +package protocol FileprivateConstrainedExtensionProtoInPackage {} |
| 156 | +extension Array: FileprivateConstrainedExtensionProtoInPackage where Element == FileprivateImportType {} |
| 157 | +extension FileprivateImportType { |
| 158 | + package func packageMethod() {} |
| 159 | +} |
| 160 | + |
| 161 | +internal protocol FileprivateConstrainedExtensionProtoInInternal {} |
| 162 | +extension Array: FileprivateConstrainedExtensionProtoInInternal where Element == FileprivateImportType {} |
| 163 | +extension FileprivateImportType { |
| 164 | + internal func internalMethod() {} |
| 165 | +} |
| 166 | + |
| 167 | +fileprivate protocol FileprivateConstrainedExtensionProtoInFileprivate {} |
| 168 | +extension Array: FileprivateConstrainedExtensionProtoInFileprivate where Element == FileprivateImportType {} |
| 169 | +extension FileprivateImportType { |
| 170 | + fileprivate func fileprivateMethod() {} |
| 171 | +} |
| 172 | + |
| 173 | +private protocol FileprivateConstrainedExtensionProtoInPrivate {} |
| 174 | +extension Array: FileprivateConstrainedExtensionProtoInPrivate where Element == FileprivateImportType {} |
| 175 | +extension FileprivateImportType { |
| 176 | + private func privateMethod() {} |
| 177 | +} |
| 178 | + |
| 179 | +public protocol PrivateConstrainedExtensionProto {} |
| 180 | +extension Array: PrivateConstrainedExtensionProto where Element == PrivateImportType {} // expected-error {{cannot use struct 'PrivateImportType' in an extension with conditional conformances; 'PrivateLib' was not imported publicly}} |
| 181 | +extension PrivateImportType { // expected-error {{cannot use struct 'PrivateImportType' in an extension with public or '@usableFromInline' members; 'PrivateLib' was not imported publicly}} |
| 182 | + public func foo() {} |
| 183 | +} |
| 184 | + |
| 185 | +package protocol PrivateConstrainedExtensionProtoInPackage {} |
| 186 | +extension Array: PrivateConstrainedExtensionProtoInPackage where Element == PrivateImportType {} |
| 187 | +extension PrivateImportType { |
| 188 | + package func packageMethod() {} |
| 189 | +} |
| 190 | + |
| 191 | +internal protocol PrivateConstrainedExtensionProtoInInternal {} |
| 192 | +extension Array: PrivateConstrainedExtensionProtoInInternal where Element == PrivateImportType {} |
| 193 | +extension PrivateImportType { |
| 194 | + internal func internalMethod() {} |
| 195 | +} |
| 196 | + |
| 197 | +fileprivate protocol PrivateConstrainedExtensionProtoInFileprivate {} |
| 198 | +extension Array: PrivateConstrainedExtensionProtoInFileprivate where Element == PrivateImportType {} |
| 199 | +extension PrivateImportType { |
| 200 | + fileprivate func fileprivateMethod() {} |
| 201 | +} |
| 202 | + |
| 203 | +private protocol PrivateConstrainedExtensionProtoInPrivate {} |
| 204 | +extension Array: PrivateConstrainedExtensionProtoInPrivate where Element == PrivateImportType {} |
| 205 | +extension PrivateImportType { |
| 206 | + private func privateMethod() {} |
| 207 | +} |
0 commit comments