Skip to content

Commit 3036f81

Browse files
authored
Merge pull request swiftlang#19672 from nkcsgexi/diag-operator-change
2 parents 08d4a93 + c2c0487 commit 3036f81

File tree

8 files changed

+22
-4
lines changed

8 files changed

+22
-4
lines changed

include/swift/AST/DiagnosticsModuleDiffer.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ ERROR(super_class_removed,none,"%0 has removed its super class %1", (StringRef,
7474

7575
ERROR(super_class_changed,none,"%0 has changed its super class from %1 to %2", (StringRef, StringRef, StringRef))
7676

77-
ERROR(nominal_type_kind_changed,none,"%0 has been changed to a %1", (StringRef, StringRef))
77+
ERROR(decl_kind_changed,none,"%0 has been changed to a %1", (StringRef, StringRef))
7878

7979
ERROR(optional_req_changed,none,"%0 is %select{now|no longer}1 an optional requirement", (StringRef, bool))
8080

test/api-digester/Inputs/cake1.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,5 @@ public class EscapingFunctionType {
131131
public func removedEscaping(_ a: @escaping ()->()) {}
132132
public func addedEscaping(_ a: ()->()) {}
133133
}
134+
135+
infix operator ..*..

test/api-digester/Inputs/cake2.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,3 +141,5 @@ public class EscapingFunctionType {
141141
public func removedEscaping(_ a: ()->()) {}
142142
public func addedEscaping(_ a: @escaping ()->()) {}
143143
}
144+
145+
prefix operator ..*..

test/api-digester/Outputs/Cake-abi.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ cake1: Var RequiementChanges.removedVar has been removed
2020

2121
/* Moved Decls */
2222
cake1: Class ClassToStruct has been changed to a Struct
23+
cake1: InfixOperator ..*.. has been changed to a PrefixOperator
2324
cake1: Protocol ProtocolToEnum has been changed to a Enum
2425

2526
/* Renamed Decls */

test/api-digester/Outputs/Cake.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ cake1: Var RequiementChanges.removedVar has been removed
1919

2020
/* Moved Decls */
2121
cake1: Class ClassToStruct has been changed to a Struct
22+
cake1: InfixOperator ..*.. has been changed to a PrefixOperator
2223
cake1: Protocol ProtocolToEnum has been changed to a Enum
2324

2425
/* Renamed Decls */

tools/swift-api-digester/ModuleAnalyzerNodes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,7 @@ class SDKNodeDeclOperator : public SDKNodeDecl {
467467
public:
468468
SDKNodeDeclOperator(SDKNodeInitInfo Info);
469469
static bool classof(const SDKNode *N);
470+
void diagnose(SDKNode *Right) override;
470471
};
471472

472473
class SDKNodeDeclTypeAlias : public SDKNodeDecl {

tools/swift-api-digester/ModuleDiagsConsumer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ static StringRef getCategoryName(uint32_t ID) {
3636
case LocalDiagID::removed_setter:
3737
return "/* Removed Decls */";
3838
case LocalDiagID::moved_decl:
39-
case LocalDiagID::nominal_type_kind_changed:
39+
case LocalDiagID::decl_kind_changed:
4040
return "/* Moved Decls */";
4141
case LocalDiagID::renamed_decl:
4242
return "/* Renamed Decls */";

tools/swift-api-digester/swift-api-digester.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -667,8 +667,8 @@ void swift::ide::api::SDKNodeDeclType::diagnose(SDKNode *Right) {
667667
auto &Diags = Ctx.getDiags();
668668

669669
if (getDeclKind() != R->getDeclKind()) {
670-
Diags.diagnose(SourceLoc(), diag::nominal_type_kind_changed,
671-
getScreenInfo(), getDeclKindStr(R->getDeclKind()));
670+
Diags.diagnose(SourceLoc(), diag::decl_kind_changed, getScreenInfo(),
671+
getDeclKindStr(R->getDeclKind()));
672672
return;
673673
}
674674

@@ -798,6 +798,17 @@ void swift::ide::api::SDKNodeDecl::diagnose(SDKNode *Right) {
798798
}
799799
}
800800

801+
void swift::ide::api::SDKNodeDeclOperator::diagnose(SDKNode *Right) {
802+
SDKNodeDecl::diagnose(Right);
803+
auto *RO = dyn_cast<SDKNodeDeclOperator>(Right);
804+
if (!RO)
805+
return;
806+
if (getDeclKind() != RO->getDeclKind()) {
807+
Ctx.getDiags().diagnose(SourceLoc(), diag::decl_kind_changed, getScreenInfo(),
808+
getDeclKindStr(RO->getDeclKind()));
809+
}
810+
}
811+
801812
void swift::ide::api::SDKNodeDeclVar::diagnose(SDKNode *Right) {
802813
SDKNodeDecl::diagnose(Right);
803814
auto *RV = dyn_cast<SDKNodeDeclVar>(Right);

0 commit comments

Comments
 (0)