Skip to content

Conversation

@xedin
Copy link
Contributor

@xedin xedin commented May 26, 2017

Enum elements have to be treated the same way as regular functions
when passed as values, which means labels have to be stripped from
their argument types.

Resolves: rdar://problem/32300339.

@xedin xedin requested a review from slavapestov May 26, 2017 08:09
@xedin
Copy link
Contributor Author

xedin commented May 26, 2017

/cc @slavapestov please take a look and let me know what you think

@xedin
Copy link
Contributor Author

xedin commented May 26, 2017

@swift-ci please smoke test

@xedin
Copy link
Contributor Author

xedin commented May 26, 2017

@swift-ci please test source compatibility

@xedin xedin requested a review from rudkx May 26, 2017 18:17
Copy link
Contributor

@rudkx rudkx left a comment

Choose a reason for hiding this comment

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

Otherwise LGTM.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's safer to have this under the version check, but is it actually necessary?

What I'm wondering is if there might be cases where the Swift 3 behavior is also broken.

Copy link
Contributor

Choose a reason for hiding this comment

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

The Swift 3 behavior is broken if your enum argument type has multiple elements.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please either remove this comment, or rewrite it to talk about the common behavior of both functions and enum cases.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please put this in a new file, test/Compatibility/enum_cases.swift.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please put this in a new file, test/Constraints/enum_cases.swift.

Both files need a lot more tests, for example it would be nice to test:

  • case has no label
  • case has label
  • case is a tuple with multiple elements, some of which have labels
  • assign case to a 'let' binding with an explicit type

@slavapestov
Copy link
Contributor

I wonder if we can get rid of scalar-to-tuple conversions entirely in Swift 4 mode once this goes in.

Enum elements have to be treated the same way as regular functions
when passed as values, which means labels have to be stripped from
their argument types.

Resolves: rdar://problem/32300339.
@xedin
Copy link
Contributor Author

xedin commented May 26, 2017

@slavapestov @rudkx I've addressed all of the notes - reformatted the comment and added a bunch more tests to the {Compatibility, Constraints}/enum_cases.swift . Also added a test which show the different in behavior between swift 3 and 4.

@slavapestov
Copy link
Contributor

LGTM!

@rudkx
Copy link
Contributor

rudkx commented May 26, 2017

Looks great!

@xedin
Copy link
Contributor Author

xedin commented May 26, 2017

@swift-ci please test and merge

@slavapestov
Copy link
Contributor

slavapestov commented May 26, 2017

@xedin We should get this into swift-4.0-branch.

@xedin
Copy link
Contributor Author

xedin commented May 26, 2017

@slavapestov Will do!

@xedin xedin merged commit 1798d1e into swiftlang:master May 27, 2017
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.

3 participants