Files
swift-mirror/test/Unsafe/module-interface.swift
Doug Gregor 13c82c6f78 Remove "unsafe" keyword from expressions when printing inlinable code
To help older compilers that don't yet support the unsafe expression
deal with the Swift interface files we produce, remove the "unsafe" from
expressions in inlinable code.
2025-02-18 07:14:18 -10:00

35 lines
1.1 KiB
Swift

// RUN: %target-swift-emit-module-interface(%t.swiftinterface) %s -module-name UserModule -enable-experimental-feature AllowUnsafeAttribute -enable-experimental-feature WarnUnsafe
// RUN: %target-swift-typecheck-module-from-interface(%t.swiftinterface) -module-name UserModule
// RUN: %FileCheck %s < %t.swiftinterface
// REQUIRES: swift_feature_AllowUnsafeAttribute
// REQUIRES: swift_feature_WarnUnsafe
// CHECK: #if compiler(>=5.3) && $AllowUnsafeAttribute
// CHECK: @unsafe public func getIntUnsafely() -> Swift.Int
// CHECK: #else
// CHECK: public func getIntUnsafely() -> Swift.Int
// CHECK: #endif
@unsafe public func getIntUnsafely() -> Int { 0 }
// CHECK: @inlinable public func useUnsafeCode()
@inlinable public func useUnsafeCode() {
// CHECK-NOT: unsafe
print( unsafe getIntUnsafely())
}
// CHECK: public protocol P
public protocol P {
func f()
}
// CHECK: public struct X : @unsafe UserModule.P
public struct X: @unsafe P {
// CHECK: #if compiler(>=5.3) && $AllowUnsafeAttribute
// CHECK: @unsafe public func f()
// CHECK: #else
// CHECK: public func f()
// CHECK: #endif
@unsafe public func f() { }
}