Skip to content

Commit 4356843

Browse files
committed
---
yaml --- r: 349144 b: refs/heads/master-next c: 5964ce4 h: refs/heads/master
1 parent e2c01ab commit 4356843

File tree

4 files changed

+30
-17
lines changed

4 files changed

+30
-17
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
refs/heads/master: 3574c513bbc5578dd9346b4ea9ab5995c5927bb5
3-
refs/heads/master-next: 7d2dac1272c0906fe3792cd04a9c7182b876d87b
3+
refs/heads/master-next: 5964ce47b042d66dc9732fc56338c5bbfcee67b0
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea
66
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-b: 66d897bfcf64a82cb9a87f5e663d889189d06d07

branches/master-next/include/swift/AST/Decl.h

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6909,7 +6909,6 @@ class OperatorDecl : public Decl {
69096909
/// \endcode
69106910
class InfixOperatorDecl : public OperatorDecl {
69116911
SourceLoc ColonLoc;
6912-
PrecedenceGroupDecl *PrecedenceGroup = nullptr;
69136912

69146913
public:
69156914
InfixOperatorDecl(DeclContext *DC, SourceLoc operatorLoc, Identifier name,
@@ -6920,14 +6919,6 @@ class InfixOperatorDecl : public OperatorDecl {
69206919
identifiers, identifierLocs),
69216920
ColonLoc(colonLoc) {}
69226921

6923-
InfixOperatorDecl(DeclContext *DC, SourceLoc operatorLoc, Identifier name,
6924-
SourceLoc nameLoc, SourceLoc colonLoc,
6925-
PrecedenceGroupDecl *precedenceGroup,
6926-
ArrayRef<NominalTypeDecl *> designatedNominalTypes)
6927-
: OperatorDecl(DeclKind::InfixOperator, DC, operatorLoc, name, nameLoc,
6928-
designatedNominalTypes),
6929-
ColonLoc(colonLoc), PrecedenceGroup(precedenceGroup) {}
6930-
69316922
SourceLoc getEndLoc() const {
69326923
auto identifierLocs = getIdentifierLocs();
69336924
if (identifierLocs.empty())
@@ -6942,10 +6933,7 @@ class InfixOperatorDecl : public OperatorDecl {
69426933

69436934
SourceLoc getColonLoc() const { return ColonLoc; }
69446935

6945-
PrecedenceGroupDecl *getPrecedenceGroup() const { return PrecedenceGroup; }
6946-
void setPrecedenceGroup(PrecedenceGroupDecl *PGD) {
6947-
PrecedenceGroup = PGD;
6948-
}
6936+
PrecedenceGroupDecl *getPrecedenceGroup() const;
69496937

69506938
/// True if this decl's attributes conflict with those declared by another
69516939
/// operator.

branches/master-next/lib/AST/Decl.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7471,6 +7471,28 @@ PrecedenceGroupDecl::PrecedenceGroupDecl(DeclContext *dc,
74717471
lowerThan.size() * sizeof(Relation));
74727472
}
74737473

7474+
llvm::Expected<PrecedenceGroupDecl *> LookupPrecedenceGroupRequest::evaluate(
7475+
Evaluator &eval, PrecedenceGroupDescriptor descriptor) const {
7476+
auto *dc = descriptor.dc;
7477+
PrecedenceGroupDecl *group = nullptr;
7478+
if (auto sf = dc->getParentSourceFile()) {
7479+
bool cascading = dc->isCascadingContextForLookup(false);
7480+
group = sf->lookupPrecedenceGroup(descriptor.ident, cascading,
7481+
descriptor.nameLoc);
7482+
} else {
7483+
group = dc->getParentModule()->lookupPrecedenceGroup(descriptor.ident,
7484+
descriptor.nameLoc);
7485+
}
7486+
return group;
7487+
}
7488+
7489+
PrecedenceGroupDecl *InfixOperatorDecl::getPrecedenceGroup() const {
7490+
return evaluateOrDefault(
7491+
getASTContext().evaluator,
7492+
OperatorPrecedenceGroupRequest{const_cast<InfixOperatorDecl *>(this)},
7493+
nullptr);
7494+
}
7495+
74747496
bool FuncDecl::isDeferBody() const {
74757497
return getName() == getASTContext().getIdentifier("$defer");
74767498
}

branches/master-next/lib/Serialization/Deserialization.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3294,9 +3294,12 @@ class swift::DeclDeserializer {
32943294

32953295
auto result = MF.createDecl<InfixOperatorDecl>(
32963296
DC, SourceLoc(), MF.getIdentifier(nameID), SourceLoc(), SourceLoc(),
3297-
cast_or_null<PrecedenceGroupDecl>(precedenceGroup.get()),
3298-
ctx.AllocateCopy(designatedNominalTypes));
3299-
3297+
ArrayRef<Identifier>{}, ArrayRef<SourceLoc>{});
3298+
result->setDesignatedNominalTypes(ctx.AllocateCopy(designatedNominalTypes));
3299+
ctx.evaluator.cacheOutput(
3300+
OperatorPrecedenceGroupRequest{result},
3301+
std::move(cast_or_null<PrecedenceGroupDecl>(precedenceGroup.get())));
3302+
33003303
declOrOffset = result;
33013304
return result;
33023305
}

0 commit comments

Comments
 (0)