Skip to content

Renamed DictionaryLiteral to KeyValuePairs #16577

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 7 commits into from
Aug 27, 2018

Conversation

masters3d
Copy link
Contributor

Implementation for swiftlang/swift-evolution#850

"There is no strong motivation to deprecate. The type does not produce
active harm. Instead, it adds measurable (if small) utility and will be
part of the ABI. A sensible renaming mitigates the most problematic
issue with the type."

@masters3d
Copy link
Contributor Author

masters3d commented May 12, 2018

@swift-ci Please smoke test
^
I don't think that worked. Can somebody kick the CI? Thanks!

@slavapestov
Copy link
Contributor

@swift-ci Please test

@slavapestov
Copy link
Contributor

@swift-ci Please test source compatibility

@slavapestov
Copy link
Contributor

I agree the type itself should not be deprecated, but I think the old name should be deprecated. What do you think?

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 19eeb4a76657cf00f5a1a8dca78ea7c885ca082a

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 19eeb4a76657cf00f5a1a8dca78ea7c885ca082a

@nh7a
Copy link

nh7a commented May 13, 2018

The proposal is suggesting KeyValueList, not KeyValueArray, though.

@masters3d
Copy link
Contributor Author

masters3d commented May 13, 2018

@nh7a I'll leave it as KeyValueArray until the final name is decided if accepted.

@slavapestov Sounds good. I misinterpreted "There is no strong motivation to deprecate".
1) Do you have any ideas how I can fix the typealias failing at SPM.
2) Do I need to worry about stdlib-stable.json?

