-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[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
[AST] Protocol conformance cleanups #8852
Conversation
We don't need this notion.
Otherwise, we could theoretically get collisions, although they are quite unlikely to matter in practice.
@swift-ci please smoke test and merge |
Whoops, missed a bit. Sorry @swift-ci |
cfe9db0
to
9636f9f
Compare
@swift-ci please smoke test and merge |
1 similar comment
@swift-ci please smoke test and merge |
lib/SILGen/SILGenType.cpp
Outdated
@@ -608,7 +608,9 @@ SILGenModule::emitProtocolWitness(ProtocolConformance *conformance, | |||
genericEnv = witnessRef.getDecl()->getInnermostDeclContext() | |||
->getGenericEnvironmentOfContext(); | |||
|
|||
Type concreteTy = conformance->getInterfaceType(); | |||
auto conformanceDC = conformance->getDeclContext(); | |||
Type concreteTy = |
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.
Is this ever different from conformanceDC->getSelfInterfaceType()?
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.
Good point. No, it isn't.
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).
9636f9f
to
51e0059
Compare
Yeah, type witnesses, too, could be in terms of interface types rather than contextual types. I do think that would be cleaner. |
@swift-ci please smoke test and merge |
Various small cleanups for
ProtocolConformance
and its subclasses.