Skip to content

Commit cc8639b

Browse files
authored
Merge pull request #81301 from slavapestov/remote-mirrors-cleanups
RemoteInspection: Two small cleanups
2 parents ce0fb99 + c205c80 commit cc8639b

File tree

3 files changed

+12
-21
lines changed

3 files changed

+12
-21
lines changed

include/swift/RemoteInspection/TypeRef.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,6 @@ class alignas(8) TypeRef {
238238
const TypeRef *subst(TypeRefBuilder &Builder,
239239
const GenericArgumentMap &Subs) const;
240240

241-
const TypeRef *subst(TypeRefBuilder &Builder,
242-
const GenericArgumentMap &Subs,
243-
bool &DidSubstitute) const;
244-
245241
std::optional<GenericArgumentMap> getSubstMap() const;
246242

247243
virtual ~TypeRef() = default;

stdlib/public/RemoteInspection/TypeRef.cpp

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,13 @@ struct TypeRefIsConcrete
506506
}
507507

508508
bool visitOpaqueArchetypeTypeRef(const OpaqueArchetypeTypeRef *O) {
509+
for (auto Args : O->getArgumentLists()) {
510+
for (auto *Arg : Args) {
511+
if (!visit(Arg))
512+
return false;
513+
}
514+
}
515+
509516
return false;
510517
}
511518

@@ -1350,15 +1357,12 @@ class TypeRefSubstitution
13501357
: public TypeRefVisitor<TypeRefSubstitution, const TypeRef *> {
13511358
TypeRefBuilder &Builder;
13521359
GenericArgumentMap Substitutions;
1353-
// Set true iff the Substitution map was actually used
1354-
bool DidSubstitute;
1360+
13551361
public:
13561362
using TypeRefVisitor<TypeRefSubstitution, const TypeRef *>::visit;
13571363

13581364
TypeRefSubstitution(TypeRefBuilder &Builder, GenericArgumentMap Substitutions)
1359-
: Builder(Builder), Substitutions(Substitutions), DidSubstitute(false) {}
1360-
1361-
bool didSubstitute() const { return DidSubstitute; }
1365+
: Builder(Builder), Substitutions(Substitutions) {}
13621366

13631367
const TypeRef *visitBuiltinTypeRef(const BuiltinTypeRef *B) {
13641368
return B;
@@ -1488,7 +1492,6 @@ class TypeRefSubstitution
14881492
if (found == Substitutions.end())
14891493
return GTP;
14901494
assert(found->second->isConcrete());
1491-
DidSubstitute = true; // We actually used the Substitutions
14921495

14931496
// When substituting a concrete type containing a metatype into a
14941497
// type parameter, (eg: T, T := C.Type), we must also represent
@@ -1609,15 +1612,6 @@ const TypeRef *TypeRef::subst(TypeRefBuilder &Builder,
16091612
return TypeRefSubstitution(Builder, Subs).visit(this);
16101613
}
16111614

1612-
const TypeRef *TypeRef::subst(TypeRefBuilder &Builder,
1613-
const GenericArgumentMap &Subs,
1614-
bool &DidSubstitute) const {
1615-
auto subst = TypeRefSubstitution(Builder, Subs);
1616-
auto TR = subst.visit(this);
1617-
DidSubstitute = subst.didSubstitute();
1618-
return TR;
1619-
}
1620-
16211615
bool TypeRef::deriveSubstitutions(GenericArgumentMap &Subs,
16221616
const TypeRef *OrigTR,
16231617
const TypeRef *SubstTR) {

stdlib/public/RemoteInspection/TypeRefBuilder.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -538,8 +538,9 @@ bool TypeRefBuilder::getFieldTypeRefs(
538538
// We need this for enums; an enum case "is generic" if any generic type
539539
// parameter substitutions occurred on the payload. E.g.,
540540
// `case a([T?])` is generic, but `case a([Int?])` is not.
541-
bool IsGeneric = false;
542-
auto Substituted = Unsubstituted->subst(*this, *Subs, IsGeneric);
541+
bool IsGeneric = !Unsubstituted->isConcrete();
542+
auto Substituted = (IsGeneric ? Unsubstituted->subst(*this, *Subs)
543+
: Unsubstituted);
543544
bool IsIndirect = FD.isEnum() && Field->IsIndirectCase;
544545

545546
auto FieldTI = FieldTypeInfo(FieldName.str(), FieldValue, Substituted,

0 commit comments

Comments
 (0)