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
Comments
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? |
I think that fixing the tests is the right path. @belkadan do you have an opinion on this? |
@gribozavr may also have a strong opinion here. |
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. |
Comment by Russ Bishop (JIRA) @gribozavr Any strong opinions? |
Could you add more details, which tests were broken? |
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. |
In this case, I think we would choose to break user code. The usecase in the test seems to be a corner case. |
Comment by Russ Bishop (JIRA) |
Additional Detail from JIRA
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.
The text was updated successfully, but these errors were encountered: