@@ -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