Skip to content

[SE-0046] Implementation for consistent func labels #2047

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

Conversation

manavgabhawala
Copy link
Contributor

What's in this pull request?

Implements SE-0046 to provide consistent function labels (i.e. the first parameter no longer has special behavior for function labels).

I separated out the changes into separate commits depending on the part being changed so that its easier to review since this is a massive change across the entire repo. However, if it is preferred that this is merged as a single commit, I would be happy to squash into one commit.

I updated most of the swift code using Regex find and replace (and then manual verification where necessary) and since a lot of other repos are going to suffer source code breaking changes to make it easier for them, here are the regex strings I used:
For regular (non-generic) functions I did a search for func ([_a-zA-Z0-9]+?)(\s*?)\((\s*?)([a-zA-Z0-9]+?)(\s*?): and replaced with func \1\2(\3_ \4\5: By estimation this worked about 95% of the time and almost never found any false positives.
For generic functions I did a second search using: func ([_a-zA-Z0-9]+?)(\s*?)(<[\s\S]*?>)(\s*?)\((\s*?)([a-zA-Z0-9]+?)(\s*?): and replaced with func \1\2\3\4(\5_ \6\7: This worked about 90% of the time but be warned it does tend to find false positives (rarely).

Resolved bug number:

  • SR-961
  • rdar://problem/25279084

Before merging this pull request to apple/swift repository:

  • Review changes
  • Other swift repositories should be ready for a source code breaking change
  • Test pull request on Swift continuous integration.

Triggering Swift CI

The swift-ci is triggered by writing a comment on this PR addressed to the GitHub user @swift-ci. Different tests will run depending on the specific comment that you use. The currently available comments are:

Smoke Testing

Platform Comment
All supported platforms @swift-ci Please smoke test
OS X platform @swift-ci Please smoke test OS X platform
Linux platform @swift-ci Please smoke test Linux platform

Validation Testing

Platform Comment
All supported platforms @swift-ci Please test
OS X platform @swift-ci Please test OS X platform
Linux platform @swift-ci Please test Linux platform

Note: Only members of the Apple organization can trigger swift-ci.

@manavgabhawala manavgabhawala force-pushed the consistent-func-labels branch from ac9d274 to 7cae734 Compare April 4, 2016 07:21
C : Collection where C.Iterator.Element == Base.Iterator.Element
>(
bounds: Range<Base.Index>, with newElements: C
subRange bounds: Range<Base.Index>, with newElements: C
Copy link
Contributor

Choose a reason for hiding this comment

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

Please don't change the standard library API. It was already audited and it conforms to the guidelines.

@gribozavr
Copy link
Contributor

CC @harlanhaskins

@gribozavr
Copy link
Contributor

@manavgabhawala Thank you! I am extremely concerned about false positives. 95% is good, but not perfect. We can't allow any unintended changes in the standard library API. Did you manually audit all of the changes to the stdlib directory?

@harlanhaskins
Copy link
Contributor

@manavgabhawala Great job! I definitely share @gribozavr's concerns about API -- it's tedious but you'll need to manually verify your regex didn't cause any unintended API changes.

@manavgabhawala
Copy link
Contributor Author

@gribozavr @harlanhaskins I did not use the regex for any of the stdlib changes for exactly that reason. I did not change any of the APIs other than the replaceSubrange function (and not just in String, in all the containers), is because almost all of the declarations were of the form replaceSubrange(_ subRange:,with:) so I thought this might be an easier change to do. However if you want, I can go ahead and change all of these back to the original form.

@harlanhaskins
Copy link
Contributor

I think it's probably best to change it back for this pull request.

@harlanhaskins
Copy link
Contributor

There are some conflict markers scattered throughout stdlib/core/Reflection.swift

@manavgabhawala
Copy link
Contributor Author

@harlanhaskins will fix, thanks for the catch

@manavgabhawala manavgabhawala force-pushed the consistent-func-labels branch 3 times, most recently from ed2f09a to 6207d38 Compare April 4, 2016 23:24
@manavgabhawala
Copy link
Contributor Author

@harlanhaskins fixed all the changes requested

@harlanhaskins
Copy link
Contributor

Were those conflicts from abfecfd? Thanks for fixing those so quickly!

I'm gonna take another look over the changes to make sure nothing stands out.

@manavgabhawala
Copy link
Contributor Author

No I think they were from 9ce9784180be8ebc7744a7a295c6006f543da344. I had fixed them but I think I forgot to save the file before I rebased. But it should be fixed now. There are always conflicts every time there are new commits since this PR changes a lot of files.

Yeah absolutely, please make sure nothing stands out.

@harlanhaskins
Copy link
Contributor

We're also going to need to have branches ready to go in SPM, corelibs, lldb, and xctest, because as soon as Top-of-Tree swiftc receives this change, all subprojects will fail to build.

I'll coordinate with @mxcl, @parkera, @ddunbar, @modocache, and @eschaton to get their projects ready.

@manavgabhawala
Copy link
Contributor Author

Great, sounds good. Let me know if there's anything I can help with

@@ -69,8 +69,8 @@ public protocol _ArrayBufferProtocol : MutableCollection {
///
/// - Precondition: This buffer is backed by a uniquely-referenced
/// `_ContiguousArrayBuffer`.
mutating func replace<C : Collection where C.Iterator.Element == Element>(
subRange subRange: Range<Int>,
mutating func replaceSubrange<C : Collection where C.Iterator.Element == Element>(
Copy link
Contributor

Choose a reason for hiding this comment

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

Lingering API change here

@harlanhaskins
Copy link
Contributor

I can't see the file right now in GitHub's diff view (too many changes 😂), but whilst running tests I found a conflict marker in test/expr/unary/selector/selector.swift

@@ -392,8 +391,8 @@ extension _ArrayBuffer {
}
else {
var refCopy = self
refCopy.replace(
subRange: i...i, with: 1, elementsOf: CollectionOfOne(newValue))
refCopy.replaceSubrange(
Copy link
Contributor

Choose a reason for hiding this comment

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

API change here

@harlanhaskins
Copy link
Contributor

@manavgabhawala Also it looks like the extra diagnostics didn't get deleted from doc_swift_module.swift.response.

@gribozavr
Copy link
Contributor

@harlanhaskins I know. I hoped to get at least some CI feedback.

@gribozavr
Copy link
Contributor

And we have some:

/Users/buildnode/jenkins/workspace/swift-PR-osx/swift/stdlib/public/core/ObjCMirrors.swift:46:41: error: missing argument label 'object:' in call
    return _getClassPlaygroundQuickLook(object)

@harlanhaskins
Copy link
Contributor

Interesting! I didn't get that one when I built with --test --validation-test...

@harlanhaskins
Copy link
Contributor

Oh, these are new changes from master?

@manavgabhawala
Copy link
Contributor Author

@harlanhaskins can I rebase now, if you are done reviewing? so that I can fixup the new extra commits that I pushed and also get all the new changes to master?

@harlanhaskins
Copy link
Contributor

Yes, absolutely! Thanks again!

We're going to coordinate this with corelibs-foundation, XCTest, lldb, and SPM, to get all of these merged together at the same time.

There will undoubtedly be at least one more rebase in your future.

@shahmishal
Copy link
Member

@swift-ci Please test

@shahmishal
Copy link
Member

@swift-ci Please smoke test

@harlanhaskins
Copy link
Contributor

Smoke test passed. Are we set to merge? @gribozavr

We'll need to coordinate with swiftlang/swift-corelibs-xctest#92 and swiftlang/swift-corelibs-foundation#305

@harlanhaskins
Copy link
Contributor

Some conflicts just arose 😕

@manavgabhawala Mind fixing these and squashing into one commit?

@harlanhaskins
Copy link
Contributor

You just need to delete the definitions for insetBy and the like, inside stdlib/core/SDK/CoreGraphics/CoreGraphics.swift.

@manavgabhawala
Copy link
Contributor Author

@harlanhaskins do you want just one commit total, or squash into the current 5, correctly?

@harlanhaskins
Copy link
Contributor

@manavgabhawala One commit total, if possible.

…ng extraneous parameter names and adding _ where necessary
@manavgabhawala manavgabhawala force-pushed the consistent-func-labels branch from a6d2029 to 7928140 Compare April 7, 2016 00:22
@manavgabhawala
Copy link
Contributor Author

@harlanhaskins done. Should we re- smoke test?

@harlanhaskins
Copy link
Contributor

@manavgabhawala I don't think that will be necessary. @gribozavr?

@harlanhaskins harlanhaskins merged commit 510f29a into swiftlang:master Apr 7, 2016
@harlanhaskins
Copy link
Contributor

Thank you, @manavgabhawala!

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.

5 participants