Skip to content

Remove unsafeAddress(of:) #3644

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

Merged
merged 1 commit into from
Jul 27, 2016
Merged

Conversation

swiftix
Copy link
Contributor

@swiftix swiftix commented Jul 20, 2016

What's in this pull request?

The is a patch for the upcoming Swift evolution proposal.

rdar://problem/18589289
Resolves #44566

@swiftix
Copy link
Contributor Author

swiftix commented Jul 20, 2016

@gribozavr Do you mind reviewing this patch?

@@ -296,7 +296,7 @@ internal func reflect(instanceAddress: UInt, kind: InstanceKind) {
/// This reflects the stored properties of the immediate class.
/// The superclass is not (yet?) visited.
public func reflect(object: AnyObject) {
let address = unsafeAddress(of: object)
var address = Unmanaged.passUnretained(object).toOpaque()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This two pieces of code in SwiftReflectionTest.swift look buggy to me. They need at least a fixLifetime, could you add it? (defer { _fixLifetime(object) } at the beginning of the method.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do

@gribozavr
Copy link
Contributor

Just small comments, LGTM otherwise! Thank you!

}
#endif

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gribozavr Is it what you meant? Specially, is it correct to put @_version just before the non _ObjC version?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think that's the right way to do it.

@swiftix
Copy link
Contributor Author

swiftix commented Jul 20, 2016

@gribozavr I incorporated all of your comments and force-pushed the new version.

@gribozavr
Copy link
Contributor

@swiftix LGTM, thank you!

@swiftix
Copy link
Contributor Author

swiftix commented Jul 21, 2016

@gribozavr BTW, do we need to provide a deprecated attribute with a message like: "Unmanaged.passUnretained(x).toOpaque()" instead? Or do we just silently remove the APIs?

@gribozavr
Copy link
Contributor

@swiftix Yes, it would be great if we could provide migration attributes for both unsafeAddressOf(_:) (Swift 2.x) and unsafeAddress(of:) (Swift 3.0 betas).

@swiftix
Copy link
Contributor Author

swiftix commented Jul 21, 2016

@gribozavr OK, I'll add those to the methods and use unreachable() as their implementation.

@gribozavr gribozavr added the swift evolution pending discussion Flag → feature: A feature that has a Swift evolution proposal currently in review label Jul 24, 2016
@swiftix
Copy link
Contributor Author

swiftix commented Jul 26, 2016

@swift-ci Please test

@swiftix
Copy link
Contributor Author

swiftix commented Jul 26, 2016

This is formally approved by means of a swift-evolution process now.

@gribozavr gribozavr changed the title [Do not merge] Remove unsafeAddress(of:) Remove unsafeAddress(of:) Jul 26, 2016
@swiftix
Copy link
Contributor Author

swiftix commented Jul 26, 2016

@parkera This PR is removing a unsafeAddress(of:) according to the SE-0127. This results in a bunch of errors when compiling foundation, because it uses this API in a couple of places. Could you help fixing it? The official suggestion is to use Unmanaged.passUnretained(x).toOpaque() instead of unsafeAddress(of: x)

@swiftix
Copy link
Contributor Author

swiftix commented Jul 26, 2016

@parkera Forgot to provide the link to the compilation errors

@parkera
Copy link
Contributor

parkera commented Jul 26, 2016

@swiftix Put up a PR on swift-corelibs-foundation and I'll merge it.

@swiftix
Copy link
Contributor Author

swiftix commented Jul 26, 2016

@swift-ci Please smoke test Linux.

@swiftix
Copy link
Contributor Author

swiftix commented Jul 27, 2016

@swift-ci Please test

rdar://problem/18589289
@swiftix
Copy link
Contributor Author

swiftix commented Jul 27, 2016

@swift-ci Please smoke test Linux.

@swiftix
Copy link
Contributor Author

swiftix commented Jul 27, 2016

Test failures seem to be unrelated.

@swiftix
Copy link
Contributor Author

swiftix commented Jul 27, 2016

@gribozavr Can you please review for CCC? There are virtually no changes since last review. I just fixed merge conflicts and force-pushed again.

@gribozavr
Copy link
Contributor

LGTM.

@swiftix swiftix merged commit 56dd5ea into swiftlang:master Jul 27, 2016
@rintaro rintaro mannequin mentioned this pull request Nov 11, 2016
@AnthonyLatsis AnthonyLatsis removed the swift evolution pending discussion Flag → feature: A feature that has a Swift evolution proposal currently in review label Mar 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants