Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Property wrapper with Opaque Type type inference #63056

Open
iDmitriyy opened this issue Jan 16, 2023 · 0 comments
Open

Property wrapper with Opaque Type type inference #63056

iDmitriyy opened this issue Jan 16, 2023 · 0 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler itself opaque types Feature → types: opaque types property wrappers Feature: property wrappers swift 5.7 type checker Area → compiler: Semantic analysis

Comments

@iDmitriyy
Copy link

iDmitriyy commented Jan 16, 2023

I get a compiler error using property wrapper with Opaque Type.

Code to reproduce:

@propertyWrapper ParamsStorage {
  private var storage = Array< Param >()

  var wrappedValue: some Collection<Param> { storage }

  func addParam(_ param: Param) { storage.append(param) }
}
...
final class Event {
  @ParamsStorage params: some Collection<Param>
  // compiler error: Property type 'some Collection' (type of 'Event.params') does not match 'wrappedValue' type 'some Collection' (type of 'ParamsStorage.wrappedValue')
}
At the same time, the following code compiles:

final class Event {
  private var _params: StatisticsParamsStorage = .init()
  var params: some Collection<StatisticsEventParam> { _params.wrappedValue }
}

Environment

  • Swift compiler version info: swiftc -version
    swift-driver version: 1.62.15 Apple Swift version 5.7.1 (swiftlang-5.7.1.135.3 clang-1400.0.29.51)
  • Xcode version info:
  • Deployment target: iOS 14.5

Swift forum thread: https://forums.swift.org/t/property-wrapper-with-opaque-type/62550
@hborla

@iDmitriyy iDmitriyy added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels labels Jan 16, 2023
@AnthonyLatsis AnthonyLatsis added compiler The Swift compiler itself type checker Area → compiler: Semantic analysis opaque types Feature → types: opaque types property wrappers Feature: property wrappers swift 5.7 and removed triage needed This issue needs more specific labels labels Jan 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler itself opaque types Feature → types: opaque types property wrappers Feature: property wrappers swift 5.7 type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

2 participants