-
Notifications
You must be signed in to change notification settings - Fork 10.5k
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
Renamed DictionaryLiteral to KeyValuePairs #16577
Conversation
@swift-ci Please smoke test |
@swift-ci Please test |
@swift-ci Please test source compatibility |
I agree the type itself should not be deprecated, but I think the old name should be deprecated. What do you think? |
Build failed |
Build failed |
The proposal is suggesting |
@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". |
include/swift/AST/Expr.h
Outdated
@@ -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, |
There was a problem hiding this comment.
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
).
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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!
0b9dee7
to
1148c86
Compare
@swift-ci Please test source compatibility |
@swift-ci Please test source compatibility |
@swift-ci please test source compatibility |
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. |
1148c86
to
10768f2
Compare
Updated. Not sure what to do about stdlib-stable.json |
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. |
There was a problem hiding this 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.
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. |
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. |
Updated. |
Can this be merged? |
@swift-ci please test and merge |
Build failed |
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 |
@akyrtzi should that api difference be firing? the one is a typealias of the other. |
\CC @nkcsgexi |
I mean, it'd be an ABI break once we stabilize the ABI, but it shouldn't be a source compatibility break. |
Can we update the expected change list for now to unblock the merging of this patch? |
sure, just want to check if it's a bug that it flagged. |
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. |
Hi @masters3d can you add that entry to the expected results to fix the test for now? Thanks! |
266de1f
to
bbe474f
Compare
@airspeedswift @benrimmington updated |
@swift-ci please test |
@swift-ci please test source compatibility |
Build failed |
Those failures are spurious CI artifacts, not actual failures. |
@swift-ci please test macOS platform |
@shahmishal any idea why macOS tests aren't triggering on this PR? |
It's running - https://ci.swift.org/job/swift-PR-osx/7078/ |
@airspeedswift All checks have passed! But I'm not sure if the source compatibility was tested. |
Thank you swift team! Thanks @benrimmington ! |
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."