Skip to content

[AST] Protocol conformance cleanups #8852

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 6 commits into from
Apr 19, 2017

Conversation

DougGregor
Copy link
Member

Various small cleanups for ProtocolConformance and its subclasses.

@DougGregor
Copy link
Member Author

@swift-ci please smoke test and merge

@DougGregor
Copy link
Member Author

Whoops, missed a bit. Sorry @swift-ci

@DougGregor DougGregor force-pushed the protocol-conformance-cleanups branch 2 times, most recently from cfe9db0 to 9636f9f Compare April 19, 2017 00:33
@DougGregor
Copy link
Member Author

@swift-ci please smoke test and merge

1 similar comment
@DougGregor
Copy link
Member Author

@swift-ci please smoke test and merge

@@ -608,7 +608,9 @@ SILGenModule::emitProtocolWitness(ProtocolConformance *conformance,
genericEnv = witnessRef.getDecl()->getInnermostDeclContext()
->getGenericEnvironmentOfContext();

Type concreteTy = conformance->getInterfaceType();
auto conformanceDC = conformance->getDeclContext();
Type concreteTy =
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this ever different from conformanceDC->getSelfInterfaceType()?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point. No, it isn't.

@slavapestov
Copy link
Contributor

Excellent!

Do you think normal conformances should be written in terms of interface types? In serialization there's a hack to map substitutions out of context and map them back in when serializing conformances, presumably because the normal conformance can form a cycle between a type and its generic environment.

If normal conformances stored interface types the map in/out of context can go away; the only place we should then be serializing archetypes inside substitutions is in the body of a SIL function, but there's no circularity issue there.

…Conformance.

NormalProtocolConformance has the only correct implementation of this
functionality. Instead, providing a safer getWitnessDecl() that
doesn't promise substitutions that are incorrect (and not actually
used by any clients).
@DougGregor DougGregor force-pushed the protocol-conformance-cleanups branch from 9636f9f to 51e0059 Compare April 19, 2017 06:38
@DougGregor
Copy link
Member Author

Yeah, type witnesses, too, could be in terms of interface types rather than contextual types. I do think that would be cleaner.

@DougGregor
Copy link
Member Author

@swift-ci please smoke test and merge

2 similar comments
@DougGregor
Copy link
Member Author

@swift-ci please smoke test and merge

@DougGregor
Copy link
Member Author

@swift-ci please smoke test and merge

@swift-ci swift-ci merged commit 504b6f2 into swiftlang:master Apr 19, 2017
@DougGregor DougGregor deleted the protocol-conformance-cleanups branch April 19, 2017 07:07
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.

3 participants