|
| 1 | +// RUN: %empty-directory(%t) |
| 2 | +// RUN: split-file %s %t |
| 3 | + |
| 4 | +// REQUIRES: asserts |
| 5 | + |
| 6 | +// RUN: %target-swift-frontend -emit-module %t/HiddenLib.swift \ |
| 7 | +// RUN: -enable-library-evolution \ |
| 8 | +// RUN: -emit-module-path %t/HiddenLib.swiftmodule |
| 9 | + |
| 10 | +// RUN: %target-swift-frontend -emit-module %t/Lib.swift -I %t \ |
| 11 | +// RUN: -enable-library-evolution \ |
| 12 | +// RUN: -emit-module-path %t/Lib.swiftmodule \ |
| 13 | +// RUN: -emit-module-interface-path %t/Lib.swiftinterface |
| 14 | + |
| 15 | +// RUN: %target-swift-frontend -typecheck %t/Client.swift -I %t \ |
| 16 | +// RUN: -verify -Xllvm -debug-only=Serialization 2>&1 \ |
| 17 | +// RUN: | %FileCheck --check-prefixes=NEEDED,UNSAFE %s |
| 18 | + |
| 19 | +// RUN: rm %t/Lib.swiftmodule |
| 20 | + |
| 21 | +// RUN: %target-swift-frontend -typecheck %t/Client.swift -I %t \ |
| 22 | +// RUN: -verify -Xllvm -debug-only=Serialization 2>&1 \ |
| 23 | +// RUN: | %FileCheck --check-prefixes=NEEDED,CLEAN %s |
| 24 | + |
| 25 | +/// Decls part of the API needed by the client. |
| 26 | +// NEEDED-NOT: Deserialized: 'refToIOI()' |
| 27 | +// NEEDED: Deserialized: 'PublicStruct' |
| 28 | +// NEEDED: Deserialized: 'publicFunc()' |
| 29 | + |
| 30 | +/// Internal details dangerous to load. |
| 31 | +// UNSAFE: Deserialized: 'internalFunc()' |
| 32 | +// UNSAFE: Deserialized: 'privateFunc()' |
| 33 | +// UNSAFE: Deserialized: 'fileprivateFunc()' |
| 34 | + |
| 35 | +/// Decls removed by rebuilding from the swiftinterface. |
| 36 | +// CLEAN-NOT: Deserialized: 'internalFunc()' |
| 37 | +// CLEAN-NOT: Deserialized: 'privateFunc()' |
| 38 | +// CLEAN-NOT: Deserialized: 'fileprivateFunc()' |
| 39 | + |
| 40 | +//--- HiddenLib.swift |
| 41 | + |
| 42 | +public struct HiddenStruct { |
| 43 | + public init() {} |
| 44 | +} |
| 45 | + |
| 46 | +//--- Lib.swift |
| 47 | + |
| 48 | +@_implementationOnly import HiddenLib |
| 49 | + |
| 50 | +public class PublicStruct { |
| 51 | + public init() {} |
| 52 | + |
| 53 | + public func publicFunc() {} |
| 54 | + internal func internalFunc() {} |
| 55 | + private func privateFunc() {} |
| 56 | + fileprivate func fileprivateFunc() {} |
| 57 | + |
| 58 | + internal func refToIOI() -> HiddenStruct { |
| 59 | + return HiddenStruct(); |
| 60 | + } |
| 61 | +} |
| 62 | + |
| 63 | +//--- Client.swift |
| 64 | + |
| 65 | +import Lib |
| 66 | + |
| 67 | +var x = PublicStruct() |
| 68 | + |
| 69 | +// Trigger a typo correction that reads all members. |
| 70 | +x.notAMember() // expected-error {{value of type 'PublicStruct' has no member 'notAMember'}} |
0 commit comments