@@ -1038,6 +1038,11 @@ static void addLinkageDecoration(
1038
1038
{
1039
1039
builder->addExportDecoration(inst, mangledName);
1040
1040
}
1041
+ if (decl->findModifier<PublicModifier>())
1042
+ {
1043
+ builder->addPublicDecoration(inst);
1044
+ builder->addKeepAliveDecoration(inst);
1045
+ }
1041
1046
}
1042
1047
1043
1048
static void addLinkageDecoration(
@@ -5161,6 +5166,15 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo>
5161
5166
return LoweredValInfo::simple(inst);
5162
5167
}
5163
5168
5169
+ bool isPublicType(Type* type)
5170
+ {
5171
+ if (auto declRefType = as<DeclRefType>(type))
5172
+ {
5173
+ if (declRefType->declRef.getDecl()->findModifier<PublicModifier>())
5174
+ return true;
5175
+ }
5176
+ return false;
5177
+ }
5164
5178
5165
5179
void lowerWitnessTable(
5166
5180
IRGenContext* subContext,
@@ -5211,6 +5225,12 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo>
5211
5225
astReqWitnessTable->witnessedType,
5212
5226
astReqWitnessTable->baseType);
5213
5227
subBuilder->addExportDecoration(irSatisfyingWitnessTable, mangledName.getUnownedSlice());
5228
+ if (isPublicType(astReqWitnessTable->witnessedType))
5229
+ {
5230
+ subBuilder->addPublicDecoration(irSatisfyingWitnessTable);
5231
+ subBuilder->addKeepAliveDecoration(irSatisfyingWitnessTable);
5232
+ }
5233
+
5214
5234
// Recursively lower the sub-table.
5215
5235
lowerWitnessTable(
5216
5236
subContext,
@@ -5327,6 +5347,11 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo>
5327
5347
// Create the IR-level witness table
5328
5348
auto irWitnessTable = subBuilder->createWitnessTable(irWitnessTableBaseType);
5329
5349
addLinkageDecoration(context, irWitnessTable, inheritanceDecl, mangledName.getUnownedSlice());
5350
+ if (parentDecl->findModifier<PublicModifier>())
5351
+ {
5352
+ subBuilder->addPublicDecoration(irWitnessTable);
5353
+ subBuilder->addKeepAliveDecoration(irWitnessTable);
5354
+ }
5330
5355
5331
5356
// Register the value now, rather than later, to avoid any possible infinite recursion.
5332
5357
setGlobalValue(context, inheritanceDecl, LoweredValInfo::simple(irWitnessTable));
@@ -6154,6 +6179,8 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo>
6154
6179
SLANG_UNREACHABLE("associatedtype should have been handled by visitAssocTypeDecl.");
6155
6180
}
6156
6181
6182
+ bool isPublicType = decl->findModifier<PublicModifier>() != nullptr;
6183
+
6157
6184
// Given a declaration of a type, we need to make sure
6158
6185
// to output "witness tables" for any interfaces this
6159
6186
// type has declared conformance to.
@@ -6171,18 +6198,20 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo>
6171
6198
6172
6199
// Emit any generics that should wrap the actual type.
6173
6200
auto outerGeneric = emitOuterGenerics(subContext, decl, decl);
6174
-
6175
6201
6176
6202
IRStructType* irStruct = subBuilder->createStructType();
6177
6203
addNameHint(context, irStruct, decl);
6178
6204
addLinkageDecoration(context, irStruct, decl);
6205
+
6179
6206
subBuilder->setInsertInto(irStruct);
6180
6207
6181
6208
// A `struct` that inherits from another `struct` must start
6182
6209
// with a member for the direct base type.
6183
6210
//
6184
6211
for( auto inheritanceDecl : decl->getMembersOfType<InheritanceDecl>() )
6185
6212
{
6213
+ if (isPublicType)
6214
+ ensureDecl(context, inheritanceDecl);
6186
6215
auto superType = inheritanceDecl->base;
6187
6216
if(auto superDeclRefType = as<DeclRefType>(superType))
6188
6217
{
0 commit comments