2828using namespace swift ;
2929
3030bool TypeChecker::diagnoseInlinableDeclRef (SourceLoc loc,
31- ConcreteDeclRef declRef ,
31+ const ValueDecl *D ,
3232 const DeclContext *DC,
3333 FragileFunctionKind Kind) {
3434 assert (Kind.kind != FragileFunctionKind::None);
3535
36- const ValueDecl *D = declRef.getDecl ();
3736 // Do some important fast-path checks that apply to all cases.
3837
3938 // Type parameters are OK.
@@ -48,7 +47,7 @@ bool TypeChecker::diagnoseInlinableDeclRef(SourceLoc loc,
4847 // Skip this check for accessors because the associated property or subscript
4948 // will also be checked, and will provide a better error message.
5049 if (!isa<AccessorDecl>(D))
51- if (diagnoseDeclRefExportability (loc, declRef , DC,
50+ if (diagnoseDeclRefExportability (loc, D , DC,
5251 None, Kind))
5352 return true ;
5453
@@ -141,19 +140,22 @@ bool TypeChecker::diagnoseInlinableDeclRefAccess(SourceLoc loc,
141140 return (downgradeToWarning == DowngradeToWarning::No);
142141}
143142
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) {
149149 if (fragileKind.kind == FragileFunctionKind::None && !reason.hasValue ())
150150 return false ;
151151
152152 auto definingModule = D->getModuleContext ();
153153
154154 auto downgradeToWarning = DowngradeToWarning::No;
155155 auto originKind = getDisallowedOriginKind (
156- D, userSF, userDC->getInnermostDeclarationDeclContext (),
156+ D,
157+ *DC->getParentSourceFile (),
158+ DC->getInnermostDeclarationDeclContext (),
157159 downgradeToWarning);
158160 if (originKind == DisallowedOriginKind::None)
159161 return false ;
@@ -211,20 +213,3 @@ TypeChecker::diagnoseConformanceExportability(SourceLoc loc,
211213 static_cast <unsigned >(originKind));
212214 return true ;
213215}
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