@@ -106,20 +106,52 @@ bool TypeChecker::diagnoseInlinableDeclRefAccess(SourceLoc loc,
106
106
return (downgradeToWarning == DowngradeToWarning::No);
107
107
}
108
108
109
- bool
110
- TypeChecker::diagnoseDeclRefExportability (SourceLoc loc ,
111
- const ValueDecl *D,
112
- const ExportContext & where) {
113
- // Accessors cannot have exportability that's different than the storage,
114
- // so skip them for now.
115
- if (isa<AccessorDecl>(D) )
109
+ static bool diagnoseTypeAliasDeclRefExportability (SourceLoc loc,
110
+ const TypeAliasDecl *TAD ,
111
+ const ExportContext &where) {
112
+ assert ( where. mustOnlyReferenceExportedDecls ());
113
+
114
+ auto *D = TAD-> getUnderlyingType ()-> getAnyNominal ();
115
+ if (!D )
116
116
return false ;
117
117
118
- if (!where.mustOnlyReferenceExportedDecls ())
118
+ auto ignoredDowngradeToWarning = DowngradeToWarning::No;
119
+ auto originKind =
120
+ getDisallowedOriginKind (D, where, ignoredDowngradeToWarning);
121
+ if (originKind == DisallowedOriginKind::None)
119
122
return false ;
120
123
121
124
auto definingModule = D->getModuleContext ();
125
+ ASTContext &ctx = definingModule->getASTContext ();
126
+ auto fragileKind = where.getFragileFunctionKind ();
127
+
128
+ if (fragileKind.kind == FragileFunctionKind::None) {
129
+ auto reason = where.getExportabilityReason ();
130
+ ctx.Diags
131
+ .diagnose (loc, diag::typealias_desugars_to_type_from_hidden_module,
132
+ TAD->getName (), definingModule->getNameStr (), D->getNameStr (),
133
+ static_cast <unsigned >(*reason), definingModule->getName (),
134
+ static_cast <unsigned >(originKind))
135
+ .warnUntilSwiftVersion (6 );
136
+ } else {
137
+ ctx.Diags
138
+ .diagnose (loc,
139
+ diag::inlinable_typealias_desugars_to_type_from_hidden_module,
140
+ TAD->getName (), definingModule->getNameStr (), D->getNameStr (),
141
+ fragileKind.getSelector (), definingModule->getName (),
142
+ static_cast <unsigned >(originKind))
143
+ .warnUntilSwiftVersion (6 );
144
+ }
145
+ D->diagnose (diag::kind_declared_here, DescriptiveDeclKind::Type);
146
+
147
+ return true ;
148
+ }
149
+
150
+ static bool diagnoseValueDeclRefExportability (SourceLoc loc, const ValueDecl *D,
151
+ const ExportContext &where) {
152
+ assert (where.mustOnlyReferenceExportedDecls ());
122
153
154
+ auto definingModule = D->getModuleContext ();
123
155
auto downgradeToWarning = DowngradeToWarning::No;
124
156
125
157
auto originKind = getDisallowedOriginKind (
@@ -162,6 +194,27 @@ TypeChecker::diagnoseDeclRefExportability(SourceLoc loc,
162
194
return true ;
163
195
}
164
196
197
+ bool TypeChecker::diagnoseDeclRefExportability (SourceLoc loc,
198
+ const ValueDecl *D,
199
+ const ExportContext &where) {
200
+ // Accessors cannot have exportability that's different than the storage,
201
+ // so skip them for now.
202
+ if (isa<AccessorDecl>(D))
203
+ return false ;
204
+
205
+ if (!where.mustOnlyReferenceExportedDecls ())
206
+ return false ;
207
+
208
+ if (diagnoseValueDeclRefExportability (loc, D, where))
209
+ return true ;
210
+
211
+ if (auto *TAD = dyn_cast<TypeAliasDecl>(D))
212
+ if (diagnoseTypeAliasDeclRefExportability (loc, TAD, where))
213
+ return true ;
214
+
215
+ return false ;
216
+ }
217
+
165
218
bool
166
219
TypeChecker::diagnoseConformanceExportability (SourceLoc loc,
167
220
const RootProtocolConformance *rootConf,
0 commit comments