Skip to content

Change all remaining tests to use associatedtype instead of typealias in protocols #1557

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
Mar 10, 2016

Conversation

gregomni
Copy link
Contributor

@gregomni gregomni commented Mar 6, 2016

Split parsing for typealias & associatedtype, allow typealias in protocol, but not as a constraint in generics.

First step in getting real type aliases in protocols is to finish smoking out the ones that ought to be associated types. Cleaned up parsing of the two, including dropping a now unneeded ParseDeclOptions flag, made typealias in a protocol an error for the moment, and then converted all the places in the tests that didn’t care about it being a deprecation warning before but do care now.

Then made typealias in a protocol actually valid, which works great except that you can't use them in where clauses in generics. So added new diagnosis if you attempt to use a protocol’s typealias in a where clause, suggesting an associatedtype instead.

@gregomni gregomni force-pushed the typealias branch 3 times, most recently from 556d114 to 9ed62b2 Compare March 8, 2016 19:58
@gregomni gregomni changed the title [WIP] Typealiases inside protocols [Parse/Sema] Typealiases inside protocols Mar 8, 2016
@gregomni
Copy link
Contributor Author

gregomni commented Mar 8, 2016

I've backed off from trying to make type aliases inside protocols work in generic where clauses right away - it was taking longer than I thought it would, and this much of the work is separable and seems better as an individual pull anyway.

As an interim step, type aliases are now allowed inside protocols, we produce a specific diagnosis if you try to use them as if they were an associatedtype in a where clause, but otherwise they act like you would hope for protocol conformance purposes (i.e. as an alias, not as another hidden generic param).

@lattner I ended up in a merge conflict with your generic type aliases work. I think the resolution was fairly straightforward, but it'd be great if you could review the ParseDecl.cpp and test/decl/typealias/typealias.swift changes here when you have the time.

@lattner
Copy link
Contributor

lattner commented Mar 8, 2016

Oh, sorry about that, I'll take a look when I get a chance.

Unrelatedly, @DougGregor and I were discussing this briefly, in terms of how to land this in Swift 3. IIRC, he had some concerns about how this lands - we want to make sure that people who ignore the "deprecated" warnings in Swift 2 get an acceptable upgrade experience in Swift 3. Doug, do you have any specific guidance here?

@gregomni
Copy link
Contributor Author

gregomni commented Mar 8, 2016

@lattner No problem! Conflicts Happen.

The current behavior if you've ignored the deprecation warnings is that:

  • typealias A will complain that there is a missing = (assigning a type to the alias is required now, not optional). Maybe this ought to still have a better 'you probably meant associatedtype' diagnosis.
  • typealias A = Int will silently work for any type whose conformance actually uses Int (is this a problem? Not sure), and will fail with reasonable diagnoses if not (e.g. "protocol requires property 'foo' with type 'A' (aka 'Int')")

@gribozavr
Copy link
Contributor

Could you split test updates (typealias => associatedtype) into a separate PR? We could merge that immediately.

@gregomni
Copy link
Contributor Author

gregomni commented Mar 9, 2016

@gribozavr Good idea. Just did that here, all tests pass locally. You want to kick off a ci test, or shall I go ahead and just merge?

I'll re-add the actual feature changes in a separate pull request.

@gribozavr
Copy link
Contributor

@swift-ci Please test

@gribozavr
Copy link
Contributor

@gregomni Thank you! Could you also retitle the PR?

@gribozavr
Copy link
Contributor

@gregomni Feel free to merge when tests pass, thank you!

@gregomni gregomni changed the title [Parse/Sema] Typealiases inside protocols Change all remaining tests to use associatedtype instead of typealias in protocols Mar 9, 2016
@gregomni
Copy link
Contributor Author

gregomni commented Mar 9, 2016

@gribozavr Done, and will do!

@gregomni gregomni force-pushed the typealias branch 2 times, most recently from a5330d6 to 7931043 Compare March 10, 2016 02:07
gregomni added a commit that referenced this pull request Mar 10, 2016
Change all remaining tests to use associatedtype instead of typealias in protocols
@gregomni gregomni merged commit 5c16c10 into swiftlang:master Mar 10, 2016
MaxDesiatov pushed a commit that referenced this pull request Oct 19, 2020
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