@@ -149,7 +149,7 @@ class alignas(8) Expr {
IsTypeDefaulted : 1,
/// Number of comma source locations.
NumCommas : 32 - 1 - NumExprBits,
/// Number of entries in the collection. If this is a DictionaryLiteral,
/// Number of entries in the collection. If this is a KeyValueArray,
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this refers to DictionaryExpr (which is a subclass of CollectionExpr).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

/// Number of entries in the collection. If this is a KeyValueArray, /// each entry is a Tuple with the key and value pair

The Tuple entry suggested to me that is the type and not the literal.
There are other places where the comments do refer to the same name while referring to the type.

Unless nessesary I am not going to change other usages in the project yet until CI is green.

Copy link
Contributor

Choose a reason for hiding this comment

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

The tuples are probably those given to any init(dictionaryLiteral:) initializer. I don't think AST/Expr.h would need to have any knowledge of the KeyValueArray type.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is part of the confusion and reason behind the rename. I believe while AST/Expr.h has not much to do with concrete types, the comment seems to be referring to the concrete type. Since this comment is not user facing I am not too worried about it. You are welcome to change it back. I added you as a collaborator to my branch. Are you able to start the CI? Thanks!

@masters3d masters3d force-pushed the renamed-to-KeyValueArray branch from 0b9dee7 to 1148c86 Compare May 17, 2018 00:39
@masters3d
Copy link
Contributor Author

@swift-ci Please test source compatibility

@aciidgh
Copy link
Contributor

aciidgh commented May 21, 2018

@swift-ci Please test source compatibility

@aciidgh
Copy link
Contributor

aciidgh commented May 21, 2018

@swift-ci please test source compatibility

@masters3d
Copy link
Contributor Author

masters3d commented May 22, 2018

none of the failures I saw are related https://ci.swift.org/job/swift-PR-source-compat-suite/1219/artifact/swift-source-compat-suite/

Aside from the Package Manager, most people do not seem to know or extend the type so I think there will not be any source compatibility issues.
https://github.com/search?p=2&q="extension+DictionaryLiteral+where"&type=Code&utf8=✓

@masters3d masters3d force-pushed the renamed-to-KeyValueArray branch from 1148c86 to 10768f2 Compare June 15, 2018 04:09
@masters3d masters3d changed the title Renamed DictionaryLiteral to KeyValueArray Renamed DictionaryLiteral to KeyValuePairs Jun 15, 2018
@masters3d
Copy link
Contributor Author

masters3d commented Jun 15, 2018

Updated. Not sure what to do about stdlib-stable.json

@lattner
Copy link
Contributor

lattner commented Jun 15, 2018

Great works @masters3d. The patch LGTM, but it would be good to get a standard library reviewer like @airspeedswift or @dabrahams to take a look.

Copy link
Member

@airspeedswift airspeedswift left a comment

Choose a reason for hiding this comment

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

LGTM with the exception of the question of the deprecation.

@airspeedswift
Copy link
Member

This all looks good to me. However, I am not sure about the deprecation in 4.2. While we could do it in 4.2, I think that's a little aggressive.

My preference would be to add the new name as a typealias in 4.2 now, and to deprecate the old name in 5.0. That way, people will be able to update their code bases in advance, and once 5.0 comes around, we can deprecate the old name in a way that means users will be able to compile without warnings with both the 4.2 and 5.0 compiler.

@lattner
Copy link
Contributor

lattner commented Jun 17, 2018

I don't think this type is widely used (does it appear in the source compat suite at all?) so I don't think that warning in 4.2 will be too aggressive. That said, your approach is also totally fine with me.

@masters3d
Copy link
Contributor Author

Updated.

@masters3d
Copy link
Contributor Author

Can this be merged?

@airspeedswift
Copy link
Member

@swift-ci please test and merge

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 266de1fe81641dd2adfb4c4beb73a2cdea53b73d

@benrimmington
Copy link
Contributor

The failure is due to a missing type change in test/api-digester/source-stability.swift.expected

 Var Dictionary.values has declared type change from LazyMapCollection<[Key : Value], Value> to Dictionary<Key, Value>.Values
+Constructor Mirror.init(_:children:displayStyle:ancestorRepresentation:) has parameter 1 type change from DictionaryLiteral<String, Any> to KeyValuePairs<String, Any>
 Constructor String.init(_:) has return type change from String? to String

@airspeedswift
Copy link
Member

@akyrtzi should that api difference be firing? the one is a typealias of the other.

@akyrtzi
Copy link
Contributor

akyrtzi commented Aug 23, 2018

\CC @nkcsgexi

@airspeedswift
Copy link
Member

I mean, it'd be an ABI break once we stabilize the ABI, but it shouldn't be a source compatibility break.

@nkcsgexi
Copy link
Contributor

Can we update the expected change list for now to unblock the merging of this patch?

@airspeedswift
Copy link
Member

sure, just want to check if it's a bug that it flagged.

@nkcsgexi
Copy link
Contributor

yeah, i think the api checker currently isn't smart enough to tell a type alias change is benign for source compatibility. This won't be an issue when we check abi stability because abi checker compares module dumps with all types canonicalized.

@airspeedswift
Copy link
Member

Hi @masters3d can you add that entry to the expected results to fix the test for now? Thanks!

@masters3d masters3d force-pushed the renamed-to-KeyValueArray branch from 266de1f to bbe474f Compare August 26, 2018 19:54
@masters3d
Copy link
Contributor Author

@airspeedswift @benrimmington updated

@airspeedswift
Copy link
Member

@swift-ci please test

@airspeedswift
Copy link
Member

@swift-ci please test source compatibility

@swiftlang swiftlang deleted a comment from swift-ci Aug 26, 2018
@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 266de1fe81641dd2adfb4c4beb73a2cdea53b73d

@airspeedswift
Copy link
Member

Those failures are spurious CI artifacts, not actual failures.

@airspeedswift
Copy link
Member

@swift-ci please test macOS platform

@airspeedswift
Copy link
Member

@shahmishal any idea why macOS tests aren't triggering on this PR?

@shahmishal
Copy link
Member

It's running - https://ci.swift.org/job/swift-PR-osx/7078/

@benrimmington
Copy link
Contributor

@airspeedswift All checks have passed!

But I'm not sure if the source compatibility was tested.

@airspeedswift airspeedswift merged commit a527e53 into swiftlang:master Aug 27, 2018
@masters3d
Copy link
Contributor Author

Thank you swift team! Thanks @benrimmington !

@masters3d masters3d deleted the renamed-to-KeyValueArray branch August 27, 2018 18:47
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.