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-1490] Implement SE-0076 by changing some UnsafeMutablePointer taking methods to take UP #44099

Closed
lattner mannequin opened this issue May 11, 2016 · 9 comments
Closed
Labels
good first issue Good for newcomers standard library Area: Standard library umbrella task

Comments

@lattner
Copy link
Mannequin

lattner mannequin commented May 11, 2016

Previous ID SR-1490
Radar None
Original Reporter @lattner
Type Task
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Standard Library
Labels Task, StarterBug
Assignee russ (JIRA)
Priority Medium

md5: 89eb1db72038e9957d739d341063d512

Issue Description:

SE-0076 has been accepted with modifications:
https://github.com/apple/swift-evolution/blob/master/proposals/0076-copying-to-unsafe-mutable-pointer-with-unsafe-pointer-source.md

instead of adding overloads for the methods as proposed, the existing methods should just be changed to take UnsafePointer instead of UnsafeMutablePointer. It would also be good to audit the rest of the standard library to make sure there aren't other similar cases. If they are found, this should also be modified as well.

@swift-ci
Copy link
Collaborator

Comment by Russ Bishop (JIRA)

@lattner Making the change as suggested broke some tests and I wonder if this will break user code too? (Referencing the member functions loses the magic conversion between the pointer types.)

I can fix the tests or I can add these as overloads - any opinion on which is preferred?

@lattner
Copy link
Mannequin Author

lattner mannequin commented May 25, 2016

I think that fixing the tests is the right path. @belkadan do you have an opinion on this?

@lattner
Copy link
Mannequin Author

lattner mannequin commented May 25, 2016

@gribozavr may also have a strong opinion here.

@belkadan
Copy link
Contributor

I'm mildly in favor of overloads to not break existing clients, and to not depend on the compiler's conversions, but I'll defer to Dmitri.

@swift-ci
Copy link
Collaborator

Comment by Russ Bishop (JIRA)

@gribozavr Any strong opinions?

@gribozavr
Copy link
Collaborator

Could you add more details, which tests were broken?

@swift-ci
Copy link
Collaborator

Comment by Russ Bishop (JIRA)

@gribozavr It's the `checkPtr` calls in `1_stdlib/UnsafePointer.swift.gyb` because it is passing a member function to a closure so the compiler magic conversion doesn't work. Changing the tests would be trivial.

My question is more philosophical - break user code by changing the existing signatures or add these as overloads?

I just got done running unit tests by implementing this with overloads (as per the original evolution proposal) and compiled foundation; everything worked as expected, nothing broken. Since this should also avoid breaking user code I would lean toward using overloads.

@gribozavr
Copy link
Collaborator

In this case, I think we would choose to break user code. The usecase in the test seems to be a corner case.

@swift-ci
Copy link
Collaborator

Comment by Russ Bishop (JIRA)

#2775

@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
Labels
good first issue Good for newcomers standard library Area: Standard library umbrella task
Projects
None yet
Development

No branches or pull requests

3 participants