Skip to content

Commit f99efc2

Browse files
committed
Fix unsafeGetSubstFieldType to propagate a substitution map in
whichever case it happens to be in. This is a basic fix so that parallel walks on tuples and function types in the substituted type will work . Separately, though, I do not think the places that use this really need to be passed an orig type; this is used for computing type properties, and I am not aware of any reason we should need an orig type to compute type properties. Additionally, the orig types computed by this function are not really correct because of the substitution being done in some cases, so it'd be very nice to rip this all out. I'm not good to look into that right now, though.
1 parent bbc6828 commit f99efc2

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

include/swift/SIL/AbstractionPattern.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,8 @@ class AbstractionPattern {
783783
/// Note that, for most purposes, you should lower a field's type against its
784784
/// *unsubstituted* interface type.
785785
AbstractionPattern
786-
unsafeGetSubstFieldType(ValueDecl *member, CanType origMemberType) const;
786+
unsafeGetSubstFieldType(ValueDecl *member, CanType origMemberType,
787+
SubstitutionMap subMap) const;
787788

788789
private:
789790
/// Return an abstraction pattern for the curried type of an

lib/SIL/IR/AbstractionPattern.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,13 +1583,14 @@ bool AbstractionPattern::hasSameBasicTypeStructure(CanType l, CanType r) {
15831583

15841584
AbstractionPattern
15851585
AbstractionPattern::unsafeGetSubstFieldType(ValueDecl *member,
1586-
CanType origMemberInterfaceType)
1586+
CanType origMemberInterfaceType,
1587+
SubstitutionMap subMap)
15871588
const {
15881589
assert(origMemberInterfaceType);
15891590
if (isTypeParameterOrOpaqueArchetype()) {
15901591
// Fall back to the generic abstraction pattern for the member.
15911592
auto sig = member->getDeclContext()->getGenericSignatureOfContext();
1592-
return AbstractionPattern(sig.getCanonicalSignature(),
1593+
return AbstractionPattern(subMap, sig.getCanonicalSignature(),
15931594
origMemberInterfaceType);
15941595
}
15951596

@@ -1626,7 +1627,9 @@ const {
16261627
member, origMemberInterfaceType)
16271628
->getReducedType(getGenericSignature());
16281629

1629-
return AbstractionPattern(getGenericSignature(), memberTy);
1630+
return AbstractionPattern(getGenericSubstitutions(),
1631+
getGenericSignature(),
1632+
memberTy);
16301633
}
16311634
llvm_unreachable("invalid abstraction pattern kind");
16321635
}

lib/SIL/IR/TypeLowering.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2343,7 +2343,8 @@ namespace {
23432343
auto sig = field->getDeclContext()->getGenericSignatureOfContext();
23442344
auto interfaceTy = field->getInterfaceType()->getReducedType(sig);
23452345
auto origFieldType = origType.unsafeGetSubstFieldType(field,
2346-
interfaceTy);
2346+
interfaceTy,
2347+
subMap);
23472348

23482349
properties.addSubobject(classifyType(origFieldType, substFieldType,
23492350
TC, Expansion));
@@ -2422,7 +2423,8 @@ namespace {
24222423

24232424
auto origEltType = origType.unsafeGetSubstFieldType(elt,
24242425
elt->getArgumentInterfaceType()
2425-
->getReducedType(D->getGenericSignature()));
2426+
->getReducedType(D->getGenericSignature()),
2427+
subMap);
24262428
properties.addSubobject(classifyType(origEltType, substEltType,
24272429
TC, Expansion));
24282430
properties =
@@ -2765,7 +2767,8 @@ bool TypeConverter::visitAggregateLeaves(
27652767
auto interfaceTy =
27662768
structField->getInterfaceType()->getReducedType(sig);
27672769
auto origFieldType =
2768-
origTy.unsafeGetSubstFieldType(structField, interfaceTy);
2770+
origTy.unsafeGetSubstFieldType(structField, interfaceTy,
2771+
subMap);
27692772
insertIntoWorklist(substFieldTy, origFieldType, structField,
27702773
llvm::None);
27712774
}
@@ -2782,7 +2785,7 @@ bool TypeConverter::visitAggregateLeaves(
27822785
->getCanonicalType();
27832786
auto origElementTy = origTy.unsafeGetSubstFieldType(
27842787
element, element->getArgumentInterfaceType()->getReducedType(
2785-
decl->getGenericSignature()));
2788+
decl->getGenericSignature()), subMap);
27862789

27872790
insertIntoWorklist(substElementType, origElementTy, element,
27882791
llvm::None);

0 commit comments

Comments
 (0)