@@ -2074,14 +2074,14 @@ static void checkDesignatedProtocol(OperatorDecl *OD, Identifier name,
2074
2074
}
2075
2075
2076
2076
if (!typeLoc.isError ()) {
2077
+ OD->setDesignatedProtocolTypeLoc (typeLoc);
2077
2078
auto *decl = typeLoc.getType ()->getNominalOrBoundGenericNominal ();
2078
2079
if (!decl || !isa<ProtocolDecl>(decl)) {
2079
2080
tc.diagnose (typeLoc.getLoc (),
2080
2081
diag::operators_designated_protocol_not_a_protocol,
2081
2082
typeLoc.getType ());
2082
2083
OD->setInvalid ();
2083
2084
} else {
2084
- OD->setDesignatedProtocol (cast<ProtocolDecl>(decl));
2085
2085
// FIXME: verify this operator has a declaration within this
2086
2086
// protocol with the same arity and fixity
2087
2087
}
@@ -2104,9 +2104,9 @@ void TypeChecker::validateDecl(OperatorDecl *OD) {
2104
2104
2105
2105
// Pre- or post-fix operator?
2106
2106
if (!IOD) {
2107
- auto *protocol = OD->getDesignatedProtocol ();
2107
+ auto typeLoc = OD->getDesignatedProtocolTypeLoc ();
2108
2108
auto protocolId = OD->getDesignatedProtocolName ();
2109
- if (!protocol && !protocolId.empty () &&
2109
+ if (typeLoc. isNull () && !protocolId.empty () &&
2110
2110
enableOperatorDesignatedProtocols) {
2111
2111
auto protocolIdLoc = OD->getDesignatedProtocolNameLoc ();
2112
2112
checkDesignatedProtocol (OD, protocolId, protocolIdLoc, *this , Context);
@@ -2127,8 +2127,8 @@ void TypeChecker::validateDecl(OperatorDecl *OD) {
2127
2127
}
2128
2128
2129
2129
auto secondId = IOD->getSecondIdentifier ();
2130
- auto *protocol = IOD->getDesignatedProtocol ();
2131
- if (!protocol && enableOperatorDesignatedProtocols) {
2130
+ auto typeLoc = IOD->getDesignatedProtocolTypeLoc ();
2131
+ if (typeLoc. isNull () && enableOperatorDesignatedProtocols) {
2132
2132
auto secondIdLoc = IOD->getSecondIdentifierLoc ();
2133
2133
assert (secondId.empty () || !firstId.empty ());
2134
2134
@@ -2140,7 +2140,7 @@ void TypeChecker::validateDecl(OperatorDecl *OD) {
2140
2140
2141
2141
if (!group && !IOD->isInvalid ()) {
2142
2142
if (!firstId.empty () &&
2143
- (!secondId.empty () || ! IOD->getDesignatedProtocol ())) {
2143
+ (!secondId.empty () || IOD->getDesignatedProtocolTypeLoc (). isNull ())) {
2144
2144
diagnose (firstIdLoc, diag::unknown_precedence_group, firstId);
2145
2145
IOD->setInvalid ();
2146
2146
}
0 commit comments