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

[SR-11571] Class instance properties with property wrappers have directly-accessed setters in certain cases #53976

Closed
belkadan opened this issue Oct 4, 2019 · 3 comments

Comments

@belkadan
Copy link
Contributor

@belkadan belkadan commented Oct 4, 2019

Previous ID SR-11571
Radar rdar://problem/55995012
Original Reporter @belkadan
Type Bug
Status Closed
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, PropertyWrappers, SILGen
Assignee @belkadan
Priority Medium

md5: 48a06e1299be6c2c32b826a45becc35c

Issue Description:

@propertyWrapper
public struct Noisy {
  private var value: Int

  public init(wrappedValue: Int) {
    value = wrappedValue
  }

  public var wrappedValue: Int {
    get { print("get!"); return value }
    set { print("set!"); value = newValue }
  }
}

class Test {
  @Noisy var foo: Int = 0

  func getAndSet() {
    print("got: \(self.foo)")
    self.foo = 42
    print("done")
  }
}

class Subclass: Test {
  override var foo: Int {
    get { print("subclass get"); return super.foo }
    set { print("subclass set"); super.foo = newValue }
  }
}

let x = Test()
x.getAndSet()
print("---")

let y = Subclass()
y.getAndSet()

This prints

get!
got: 0
set!
done
---
subclass get
get!
got: 0
set!
done

Notice the lack of "subclass set".

@belkadan
Copy link
Contributor Author

@belkadan belkadan commented Oct 4, 2019

@swift-ci create

@hborla
Copy link
Member

@hborla hborla commented Jul 16, 2021

This is fixed in 5.5; could you please verify in Xcode 13 beta, or with a 5.5 toolchain from https://swift.org/download/#snapshots ? Thanks!

@belkadan
Copy link
Contributor Author

@belkadan belkadan commented Jul 16, 2021

Verified with swift-5.5-DEVELOPMENT-SNAPSHOT-2021-07-14-a-osx.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants