@@ -105,6 +105,16 @@ 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
+ }
108
118
109
119
// Swift 4.2 did not perform any checks for type aliases.
110
120
if (isa<TypeAliasDecl>(D)) {
@@ -124,22 +134,12 @@ bool TypeChecker::diagnoseInlinableDeclRefAccess(SourceLoc loc,
124
134
if (isa<TypeAliasDecl>(DC) && !Context.isSwiftVersionAtLeast (6 ))
125
135
downgradeToWarning = DowngradeToWarning::Yes;
126
136
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
-
138
137
if (!allowedForPkgCtx) {
139
138
auto diagID = diag::resilience_decl_unavailable;
140
139
if (downgradeToWarning == DowngradeToWarning::Yes)
141
140
diagID = diag::resilience_decl_unavailable_warn;
142
141
142
+ AccessLevel diagAccessLevel = declAccessScope.accessLevelForDiagnostics ();
143
143
Context.Diags .diagnose (loc, diagID, D, diagAccessLevel,
144
144
fragileKind.getSelector ());
145
145
0 commit comments