Skip to content

Commit cf09773

Browse files
committed
ASTBridging: Bridge swift::Associativity directly
1 parent 38360fe commit cf09773

File tree

4 files changed

+14
-20
lines changed

4 files changed

+14
-20
lines changed

include/swift/AST/ASTBridging.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,12 +1672,6 @@ BridgedOperatorDecl BridgedOperatorDecl_createParsed(
16721672
BridgedSourceLoc cColonLoc, BridgedIdentifier cPrecedenceGroupName,
16731673
BridgedSourceLoc cPrecedenceGroupLoc);
16741674

1675-
enum ENUM_EXTENSIBILITY_ATTR(closed) BridgedAssociativity {
1676-
BridgedAssociativityNone,
1677-
BridgedAssociativityLeft,
1678-
BridgedAssociativityRight,
1679-
};
1680-
16811675
SWIFT_NAME("BridgedPrecedenceGroupDecl.createParsed(declContext:"
16821676
"precedencegroupKeywordLoc:name:nameLoc:leftBraceLoc:"
16831677
"associativityLabelLoc:associativityValueLoc:associativity:"
@@ -1689,8 +1683,8 @@ BridgedPrecedenceGroupDecl BridgedPrecedenceGroupDecl_createParsed(
16891683
BridgedSourceLoc cPrecedencegroupKeywordLoc, BridgedIdentifier cName,
16901684
BridgedSourceLoc cNameLoc, BridgedSourceLoc cLeftBraceLoc,
16911685
BridgedSourceLoc cAssociativityKeywordLoc,
1692-
BridgedSourceLoc cAssociativityValueLoc,
1693-
BridgedAssociativity cAssociativity, BridgedSourceLoc cAssignmentKeywordLoc,
1686+
BridgedSourceLoc cAssociativityValueLoc, swift::Associativity associativity,
1687+
BridgedSourceLoc cAssignmentKeywordLoc,
16941688
BridgedSourceLoc cAssignmentValueLoc, bool isAssignment,
16951689
BridgedSourceLoc cHigherThanKeywordLoc, BridgedArrayRef cHigherThanNames,
16961690
BridgedSourceLoc cLowerThanKeywordLoc, BridgedArrayRef cLowerThanNames,

include/swift/AST/AttrKind.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,19 @@ class StringRef;
2929
namespace swift {
3030

3131
/// The associativity of a binary operator.
32-
enum class Associativity : uint8_t {
32+
enum class ENUM_EXTENSIBILITY_ATTR(closed) Associativity : uint8_t {
3333
/// Non-associative operators cannot be written next to other
3434
/// operators with the same precedence. Relational operators are
3535
/// typically non-associative.
36-
None,
36+
None SWIFT_NAME("none"),
3737

3838
/// Left-associative operators associate to the left if written next
3939
/// to other left-associative operators of the same precedence.
40-
Left,
40+
Left SWIFT_NAME("left"),
4141

4242
/// Right-associative operators associate to the right if written
4343
/// next to other right-associative operators of the same precedence.
44-
Right
44+
Right SWIFT_NAME("right")
4545
};
4646

4747
/// Returns the in-source spelling of the given associativity.

lib/AST/Bridging/DeclBridging.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -586,8 +586,8 @@ BridgedPrecedenceGroupDecl BridgedPrecedenceGroupDecl_createParsed(
586586
BridgedSourceLoc cPrecedencegroupKeywordLoc, BridgedIdentifier cName,
587587
BridgedSourceLoc cNameLoc, BridgedSourceLoc cLeftBraceLoc,
588588
BridgedSourceLoc cAssociativityKeywordLoc,
589-
BridgedSourceLoc cAssociativityValueLoc,
590-
BridgedAssociativity cAssociativity, BridgedSourceLoc cAssignmentKeywordLoc,
589+
BridgedSourceLoc cAssociativityValueLoc, swift::Associativity associativity,
590+
BridgedSourceLoc cAssignmentKeywordLoc,
591591
BridgedSourceLoc cAssignmentValueLoc, bool isAssignment,
592592
BridgedSourceLoc cHigherThanKeywordLoc, BridgedArrayRef cHigherThanNames,
593593
BridgedSourceLoc cLowerThanKeywordLoc, BridgedArrayRef cLowerThanNames,
@@ -609,9 +609,9 @@ BridgedPrecedenceGroupDecl BridgedPrecedenceGroupDecl_createParsed(
609609
cDeclContext.unbridged(), cPrecedencegroupKeywordLoc.unbridged(),
610610
cNameLoc.unbridged(), cName.unbridged(), cLeftBraceLoc.unbridged(),
611611
cAssociativityKeywordLoc.unbridged(), cAssociativityValueLoc.unbridged(),
612-
static_cast<Associativity>(cAssociativity),
613-
cAssignmentKeywordLoc.unbridged(), cAssignmentValueLoc.unbridged(),
614-
isAssignment, cHigherThanKeywordLoc.unbridged(), higherThanNames,
612+
associativity, cAssignmentKeywordLoc.unbridged(),
613+
cAssignmentValueLoc.unbridged(), isAssignment,
614+
cHigherThanKeywordLoc.unbridged(), higherThanNames,
615615
cLowerThanKeywordLoc.unbridged(), lowerThanNames,
616616
cRightBraceLoc.unbridged());
617617
}

lib/ASTGen/Sources/ASTGen/Decls.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@ extension ASTGenVisitor {
927927

928928
// MARK: - PrecedenceGroupDecl
929929

930-
extension BridgedAssociativity {
930+
extension swift.Associativity {
931931
fileprivate init?(from keyword: Keyword?) {
932932
switch keyword {
933933
case .none?: self = .none
@@ -991,9 +991,9 @@ extension ASTGenVisitor {
991991
}
992992
}
993993

994-
let associativityValue: BridgedAssociativity
994+
let associativityValue: swift.Associativity
995995
if let token = body.associativity?.value {
996-
if let value = BridgedAssociativity(from: token.keywordKind) {
996+
if let value = swift.Associativity(from: token.keywordKind) {
997997
associativityValue = value
998998
} else {
999999
self.diagnose(.unexpectedTokenKind(token: token))

0 commit comments

Comments
 (0)