@@ -1507,24 +1507,20 @@ RValue SILGenFunction::emitCollectionConversion(SILLocation loc,
1507
1507
CanType toCollection,
1508
1508
ManagedValue mv,
1509
1509
SGFContext C) {
1510
- auto *fromDecl = fromCollection->getAnyNominal ();
1511
- auto *toDecl = toCollection->getAnyNominal ();
1510
+ SmallVector<Type, 4 > replacementTypes;
1512
1511
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 ());
1515
1518
1516
1519
// Form type parameter substitutions.
1517
1520
auto genericSig = fn->getGenericSignature ();
1518
- unsigned fromParamCount = fromDecl->getGenericSignature ()
1519
- .getGenericParams ().size ();
1520
-
1521
1521
auto subMap =
1522
- SubstitutionMap::combineSubstitutionMaps (fromSubMap,
1523
- toSubMap,
1524
- CombineSubstitutionMaps::AtIndex,
1525
- fromParamCount,
1526
- 0 ,
1527
- genericSig);
1522
+ SubstitutionMap::get (genericSig, replacementTypes,
1523
+ LookUpConformanceInModule ());
1528
1524
return emitApplyOfLibraryIntrinsic (loc, fn, subMap, {mv}, C);
1529
1525
}
1530
1526
@@ -6353,19 +6349,18 @@ SILGenFunction::emitArrayToPointer(SILLocation loc, ManagedValue array,
6353
6349
assert (array.isLValue ());
6354
6350
}
6355
6351
6352
+ diagnoseImplicitRawConversion (accessInfo.ArrayType , accessInfo.PointerType ,
6353
+ loc, *this );
6354
+
6356
6355
// 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 );
6361
6360
6362
6361
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 ());
6369
6364
6370
6365
SmallVector<ManagedValue, 2 > resultScalars;
6371
6366
emitApplyOfLibraryIntrinsic (loc, converter, subMap, array, SGFContext ())
0 commit comments