-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Extend operator decls to allow any designated nominal type for lookup. #19756
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
Conversation
Rather than limiting this to protocols, allow any nominal type. Rename -enable-operator-designated-protocols to -enable-operator-designated-types to reflect the change.
@swift-ci Please smoke test |
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.
Besides minor renaming nits, LGTM!
lib/Sema/TypeCheckDecl.cpp
Outdated
enableOperatorDesignatedProtocols) { | ||
auto protocolIdLoc = OD->getDesignatedProtocolNameLoc(); | ||
checkDesignatedProtocol(OD, protocolId, protocolIdLoc, *this, Context); | ||
auto *protocol = OD->getDesignatedNominalType(); |
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.
Probably needs renaming too?
lib/Sema/TypeCheckDecl.cpp
Outdated
@@ -2127,20 +2120,20 @@ void TypeChecker::validateDecl(OperatorDecl *OD) { | |||
} | |||
|
|||
auto secondId = IOD->getSecondIdentifier(); | |||
auto *protocol = IOD->getDesignatedProtocol(); | |||
if (!protocol && enableOperatorDesignatedProtocols) { | |||
auto *protocol = IOD->getDesignatedNominalType(); |
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.
Here is as well...
lib/Serialization/Serialization.cpp
Outdated
@@ -2878,7 +2878,7 @@ void Serializer::writeDecl(const Decl *D) { | |||
auto contextID = addDeclContextRef(op->getDeclContext()); | |||
auto nameID = addDeclBaseNameRef(op->getName()); | |||
auto groupID = addDeclRef(op->getPrecedenceGroup()); | |||
auto protoID = addDeclRef(op->getDesignatedProtocol()); | |||
auto protoID = addDeclRef(op->getDesignatedNominalType()); |
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.
All of names here have to be nominalID
?
@xedin Thanks for catching those. I have other edits to extend this further, but I've fixed up the naming prior to merging. |
@swift-ci Please smoke test |
…BE-61E65F8A7618 [test] Fix a solver flag rename that was missed in #19756.
Rather than limiting this to protocols, allow any nominal type.
Rename -enable-operator-designated-protocols to
-enable-operator-designated-types to reflect the change.