@@ -32,16 +32,9 @@ using namespace swift;
32
32
// / This requires the getter's body to have a certain syntactic form. It should
33
33
// / be kept in sync with importEnumCaseAlias in the ClangImporter library.
34
34
static EnumElementDecl *
35
- extractEnumElement (TypeChecker &TC, SourceLoc UseLoc, const VarDecl *constant) {
36
- if (auto Attr = AvailableAttr::isUnavailable (constant)) {
37
- auto Rename = Attr->Rename ;
38
- if (!Rename.empty ()) {
39
- TC.diagnose (UseLoc, diag::availability_decl_unavailable_rename,
40
- constant->getName (), /* replaced*/ false ,
41
- /* special kind*/ 0 , Attr->Rename )
42
- .fixItReplace (UseLoc, Rename);
43
- }
44
- }
35
+ extractEnumElement (TypeChecker &TC, DeclContext *DC, SourceLoc UseLoc,
36
+ const VarDecl *constant) {
37
+ TC.diagnoseExplicitUnavailability (constant, UseLoc, DC, nullptr );
45
38
46
39
const FuncDecl *getter = constant->getGetter ();
47
40
if (!getter)
@@ -72,7 +65,7 @@ extractEnumElement(TypeChecker &TC, SourceLoc UseLoc, const VarDecl *constant) {
72
65
// / If there are no enum elements but there are properties, attempts to map
73
66
// / an arbitrary property to an enum element using extractEnumElement.
74
67
static EnumElementDecl *
75
- filterForEnumElement (TypeChecker &TC, SourceLoc UseLoc,
68
+ filterForEnumElement (TypeChecker &TC, DeclContext *DC, SourceLoc UseLoc,
76
69
LookupResult foundElements) {
77
70
EnumElementDecl *foundElement = nullptr ;
78
71
VarDecl *foundConstant = nullptr ;
@@ -97,7 +90,7 @@ filterForEnumElement(TypeChecker &TC, SourceLoc UseLoc,
97
90
}
98
91
99
92
if (!foundElement && foundConstant && foundConstant->hasClangNode ())
100
- foundElement = extractEnumElement (TC, UseLoc, foundConstant);
93
+ foundElement = extractEnumElement (TC, DC, UseLoc, foundConstant);
101
94
102
95
return foundElement;
103
96
}
@@ -109,7 +102,7 @@ lookupUnqualifiedEnumMemberElement(TypeChecker &TC, DeclContext *DC,
109
102
auto lookupOptions = defaultUnqualifiedLookupOptions;
110
103
lookupOptions |= NameLookupFlags::KnownPrivate;
111
104
auto lookup = TC.lookupUnqualified (DC, name, SourceLoc (), lookupOptions);
112
- return filterForEnumElement (TC, UseLoc, lookup);
105
+ return filterForEnumElement (TC, DC, UseLoc, lookup);
113
106
}
114
107
115
108
// / Find an enum element in an enum type.
@@ -122,7 +115,7 @@ lookupEnumMemberElement(TypeChecker &TC, DeclContext *DC, Type ty,
122
115
NameLookupOptions lookupOptions
123
116
= defaultMemberLookupOptions - NameLookupFlags::DynamicLookup;
124
117
LookupResult foundElements = TC.lookupMember (DC, ty, name, lookupOptions);
125
- return filterForEnumElement (TC, UseLoc, foundElements);
118
+ return filterForEnumElement (TC, DC, UseLoc, foundElements);
126
119
}
127
120
128
121
namespace {
0 commit comments