-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Add serialization/deserialization support for designated protocols fo… #19194
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
Add serialization/deserialization support for designated protocols fo… #19194
Conversation
@swift-ci Please smoke test |
DeclContextIDField // context decl | ||
IdentifierIDField, // name | ||
DeclContextIDField, // context decl | ||
TypeIDField // protocol |
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 should really be serialized as a Decl, not a Type, no?
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.
Yes that makes sense given that I am only using the type to get to the decl at this point. An earlier version of this added constructors for OperatorDecls that took TypeLocs.
declOrOffset = createDecl<PrefixOperatorDecl>(DC, SourceLoc(), | ||
getIdentifier(nameID), | ||
SourceLoc()); | ||
TypeLoc protoTyLoc = TypeLoc::withoutLoc(getType(protoID)); |
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.
Note that this has poor recovery (read: will crash) if the protocol can't be deserialized for whatever reason. That's probably fine for now, but really there should be a recovery mechanism.
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.
What's a better approach? We seem to be doing something very similar in other places.
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.
Look for the uses of getTypeChecked
elsewhere in the file. Moving over to that for everything is a big task, but we probably want new fields to be thinking about recovery.
Identifier protocolName; | ||
if (auto protoTy = protoTyLoc.getType()) | ||
if (auto *protoDecl = protoTy->getNominalOrBoundGenericNominal()) | ||
protocolName = protoDecl->getName(); |
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 only skimmed your previous proposal, but this confuses me: an identifier isn't enough to uniquely identify a type, so why bother?
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 don't understand what you're asking here, can you clarify?
I'll push another version of this once #19202 lands. |
…r operators. Parsing for these protocols in operator declarations is gated by -enable-operator-designated-protocols (added in #19145).
@swift-ci Please smoke test |
…r operators.
Parsing for these protocols in operator declarations is gated by
-enable-operator-designated-protocols (added in
#19145).