swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.28k stars 10.33k forks source link

Deprecated types aren't diagnosed when used as property wrappers #63139

Open stephencelis opened 1 year ago

stephencelis commented 1 year ago

Description

When a type that can act as a property wrapper (such as a struct, or type alias to a struct) is deprecated, no warning shows up when used as an @-property wrapper.

Steps to reproduce

Paste the following into a Swift file:

@available(*, deprecated)
@propertyWrapper
struct A {
  var wrappedValue: Int
}

@available(*, deprecated)
typealias B = A

func f() {
  @A var x = 0                // No warning!
  var y = A(wrappedValue: 0)  // ⚠️ 'A' is deprecated

  @B var z = 0                // No warning!
  var w = B(wrappedValue: 0)  // ⚠️ 'B' is deprecated
}

Expected behavior

I expect both @A and @B lines to have deprecation warnings.

Environment

stephencelis commented 1 year ago

Worse, if marked unavailable, usages still compile:

@available(*, unavailable)
@propertyWrapper
struct A {
  var wrappedValue: Int
}

@available(*, unavailable)
typealias B = A

func f() {
  @A var x = 0                // Compiles!
  @B var z = 0                // Compiles!
}
stephencelis commented 1 year ago

Appears to be a partial duplicate of https://github.com/apple/swift/issues/57231