Skip to content

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

Merged
merged 1 commit into from
Sep 12, 2018
Merged

Add serialization/deserialization support for designated protocols fo… #19194

merged 1 commit into from
Sep 12, 2018

Conversation

rudkx
Copy link
Contributor

@rudkx rudkx commented Sep 7, 2018

…r operators.

Parsing for these protocols in operator declarations is gated by
-enable-operator-designated-protocols (added in
#19145).

@rudkx
Copy link
Contributor Author

rudkx commented Sep 7, 2018

@swift-ci Please smoke test

DeclContextIDField // context decl
IdentifierIDField, // name
DeclContextIDField, // context decl
TypeIDField // protocol
Copy link
Contributor

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?

Copy link
Contributor Author

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));
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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();
Copy link
Contributor

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?

Copy link
Contributor Author

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?

@rudkx
Copy link
Contributor Author

rudkx commented Sep 10, 2018

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).
@rudkx
Copy link
Contributor Author

rudkx commented Sep 11, 2018

@swift-ci Please smoke test

@rudkx rudkx merged commit 3f74fbc into swiftlang:master Sep 12, 2018
@rudkx rudkx deleted the serialization-for-designated-protocols branch September 12, 2018 00:19
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.

2 participants