28
28
using namespace swift ;
29
29
30
30
bool TypeChecker::diagnoseInlinableDeclRef (SourceLoc loc,
31
- ConcreteDeclRef declRef ,
31
+ const ValueDecl *D ,
32
32
const DeclContext *DC,
33
33
FragileFunctionKind Kind) {
34
34
assert (Kind.kind != FragileFunctionKind::None);
35
35
36
- const ValueDecl *D = declRef.getDecl ();
37
36
// Do some important fast-path checks that apply to all cases.
38
37
39
38
// Type parameters are OK.
@@ -48,7 +47,7 @@ bool TypeChecker::diagnoseInlinableDeclRef(SourceLoc loc,
48
47
// Skip this check for accessors because the associated property or subscript
49
48
// will also be checked, and will provide a better error message.
50
49
if (!isa<AccessorDecl>(D))
51
- if (diagnoseDeclRefExportability (loc, declRef , DC,
50
+ if (diagnoseDeclRefExportability (loc, D , DC,
52
51
None, Kind))
53
52
return true ;
54
53
@@ -141,19 +140,22 @@ bool TypeChecker::diagnoseInlinableDeclRefAccess(SourceLoc loc,
141
140
return (downgradeToWarning == DowngradeToWarning::No);
142
141
}
143
142
144
- static bool diagnoseDeclExportability (SourceLoc loc, const ValueDecl *D,
145
- const SourceFile &userSF,
146
- const DeclContext *userDC,
147
- Optional<ExportabilityReason> reason,
148
- FragileFunctionKind fragileKind) {
143
+ bool
144
+ TypeChecker::diagnoseDeclRefExportability (SourceLoc loc,
145
+ const ValueDecl *D,
146
+ const DeclContext *DC,
147
+ Optional<ExportabilityReason> reason,
148
+ FragileFunctionKind fragileKind) {
149
149
if (fragileKind.kind == FragileFunctionKind::None && !reason.hasValue ())
150
150
return false ;
151
151
152
152
auto definingModule = D->getModuleContext ();
153
153
154
154
auto downgradeToWarning = DowngradeToWarning::No;
155
155
auto originKind = getDisallowedOriginKind (
156
- D, userSF, userDC->getInnermostDeclarationDeclContext (),
156
+ D,
157
+ *DC->getParentSourceFile (),
158
+ DC->getInnermostDeclarationDeclContext (),
157
159
downgradeToWarning);
158
160
if (originKind == DisallowedOriginKind::None)
159
161
return false ;
@@ -211,20 +213,3 @@ TypeChecker::diagnoseConformanceExportability(SourceLoc loc,
211
213
static_cast <unsigned >(originKind));
212
214
return true ;
213
215
}
214
-
215
- bool
216
- TypeChecker::diagnoseDeclRefExportability (SourceLoc loc,
217
- ConcreteDeclRef declRef,
218
- const DeclContext *DC,
219
- Optional<ExportabilityReason> reason,
220
- FragileFunctionKind fragileKind) {
221
- // We're only interested in diagnosing uses from source files.
222
- auto userSF = DC->getParentSourceFile ();
223
- if (!userSF)
224
- return false ;
225
-
226
- const ValueDecl *D = declRef.getDecl ();
227
- if (diagnoseDeclExportability (loc, D, *userSF, DC, reason, fragileKind))
228
- return true ;
229
- return false ;
230
- }
0 commit comments