Skip to content

Commit d2343f2

Browse files
committed
[Sema] Create a new TypeRefinementContext only for explicit inlinables
1 parent 429017f commit d2343f2

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

lib/Sema/TypeCheckAvailability.cpp

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -203,21 +203,27 @@ class TypeRefinementContextBuilder : private ASTWalker {
203203

204204
return NewTRC;
205205
}
206-
206+
207207
/// Returns true if the declaration should introduce a new refinement context.
208208
bool declarationIntroducesNewContext(Decl *D) {
209209
if (!isa<ValueDecl>(D) && !isa<ExtensionDecl>(D)) {
210210
return false;
211211
}
212-
212+
213+
// Explicit inlinability may to the decl being used on an earlier OS
214+
// version when inlined on the client side. This check assumes that
215+
// implicit decls are handled elsewhere.
216+
bool isExplicitlyInlinable = !D->isImplicit() &&
217+
(D->getAttrs().hasAttribute<InlinableAttr>() ||
218+
D->getAttrs().hasAttribute<AlwaysEmitIntoClientAttr>());
219+
213220
// No need to introduce a context if the declaration does not have an
214-
// availability or inlinable attribute.
221+
// availability or non-implicit inlinable attribute.
215222
if (!hasActiveAvailableAttribute(D, Context) &&
216-
!D->getAttrs().hasAttribute<InlinableAttr>() &&
217-
!D->getAttrs().hasAttribute<AlwaysEmitIntoClientAttr>()) {
223+
!isExplicitlyInlinable) {
218224
return false;
219225
}
220-
226+
221227
// Only introduce for an AbstractStorageDecl if it is not local.
222228
// We introduce for the non-local case because these may
223229
// have getters and setters (and these may be synthesized, so they might
@@ -228,7 +234,7 @@ class TypeRefinementContextBuilder : private ASTWalker {
228234
return false;
229235
}
230236
}
231-
237+
232238
return true;
233239
}
234240

0 commit comments

Comments
 (0)