@@ -137,25 +137,25 @@ class InstructionVisitor : public SILCloner<InstructionVisitor> {
137
137
};
138
138
139
139
// / Make a nominal type, including it's context, usable from inline.
140
- static void makeNominalUsableFromInline (NominalTypeDecl *NT , SILModule &M) {
141
- if (NT ->getEffectiveAccess () >= AccessLevel::Public)
140
+ static void makeDeclUsableFromInline (ValueDecl *decl , SILModule &M) {
141
+ if (decl ->getEffectiveAccess () >= AccessLevel::Public)
142
142
return ;
143
143
144
- if (!NT ->isUsableFromInline ()) {
144
+ if (!decl ->isUsableFromInline ()) {
145
145
// Mark the nominal type as "usableFromInline".
146
146
// TODO: find a way to do this without modifying the AST. The AST should be
147
147
// immutable at this point.
148
- auto &ctx = NT ->getASTContext ();
148
+ auto &ctx = decl ->getASTContext ();
149
149
auto *attr = new (ctx) UsableFromInlineAttr (/* implicit=*/ true );
150
- NT ->getAttrs ().add (attr);
150
+ decl ->getAttrs ().add (attr);
151
151
}
152
- if (auto *enclosingNominal = dyn_cast<NominalTypeDecl>(NT ->getDeclContext ())) {
153
- makeNominalUsableFromInline (enclosingNominal , M);
154
- } else if (auto *enclosingExt = dyn_cast<ExtensionDecl>(NT ->getDeclContext ())) {
155
- if (auto *extendedNominal = enclosingExt ->getExtendedNominal ()) {
156
- makeNominalUsableFromInline (extendedNominal, M);
152
+ if (auto *nominalCtx = dyn_cast<NominalTypeDecl>(decl ->getDeclContext ())) {
153
+ makeDeclUsableFromInline (nominalCtx , M);
154
+ } else if (auto *extCtx = dyn_cast<ExtensionDecl>(decl ->getDeclContext ())) {
155
+ if (auto *extendedNominal = extCtx ->getExtendedNominal ()) {
156
+ makeDeclUsableFromInline (extendedNominal, M);
157
157
}
158
- } else if (NT ->getDeclContext ()->isLocalContext ()) {
158
+ } else if (decl ->getDeclContext ()->isLocalContext ()) {
159
159
// TODO
160
160
}
161
161
}
@@ -166,15 +166,15 @@ void CrossModuleSerializationSetup::makeTypeUsableFromInline(CanType type) {
166
166
return ;
167
167
168
168
if (NominalTypeDecl *NT = type->getNominalOrBoundGenericNominal ()) {
169
- makeNominalUsableFromInline (NT, M);
169
+ makeDeclUsableFromInline (NT, M);
170
170
}
171
171
172
172
// Also make all sub-types usable from inline.
173
173
type.visit ([this ](Type rawSubType) {
174
174
CanType subType = rawSubType->getCanonicalType ();
175
175
if (typesHandled.insert (subType.getPointer ()).second ) {
176
176
if (NominalTypeDecl *subNT = subType->getNominalOrBoundGenericNominal ()) {
177
- makeNominalUsableFromInline (subNT, M);
177
+ makeDeclUsableFromInline (subNT, M);
178
178
}
179
179
}
180
180
});
@@ -235,6 +235,9 @@ prepareInstructionForSerialization(SILInstruction *inst) {
235
235
[this ](SILDeclRef method) { handleReferencedMethod (method); });
236
236
return ;
237
237
}
238
+ if (auto *REAI = dyn_cast<RefElementAddrInst>(inst)) {
239
+ makeDeclUsableFromInline (REAI->getField (), M);
240
+ }
238
241
}
239
242
240
243
void CrossModuleSerializationSetup::handleReferencedFunction (SILFunction *func) {
0 commit comments