Skip to content

Commit 7648a31

Browse files
committed
SILGen: Remove usages of SubstitutionMap::combineSubstitutionMaps()
1 parent b68a78c commit 7648a31

File tree

2 files changed

+23
-31
lines changed

2 files changed

+23
-31
lines changed

lib/SILGen/SILGenConvert.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -531,17 +531,14 @@ SILGenFunction::emitPointerToPointer(SILLocation loc,
531531
origValue = emitManagedBufferWithCleanup(origBuf);
532532
}
533533
// Invoke the conversion intrinsic to convert to the destination type.
534-
auto *proto = getPointerProtocol();
535-
auto firstSubMap = inputType->getContextSubstitutionMap(proto);
536-
auto secondSubMap = outputType->getContextSubstitutionMap(proto);
534+
SmallVector<Type, 2> replacementTypes;
535+
replacementTypes.push_back(inputType);
536+
replacementTypes.push_back(outputType);
537537

538538
auto genericSig = converter->getGenericSignature();
539539
auto subMap =
540-
SubstitutionMap::combineSubstitutionMaps(firstSubMap,
541-
secondSubMap,
542-
CombineSubstitutionMaps::AtIndex,
543-
1, 0,
544-
genericSig);
540+
SubstitutionMap::get(genericSig, replacementTypes,
541+
LookUpConformanceInModule());
545542

546543
return emitApplyOfLibraryIntrinsic(loc, converter, subMap, origValue, C);
547544
}

lib/SILGen/SILGenExpr.cpp

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1507,24 +1507,20 @@ RValue SILGenFunction::emitCollectionConversion(SILLocation loc,
15071507
CanType toCollection,
15081508
ManagedValue mv,
15091509
SGFContext C) {
1510-
auto *fromDecl = fromCollection->getAnyNominal();
1511-
auto *toDecl = toCollection->getAnyNominal();
1510+
SmallVector<Type, 4> replacementTypes;
15121511

1513-
auto fromSubMap = fromCollection->getContextSubstitutionMap(fromDecl);
1514-
auto toSubMap = toCollection->getContextSubstitutionMap(toDecl);
1512+
auto fromArgs = cast<BoundGenericType>(fromCollection)->getGenericArgs();
1513+
auto toArgs = cast<BoundGenericType>(toCollection)->getGenericArgs();
1514+
replacementTypes.insert(replacementTypes.end(),
1515+
fromArgs.begin(), fromArgs.end());
1516+
replacementTypes.insert(replacementTypes.end(),
1517+
toArgs.begin(), toArgs.end());
15151518

15161519
// Form type parameter substitutions.
15171520
auto genericSig = fn->getGenericSignature();
1518-
unsigned fromParamCount = fromDecl->getGenericSignature()
1519-
.getGenericParams().size();
1520-
15211521
auto subMap =
1522-
SubstitutionMap::combineSubstitutionMaps(fromSubMap,
1523-
toSubMap,
1524-
CombineSubstitutionMaps::AtIndex,
1525-
fromParamCount,
1526-
0,
1527-
genericSig);
1522+
SubstitutionMap::get(genericSig, replacementTypes,
1523+
LookUpConformanceInModule());
15281524
return emitApplyOfLibraryIntrinsic(loc, fn, subMap, {mv}, C);
15291525
}
15301526

@@ -6353,19 +6349,18 @@ SILGenFunction::emitArrayToPointer(SILLocation loc, ManagedValue array,
63536349
assert(array.isLValue());
63546350
}
63556351

6352+
diagnoseImplicitRawConversion(accessInfo.ArrayType, accessInfo.PointerType,
6353+
loc, *this);
6354+
63566355
// Invoke the conversion intrinsic, which will produce an owner-pointer pair.
6357-
auto firstSubMap =
6358-
accessInfo.ArrayType->getContextSubstitutionMap();
6359-
auto secondSubMap = accessInfo.PointerType->getContextSubstitutionMap(
6360-
getPointerProtocol());
6356+
SmallVector<Type, 2> replacementTypes;
6357+
replacementTypes.push_back(
6358+
accessInfo.ArrayType->castTo<BoundGenericStructType>()->getGenericArgs()[0]);
6359+
replacementTypes.push_back(accessInfo.PointerType);
63616360

63626361
auto genericSig = converter->getGenericSignature();
6363-
auto subMap = SubstitutionMap::combineSubstitutionMaps(
6364-
firstSubMap, secondSubMap, CombineSubstitutionMaps::AtIndex, 1, 0,
6365-
genericSig);
6366-
6367-
diagnoseImplicitRawConversion(accessInfo.ArrayType, accessInfo.PointerType,
6368-
loc, *this);
6362+
auto subMap = SubstitutionMap::get(genericSig, replacementTypes,
6363+
LookUpConformanceInModule());
63696364

63706365
SmallVector<ManagedValue, 2> resultScalars;
63716366
emitApplyOfLibraryIntrinsic(loc, converter, subMap, array, SGFContext())

0 commit comments

Comments
 (0)