@@ -105,16 +105,6 @@ bool TypeChecker::diagnoseInlinableDeclRefAccess(SourceLoc loc,
105
105
}
106
106
107
107
DowngradeToWarning downgradeToWarning = DowngradeToWarning::No;
108
- // Don't change the order of the getDisallowedOriginKind call;
109
- // it can reset downgradeToWarning to NO so needs to be called here.
110
- auto originKind = getDisallowedOriginKind (D, where, downgradeToWarning);
111
- // For a default argument or property initializer, package type is
112
- // allowed at the use site with package access scope.
113
- auto allowedForPkgCtx = false ;
114
- if (originKind == DisallowedOriginKind::None ||
115
- originKind == DisallowedOriginKind::PackageImport) {
116
- allowedForPkgCtx = where.isPackage () && declAccessScope.isPackage ();
117
- }
118
108
119
109
// Swift 4.2 did not perform any checks for type aliases.
120
110
if (isa<TypeAliasDecl>(D)) {
@@ -134,12 +124,22 @@ bool TypeChecker::diagnoseInlinableDeclRefAccess(SourceLoc loc,
134
124
if (isa<TypeAliasDecl>(DC) && !Context.isSwiftVersionAtLeast (6 ))
135
125
downgradeToWarning = DowngradeToWarning::Yes;
136
126
127
+ AccessLevel diagAccessLevel = declAccessScope.accessLevelForDiagnostics ();
128
+
129
+ auto allowedForPkgCtx = false ;
130
+ auto originKind = getDisallowedOriginKind (D, where, downgradeToWarning);
131
+ // For a default argument or property initializer, package type is
132
+ // allowed at the use site with package access scope.
133
+ if (originKind == DisallowedOriginKind::None ||
134
+ originKind == DisallowedOriginKind::PackageImport) {
135
+ allowedForPkgCtx = where.isPackage () && diagAccessLevel >= AccessLevel::Package;
136
+ }
137
+
137
138
if (!allowedForPkgCtx) {
138
139
auto diagID = diag::resilience_decl_unavailable;
139
140
if (downgradeToWarning == DowngradeToWarning::Yes)
140
141
diagID = diag::resilience_decl_unavailable_warn;
141
142
142
- AccessLevel diagAccessLevel = declAccessScope.accessLevelForDiagnostics ();
143
143
Context.Diags .diagnose (loc, diagID, D, diagAccessLevel,
144
144
fragileKind.getSelector ());
145
145
0 commit comments