Files
swift-mirror/test/Sema/diag_constantness_check_os_log_swift6.swift
Pavel Yaskevich b484e9645d [Sema] ConstnessChecker: Look through function conversions while checking arguments
In strict concurrency mode some calls could reference a declaration that
is  wrapped in one or more function conversion expressions to apply
concurrency related attributes or erase them (such as `@Sendable` or
`@MainActor`). This shouldn't impact constness checking and the checker
should look through such conversions.

Resolves: rdar://148168219
2025-04-23 14:11:39 -07:00

34 lines
747 B
Swift

// RUN: %target-typecheck-verify-swift -swift-version 6
// REQUIRES: VENDOR=apple
// REQUIRES: concurrency
import OSLogTestHelper
class Log {
@_semantics("oslog.requires_constant_arguments")
func debug(_: OSLogMessage) {}
}
@_semantics("constant_evaluable")
@_transparent
public func __outputFormatter(_ key: String, fallback: OSLogMessage) -> OSLogMessage {
fallback
}
@MainActor
@_semantics("constant_evaluable")
@_transparent
public func __isolatedOutputFormatter(_ key: String, fallback: OSLogMessage) -> OSLogMessage {
fallback
}
func test(log: Log) {
log.debug(__outputFormatter("1", fallback: "msg")) // Ok
}
@MainActor
func isolatedTest(log: Log) {
log.debug(__isolatedOutputFormatter("1", fallback: "msg")) // Ok
}