Files
swift-mirror/test/attr/using_diagnose_combined.swift
Aviva Ruben ce56e9ce6c Implement file-level using @available (and stop rejecting diagnose)
Diagnose was already supported by swift syntax, so we don't need to
track it at all in C++. Adds support for propagating a file default
availability via a side effect of a request. Ideally this would go
away in a future compiler that doesn't mutate decls to apply inferred
attributes. Future default attributes probably end up in this request,
unfortunately.
2026-06-22 13:31:20 -07:00

42 lines
1.6 KiB
Swift

// RUN: %target-swift-frontend -enable-experimental-feature DefaultIsolationPerFile -strict-memory-safety -typecheck -verify %s
// REQUIRES: swift_feature_DefaultIsolationPerFile
using @diagnose(DeprecatedDeclaration, as: ignored)
using @diagnose(StrictMemorySafety, as: error, reason: "I love strict memory safety! <3")
@available(*, deprecated)
func deprecatedThing() {}
@unsafe
func unsafeThing() {}
func caller() {
deprecatedThing()
unsafeThing() // expected-error {{expression uses unsafe constructs but is not marked with 'unsafe'}}
// expected-note@-1 {{reference to unsafe global function 'unsafeThing()'}}
}
@diagnose(DeprecatedDeclaration, as: error)
func callerWithPartialOverride() {
deprecatedThing() // expected-error {{'deprecatedThing()' is deprecated}}
unsafeThing() // expected-error {{expression uses unsafe constructs but is not marked with 'unsafe'}}
// expected-note@-1 {{reference to unsafe global function 'unsafeThing()'}}
}
@diagnose(DeprecatedDeclaration, as: warning)
class SplitOverride {
func methodA() {
deprecatedThing() // expected-warning {{'deprecatedThing()' is deprecated}}
unsafeThing() // expected-error {{expression uses unsafe constructs but is not marked with 'unsafe'}}
// expected-note@-1 {{reference to unsafe global function 'unsafeThing()'}}
}
@diagnose(StrictMemorySafety, as: warning)
func methodB() {
deprecatedThing() // expected-warning {{'deprecatedThing()' is deprecated}}
unsafeThing() // expected-warning {{expression uses unsafe constructs but is not marked with 'unsafe'}}
// expected-note@-1 {{reference to unsafe global function 'unsafeThing()'}}
}
}