-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Non-copyable generics fixes #71241
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
Non-copyable generics fixes #71241
Conversation
369fae7
to
a88a144
Compare
@swift-ci Please smoke test |
a88a144
to
91adc2f
Compare
@swift-ci Please smoke test |
91adc2f
to
d5c6be4
Compare
@swift-ci Please test source compatibility |
a7e0f9c
to
ccd7427
Compare
// Force creation of the generic signature. | ||
(void) ED->getGenericSignature(); | ||
dumpGenericSignature(Ctx, ED); | ||
|
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'm curious why we have to do this now.
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.
We force certain requests in TypeCheckDeclPrimary just to ensure diagnostics are emitted before we go on to SILGen. (This isn't new, I just moved some code around so that the -debug-generic-signature behavior happens here instead of in TypeCheckGeneric.cpp.)
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.
Only reviewed the code completion parts.
LLVM_DEBUG(llvm::dbgs() << "Adding conformed protocol " | ||
<< Conformance->getProtocol()->getName() | ||
<< "\n";); |
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.
Are these debug statements intentionally left?
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.
They're only active when you run with -Xllvm -debug-only=CodeCompletionResultType
@@ -22,6 +22,9 @@ using namespace swift; | |||
using namespace ide; | |||
using TypeRelation = CodeCompletionResultTypeRelation; | |||
|
|||
#define DEBUG_TYPE "CodeCompletionResultType" |
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.
Stupid question: What is DEBUG_TYPE
used for?
SmallVector<const USRBasedType *, 2> Supertypes; | ||
; | ||
if (auto Nominal = Ty->getAnyNominal()) { | ||
if (auto *Proto = dyn_cast<ProtocolDecl>(Nominal)) { | ||
Proto->walkInheritedProtocols([&](ProtocolDecl *inherited) { | ||
if (Proto != inherited && | ||
!inherited->isSpecificProtocol(KnownProtocolKind::Sendable)) { | ||
!inherited->isSpecificProtocol(KnownProtocolKind::Sendable) && | ||
!inherited->getInvertibleProtocolKind()) { |
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’m not sure how the inverted protocols are modeled in the AST but shouldn’t we check if the specific conformance is inverted (ie. has ~
) instead of checking whether the protocol is invertible?
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.
We're just skipping these protocols entirely here because we get the wrong USRs for their ProtocolDecls. Once the USR mangling is fixed we can remove this hack.
// FIXME: Copyable and Escapable conformances are skipped because the | ||
// USR mangling produces the type 'Any' for the protocol type. |
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.
Why does it produce Any
for the protocol name?
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.
Because we need to fix the mangling.
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.
Ah, I see. Thanks for the clarification. Is the name mangling something we are planning to fix in the short term?
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, because we need to distinguish Any
(which is now formally <Self where Self: Copyable, Self: Escapable>
but must mangle as before) from any ~Copyable
(<Self where Self: Escapable>
, which needs a new mangling invented) and any ~Escapable
(<Self where Self: Copyable>
, ditto). Right now we simply strip out Copyable and Escapable from existentials before mangling, which is not correct.
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.
OK, great 👍🏽
ccd7427
to
6a7f718
Compare
…lTypeDecl from a SynthesizedFileUnit
We want extensions to introduce default Copyable/Escapable just like other generic contexts, so that once Optional adopts ~Copyable, an `extension Optional` actually adds `Wrapped: Copyable` by default.
…checkConformance()
6a7f718
to
d8f85a3
Compare
@swift-ci Please smoke test |
This fixes some validation test failures when non-copyable generics are enabled. Should be NFC otherwise.