|
| 1 | +// RUN: %empty-directory(%t) |
| 2 | +// RUN: split-file %s %t |
| 3 | + |
| 4 | +// REQUIRES: asserts |
| 5 | + |
| 6 | +/// Resilient scenario, we ignore underlying type of non-inlinable functions. |
| 7 | +/// Build libraries. |
| 8 | +// RUN: %target-swift-frontend -emit-module %t/Lib.swift \ |
| 9 | +// RUN: -swift-version 5 -enable-library-evolution \ |
| 10 | +// RUN: -emit-module-path %t/Lib.swiftmodule \ |
| 11 | +// RUN: -emit-module-interface-path %t/Lib.swiftinterface -verify |
| 12 | + |
| 13 | +/// Build clients, with and without safety. |
| 14 | +// RUN: %target-swift-frontend -typecheck %t/Client.swift -I %t \ |
| 15 | +// RUN: -verify -Xllvm -debug-only=Serialization \ |
| 16 | +// RUN: -enable-deserialization-safety 2>&1 \ |
| 17 | +// RUN: | %FileCheck %s |
| 18 | + |
| 19 | +// RUN: %target-swift-frontend -typecheck %t/Client.swift -I %t \ |
| 20 | +// RUN: -verify -Xllvm -debug-only=Serialization \ |
| 21 | +// RUN: -disable-deserialization-safety 2>&1 \ |
| 22 | +// RUN: | %FileCheck %s |
| 23 | + |
| 24 | +// RUN: %target-swift-frontend -typecheck %t/Client.swift -I %t \ |
| 25 | +// RUN: -verify -Xllvm -debug-only=Serialization \ |
| 26 | +// RUN: -disable-access-control 2>&1 \ |
| 27 | +// RUN: | %FileCheck %s |
| 28 | + |
| 29 | +/// Build against the swiftinterface. |
| 30 | +// RUN: rm %t/Lib.swiftmodule |
| 31 | +// RUN: %target-swift-frontend -typecheck %t/Client.swift -I %t \ |
| 32 | +// RUN: -verify -Xllvm -debug-only=Serialization \ |
| 33 | +// RUN: -disable-deserialization-safety 2>&1 \ |
| 34 | +// RUN: | %FileCheck %s |
| 35 | + |
| 36 | +/// Non-resilient scenario, all underlying types are loaded. |
| 37 | +// RUN: %empty-directory(%t) |
| 38 | +// RUN: split-file %s %t |
| 39 | +// RUN: %target-swift-frontend -emit-module %t/Lib.swift \ |
| 40 | +// RUN: -swift-version 5 \ |
| 41 | +// RUN: -emit-module-path %t/Lib.swiftmodule -verify |
| 42 | +// RUN: %target-swift-frontend -typecheck %t/Client.swift -I %t \ |
| 43 | +// RUN: -verify -Xllvm -debug-only=Serialization \ |
| 44 | +// RUN: -disable-deserialization-safety 2>&1 \ |
| 45 | +// RUN: | %FileCheck --check-prefix=NON-RESILIENT %s |
| 46 | +// NON-RESILIENT-NOT: Ignoring underlying information |
| 47 | + |
| 48 | +//--- Lib.swift |
| 49 | +public protocol V {} |
| 50 | + |
| 51 | +public struct EV : V { |
| 52 | + public init () {} |
| 53 | +} |
| 54 | + |
| 55 | +@available(SwiftStdlib 5.1, *) |
| 56 | +public extension V { |
| 57 | + private func referencedPrivateFunc(v: some V) -> some V { return v } |
| 58 | + |
| 59 | + /// Hidden underlying types. |
| 60 | +// CHECK: Ignoring underlying information for opaque type of 'opaqueReferencingPrivate()' |
| 61 | + func opaqueReferencingPrivate() -> some V { |
| 62 | + referencedPrivateFunc(v: EV()) |
| 63 | + } |
| 64 | + |
| 65 | +// CHECK: Ignoring underlying information for opaque type of 'opaqueReferencingPrivateVar' |
| 66 | + var opaqueReferencingPrivateVar: some V { |
| 67 | + referencedPrivateFunc(v: EV()) |
| 68 | + } |
| 69 | + |
| 70 | +// CHECK: Ignoring underlying information for opaque type of 'opaqueReferencingPrivateVarPattern' |
| 71 | + var opaqueReferencingPrivateVarPattern: some V { |
| 72 | + get { |
| 73 | + referencedPrivateFunc(v: EV()) |
| 74 | + } |
| 75 | + } |
| 76 | + |
| 77 | +// CHECK: Ignoring underlying information for opaque type of 'subscript(_:)' |
| 78 | + subscript(v: some V) -> some V { |
| 79 | + referencedPrivateFunc(v: v) |
| 80 | + } |
| 81 | + |
| 82 | + /// Visible underlying types. |
| 83 | +// CHECK: Loading underlying information for opaque type of 'inlinableOpaqueFunc()' |
| 84 | + @inlinable |
| 85 | + func inlinableOpaqueFunc() -> some V { EV() } |
| 86 | + |
| 87 | +// CHECK: Loading underlying information for opaque type of 'aeicOpaqueFunc()' |
| 88 | + @_alwaysEmitIntoClient |
| 89 | + func aeicOpaqueFunc() -> some V { EV() } |
| 90 | + |
| 91 | +// CHECK: Loading underlying information for opaque type of 'transparentOpaqueFunc()' |
| 92 | + @_transparent |
| 93 | + func transparentOpaqueFunc() -> some V { EV() } |
| 94 | + |
| 95 | +// CHECK: Loading underlying information for opaque type of 'inlinableOpaqueVar' |
| 96 | + @inlinable |
| 97 | + var inlinableOpaqueVar: some V { EV() } |
| 98 | + |
| 99 | +// CHECK: Loading underlying information for opaque type of 'inlinableOpaqueVarPattern' |
| 100 | + var inlinableOpaqueVarPattern: some V { |
| 101 | + @inlinable |
| 102 | + get { EV() } |
| 103 | + } |
| 104 | +} |
| 105 | + |
| 106 | +//--- Client.swift |
| 107 | +import Lib |
| 108 | + |
| 109 | +if #available(SwiftStdlib 5.1, *) { |
| 110 | + let v = EV() |
| 111 | + let _ = v.opaqueReferencingPrivate() |
| 112 | + let _ = v.opaqueReferencingPrivateVar |
| 113 | + let _ = v.opaqueReferencingPrivateVarPattern |
| 114 | + let _ = v[v] |
| 115 | + |
| 116 | + let _ = v.inlinableOpaqueFunc() |
| 117 | + let _ = v.aeicOpaqueFunc() |
| 118 | + let _ = v.transparentOpaqueFunc() |
| 119 | + |
| 120 | + let _ = v.inlinableOpaqueVar |
| 121 | + let _ = v.inlinableOpaqueVarPattern |
| 122 | +} |
0 commit comments