|
| 1 | +// RUN: %empty-directory(%t) |
| 2 | +// RUN: %target-swift-frontend -emit-module -emit-module-path %t/weak_import_availability_helper.swiftmodule -parse-as-library %S/Inputs/weak_import_availability_helper.swift -enable-resilience |
| 3 | +// |
| 4 | +// RUN: %target-swift-frontend -primary-file %s -I %t -emit-ir | %FileCheck %s |
| 5 | + |
| 6 | +// REQUIRES: OS=macosx |
| 7 | + |
| 8 | +import weak_import_availability_helper |
| 9 | + |
| 10 | +public func useConditionallyAvailableCase(e: AlwaysAvailableEnum) { |
| 11 | + switch e { |
| 12 | + case .alwaysAvailableCase: break |
| 13 | + case .conditionallyAvailableCase: break |
| 14 | + } |
| 15 | +} |
| 16 | + |
| 17 | +// CHECK-LABEL: @"$s31weak_import_availability_helper19AlwaysAvailableEnumO013conditionallyF4CaseyA2CmFWC" = extern_weak constant i32 |
| 18 | + |
| 19 | +func useConformance<T : AlwaysAvailableProtocol>(_: T.Type) {} |
| 20 | + |
| 21 | +@available(macOS 10.50, *) |
| 22 | +public func useConditionallyAvailableConformance() { |
| 23 | + useConformance(AlwaysAvailableStruct.self) |
| 24 | +} |
| 25 | + |
| 26 | +// FIXME: We reference the witness table directly -- that's a bug since the module is resilient. Should reference the |
| 27 | +// conformance descriptor instead. |
| 28 | + |
| 29 | +// CHECK-LABEL: @"$s31weak_import_availability_helper21AlwaysAvailableStructVAA0eF8ProtocolAAWP" = extern_weak global i8* |
| 30 | + |
| 31 | +@available(macOS 10.50, *) |
| 32 | +public func callConditionallyAvailableFunction() { |
| 33 | + conditionallyAvailableFunction() |
| 34 | +} |
| 35 | + |
| 36 | +// CHECK-LABEL: declare extern_weak swiftcc void @"$s31weak_import_availability_helper30conditionallyAvailableFunctionyyF"() |
| 37 | + |
| 38 | +@available(macOS 10.50, *) |
| 39 | +public func useConditionallyAvailableGlobal() { |
| 40 | + _ = conditionallyAvailableGlobal |
| 41 | + conditionallyAvailableGlobal = 0 |
| 42 | + conditionallyAvailableGlobal += 1 |
| 43 | +} |
| 44 | + |
| 45 | +// CHECK-LABEL: declare extern_weak swiftcc i64 @"$s31weak_import_availability_helper28conditionallyAvailableGlobalSivg"() |
| 46 | + |
| 47 | +// CHECK-LABEL: declare extern_weak swiftcc void @"$s31weak_import_availability_helper28conditionallyAvailableGlobalSivs"(i64) |
| 48 | + |
| 49 | +func blackHole<T>(_: T) {} |
| 50 | + |
| 51 | +@available(macOS 10.50, *) |
| 52 | +public func useConditionallyAvailableStruct() { |
| 53 | + blackHole(ConditionallyAvailableStruct.self) |
| 54 | +} |
| 55 | + |
| 56 | +// CHECK-LABEL: declare extern_weak swiftcc %swift.metadata_response @"$s31weak_import_availability_helper28ConditionallyAvailableStructVMa"(i64) |
| 57 | + |
| 58 | +@available(macOS 10.50, *) |
| 59 | +public func useConditionallyAvailableMethod(s: ConditionallyAvailableStruct) { |
| 60 | + s.conditionallyAvailableMethod() |
| 61 | +} |
| 62 | + |
| 63 | +// CHECK-LABEL: declare extern_weak swiftcc void @"$s31weak_import_availability_helper28ConditionallyAvailableStructV013conditionallyF6MethodyyF"(%swift.opaque* noalias nocapture swiftself) |
0 commit comments