-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Closed
Labels
availabilityThe @available attribute and availability checking in generalThe @available attribute and availability checking in generalbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselftype checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysis
Description
Describe the bug
When a literal initializer is marked with an availability annotation, it's seemingly ignored by the compiler at the point of use, unless the initializer is used explicitly.
Steps To Reproduce
struct Foo {
let bar: String
}
@available(*, deprecated)
extension Foo: ExpressibleByStringLiteral {
init(stringLiteral value: StringLiteralType) {
self.bar = value
}
}
let a: Foo = Foo(stringLiteral: "") // warning: 'init(stringLiteral:)' is deprecated
let b: Foo = "" // no warningExpected behavior
Both assignments should cause a deprecation warning.
Note: every other availability status (e.g. unavailable) is also ignored.
Screenshots
Metadata
Metadata
Assignees
Labels
availabilityThe @available attribute and availability checking in generalThe @available attribute and availability checking in generalbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselftype checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysis
