mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Since we no longer remove these attributes from the AttributedTypeRepr, if we print based on the TypeRepr, we'll print them twice. The best solution is to only print the attributes based on the inheritance clause if we're not printing the type based on the TypeRepr. Fixes rdar://122965951.
93 lines
3.4 KiB
Swift
93 lines
3.4 KiB
Swift
// RUN: %empty-directory(%t)
|
|
// RUN: %target-swift-emit-module-interface(%t/Library.swiftinterface) %s -enable-experimental-concurrency -DLIBRARY -module-name Library
|
|
// RUN: %target-swift-typecheck-module-from-interface(%t/Library.swiftinterface) -enable-experimental-concurrency
|
|
|
|
// REQUIRES: concurrency
|
|
|
|
#if LIBRARY
|
|
@available(SwiftStdlib 5.5, *)
|
|
public func fn() async {
|
|
fatalError()
|
|
}
|
|
|
|
@available(SwiftStdlib 5.5, *)
|
|
public func reasyncFn(_: () async -> ()) reasync {
|
|
fatalError()
|
|
}
|
|
|
|
@available(SwiftStdlib 5.5, *)
|
|
public func takesSendable(
|
|
_ block: @Sendable @escaping () async throws -> Void
|
|
) { }
|
|
|
|
@available(SwiftStdlib 5.5, *)
|
|
public func takesMainActor(
|
|
_ block: @MainActor @escaping () -> Void
|
|
) { }
|
|
|
|
@MainActor(unsafe)
|
|
public protocol UnsafeMainProtocol {
|
|
func requirement()
|
|
}
|
|
|
|
public struct InferredUnsafeMainActor: UnsafeMainProtocol {
|
|
public func requirement() {}
|
|
}
|
|
|
|
@preconcurrency @MainActor
|
|
public protocol PreconcurrencyMainProtocol {
|
|
func requirement()
|
|
}
|
|
|
|
public struct InferredPreconcurrencyMainActor: PreconcurrencyMainProtocol {
|
|
public func requirement() {}
|
|
}
|
|
|
|
// rdar://122965951
|
|
public struct UncheckedSendable: @unchecked Sendable {}
|
|
extension UnsafePointer : @retroactive @unchecked Sendable {}
|
|
|
|
// RUN: %target-typecheck-verify-swift -enable-experimental-concurrency -I %t
|
|
|
|
#else
|
|
import Library
|
|
|
|
@available(SwiftStdlib 5.5, *)
|
|
func callFn() async {
|
|
await fn()
|
|
}
|
|
#endif
|
|
|
|
// RUN: %FileCheck --check-prefix=CHECK --check-prefix=CHECK-TYPECHECKED %s < %t/Library.swiftinterface
|
|
// CHECK: // swift-module-flags:{{.*}} -enable-experimental-concurrency
|
|
// CHECK: public func fn() async
|
|
// CHECK: public func reasyncFn(_: () async -> ()) reasync
|
|
// CHECK: public func takesSendable(_ block: {{@escaping @Sendable|@Sendable @escaping}} () async throws ->
|
|
// CHECK: public func takesMainActor(_ block: {{@escaping @_Concurrency.MainActor|@MainActor @escaping}} () ->
|
|
|
|
// CHECK: @_Concurrency.MainActor @preconcurrency public protocol UnsafeMainProtocol {
|
|
// CHECK-NEXT: @_Concurrency.MainActor @preconcurrency func requirement()
|
|
// CHECK-NEXT: }
|
|
|
|
// CHECK: @_Concurrency.MainActor @preconcurrency public struct InferredUnsafeMainActor :
|
|
// CHECK-NEXT: @_Concurrency.MainActor @preconcurrency public func requirement()
|
|
// CHECK-NEXT: }
|
|
|
|
// CHECK: @preconcurrency @_Concurrency.MainActor public protocol PreconcurrencyMainProtocol {
|
|
// CHECK-NEXT: @_Concurrency.MainActor @preconcurrency func requirement()
|
|
// CHECK-NEXT: }
|
|
|
|
// CHECK: @_Concurrency.MainActor @preconcurrency public struct InferredPreconcurrencyMainActor :
|
|
// CHECK-NEXT: @_Concurrency.MainActor @preconcurrency public func requirement()
|
|
// CHECK-NEXT: }
|
|
|
|
// CHECK-TYPECHECKED: public struct UncheckedSendable : @unchecked Swift.Sendable
|
|
// CHECK-ASWRITTEN: public struct UncheckedSendable : @unchecked Sendable
|
|
|
|
// CHECK-TYPECHECKED: extension Swift.UnsafePointer : @unchecked @retroactive Swift.Sendable
|
|
// CHECK-ASWRITTEN: extension UnsafePointer : @retroactive @unchecked Sendable
|
|
|
|
// RUN: %target-swift-emit-module-interface(%t/LibraryPreserveTypesAsWritten.swiftinterface) %s -enable-experimental-concurrency -DLIBRARY -module-name LibraryPreserveTypesAsWritten -module-interface-preserve-types-as-written
|
|
// RUN: %target-swift-typecheck-module-from-interface(%t/LibraryPreserveTypesAsWritten.swiftinterface) -enable-experimental-concurrency
|
|
// RUN: %FileCheck --check-prefix=CHECK --check-prefix=CHECK-ASWRITTEN %s < %t/LibraryPreserveTypesAsWritten.swiftinterface
|