Skip to content

swift-module-digester: diagnose adding/removing protocol conformances as API breakages. #19427

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 2 commits into from
Sep 21, 2018

Conversation

nkcsgexi
Copy link
Contributor

No description provided.

@nkcsgexi
Copy link
Contributor Author

@swift-ci please smoke test

@@ -58,6 +58,10 @@ ERROR(decl_added,none,"%0 is added to a non-resilient type", (StringRef))

ERROR(default_arg_removed,none,"%0 has removed default argument from %1", (StringRef, StringRef))

ERROR(conformance_removed,none,"%0 has removed conformance to %1", (StringRef, StringRef))

ERROR(conformance_added,none,"%0 has added conformance to %1", (StringRef, StringRef))
Copy link
Contributor

Choose a reason for hiding this comment

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

Adding a conformance is not an API or ABI break.

Also I'm assuming this applies to resilient types too, and if the conformance is defined in an extension?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The check performs on all types and if the conformance is defined in extensions. Adding conformances can be a problem for protocols (i.e. adding inherited protools).

Copy link
Contributor

Choose a reason for hiding this comment

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

Please don't model inherited protocols as conformances. Adding an inherited protocol is indeed an API and ABI break, but that's the only case.

A bona-fide "conformance" always involves a concrete type and is its own thing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's already been scoped to protocol only in TOT and we've reworded the diagnostic message.

@@ -701,7 +721,16 @@ bool SDKNode::operator==(const SDKNode &Other) const {
}
LLVM_FALLTHROUGH;
}
case SDKNodeKind::DeclType:
case SDKNodeKind::DeclType: {
Copy link
Contributor

Choose a reason for hiding this comment

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

What if I'm adding a conformance in an extension, and the extended type is from a different module? You really should model conformances as top-level entities, and not as part of types. Then adding a new conformance is fine (just like adding a new top-level function), but removing one is not allowed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If the extension is for a type from a different module, the tool will synthesize the type definition in its module dump (here). So the standalone extension won't be missed.

@nkcsgexi nkcsgexi force-pushed the diagnose-conformance branch from ef5ce32 to 08c8cf1 Compare September 20, 2018 22:24
@nkcsgexi
Copy link
Contributor Author

@swift-ci please smoke test

…xternal type, we should synthesize only one type decl node.
@nkcsgexi
Copy link
Contributor Author

@swift-ci please smoke test

@nkcsgexi
Copy link
Contributor Author

@swift-ci Please smoke test Linux platform

@nkcsgexi nkcsgexi merged commit 0ad67cb into swiftlang:master Sep 21, 2018
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