@@ -440,6 +440,8 @@ synthesizeStructDefaultConstructorBody(AbstractFunctionDecl *afd,
440440 ASTContext &ctx = constructor->getASTContext ();
441441 auto structDecl = static_cast <StructDecl *>(context);
442442
443+ auto *module = structDecl->getParentModule ();
444+
443445 // Use a builtin to produce a zero initializer, and assign it to self.
444446
445447 // Construct the left-hand reference to self.
@@ -456,7 +458,8 @@ synthesizeStructDefaultConstructorBody(AbstractFunctionDecl *afd,
456458 cast<FuncDecl>(getBuiltinValueDecl (ctx, zeroInitID));
457459 SubstitutionMap subMap =
458460 SubstitutionMap::get (zeroInitializerFunc->getGenericSignature (),
459- llvm::makeArrayRef (selfType), {});
461+ llvm::makeArrayRef (selfType),
462+ LookUpConformanceInModule (module ));
460463 ConcreteDeclRef concreteDeclRef (zeroInitializerFunc, subMap);
461464 auto zeroInitializerRef =
462465 new (ctx) DeclRefExpr (concreteDeclRef, DeclNameLoc (), /* implicit*/ true );
@@ -822,6 +825,8 @@ synthesizeUnionFieldGetterBody(AbstractFunctionDecl *afd, void *context) {
822825 ASTContext &ctx = getterDecl->getASTContext ();
823826 auto importedFieldDecl = static_cast <VarDecl *>(context);
824827
828+ auto *module = afd->getParentModule ();
829+
825830 auto selfDecl = getterDecl->getImplicitSelfDecl ();
826831
827832 auto selfRef = new (ctx) DeclRefExpr (selfDecl, DeclNameLoc (),
@@ -836,7 +841,7 @@ synthesizeUnionFieldGetterBody(AbstractFunctionDecl *afd, void *context) {
836841 SubstitutionMap::get (
837842 reinterpretCast->getGenericSignature (),
838843 {selfDecl->getInterfaceType (), importedFieldDecl->getInterfaceType ()},
839- ArrayRef<ProtocolConformanceRef>( )));
844+ LookUpConformanceInModule ( module )));
840845 auto reinterpretCastRefExpr =
841846 new (ctx) DeclRefExpr (reinterpretCastRef, DeclNameLoc (),
842847 /* implicit*/ true );
@@ -860,6 +865,8 @@ synthesizeUnionFieldGetterBody(AbstractFunctionDecl *afd, void *context) {
860865// / Synthesizer for the body of a union field setter.
861866static std::pair<BraceStmt *, bool >
862867synthesizeUnionFieldSetterBody (AbstractFunctionDecl *afd, void *context) {
868+ auto *module = afd->getParentModule ();
869+
863870 auto setterDecl = cast<AccessorDecl>(afd);
864871 ASTContext &ctx = setterDecl->getASTContext ();
865872
@@ -880,7 +887,7 @@ synthesizeUnionFieldSetterBody(AbstractFunctionDecl *afd, void *context) {
880887 ConcreteDeclRef addressofFnRef (
881888 addressofFn, SubstitutionMap::get (addressofFn->getGenericSignature (),
882889 {inoutSelfDecl->getInterfaceType ()},
883- ArrayRef<ProtocolConformanceRef>( )));
890+ LookUpConformanceInModule ( module )));
884891 auto addressofFnRefExpr =
885892 new (ctx) DeclRefExpr (addressofFnRef, DeclNameLoc (), /* implicit*/ true );
886893 // FIXME: Verify ExtInfo state is correct, not working by accident.
@@ -902,7 +909,7 @@ synthesizeUnionFieldSetterBody(AbstractFunctionDecl *afd, void *context) {
902909 ConcreteDeclRef initializeFnRef (
903910 initializeFn, SubstitutionMap::get (initializeFn->getGenericSignature (),
904911 {newValueDecl->getInterfaceType ()},
905- ArrayRef<ProtocolConformanceRef>( )));
912+ LookUpConformanceInModule ( module )));
906913 auto initializeFnRefExpr =
907914 new (ctx) DeclRefExpr (initializeFnRef, DeclNameLoc (), /* implicit*/ true );
908915 // FIXME: Verify ExtInfo state is correct, not working by accident.
@@ -1205,6 +1212,8 @@ static std::pair<BraceStmt *, bool>
12051212synthesizeEnumRawValueConstructorBody (AbstractFunctionDecl *afd,
12061213 void *context) {
12071214 ASTContext &ctx = afd->getASTContext ();
1215+ auto *module = afd->getParentModule ();
1216+
12081217 auto ctorDecl = cast<ConstructorDecl>(afd);
12091218 auto enumDecl = static_cast <EnumDecl *>(context);
12101219 auto selfDecl = ctorDecl->getImplicitSelfDecl ();
@@ -1222,7 +1231,8 @@ synthesizeEnumRawValueConstructorBody(AbstractFunctionDecl *afd,
12221231 auto rawTy = enumDecl->getRawType ();
12231232 auto enumTy = enumDecl->getDeclaredInterfaceType ();
12241233 SubstitutionMap subMap = SubstitutionMap::get (
1225- reinterpretCast->getGenericSignature (), {rawTy, enumTy}, {});
1234+ reinterpretCast->getGenericSignature (), {rawTy, enumTy},
1235+ LookUpConformanceInModule (module ));
12261236 ConcreteDeclRef concreteDeclRef (reinterpretCast, subMap);
12271237 auto reinterpretCastRef =
12281238 new (ctx) DeclRefExpr (concreteDeclRef, DeclNameLoc (), /* implicit*/ true );
@@ -1290,10 +1300,13 @@ synthesizeEnumRawValueGetterBody(AbstractFunctionDecl *afd, void *context) {
12901300 /* implicit*/ true );
12911301 selfRef->setType (selfDecl->getTypeInContext ());
12921302
1303+ auto *module = afd->getParentModule ();
1304+
12931305 auto reinterpretCast = cast<FuncDecl>(
12941306 getBuiltinValueDecl (ctx, ctx.getIdentifier (" reinterpretCast" )));
12951307 SubstitutionMap subMap = SubstitutionMap::get (
1296- reinterpretCast->getGenericSignature (), {enumTy, rawTy}, {});
1308+ reinterpretCast->getGenericSignature (), {enumTy, rawTy},
1309+ LookUpConformanceInModule (module ));
12971310 ConcreteDeclRef concreteDeclRef (reinterpretCast, subMap);
12981311
12991312 auto reinterpretCastRef =
@@ -1495,8 +1508,11 @@ Expr *SwiftDeclSynthesizer::synthesizeReturnReinterpretCast(ASTContext &ctx,
14951508 Expr *baseExpr) {
14961509 auto reinterpretCast = cast<FuncDecl>(
14971510 getBuiltinValueDecl (ctx, ctx.getIdentifier (" reinterpretCast" )));
1511+ auto *module = reinterpretCast->getParentModule ();
1512+
14981513 SubstitutionMap subMap = SubstitutionMap::get (
1499- reinterpretCast->getGenericSignature (), {givenType, exprType}, {});
1514+ reinterpretCast->getGenericSignature (), {givenType, exprType},
1515+ LookUpConformanceInModule (module ));
15001516 ConcreteDeclRef concreteDeclRef (reinterpretCast, subMap);
15011517 auto reinterpretCastRef =
15021518 new (ctx) DeclRefExpr (concreteDeclRef, DeclNameLoc (), /* implicit*/ true );
@@ -1519,6 +1535,8 @@ Expr *SwiftDeclSynthesizer::synthesizeReturnReinterpretCast(ASTContext &ctx,
15191535static std::pair<BraceStmt *, bool >
15201536synthesizeUnwrappingGetterOrAddressGetterBody (AbstractFunctionDecl *afd,
15211537 void *context, bool isAddress) {
1538+ auto *module = afd->getParentModule ();
1539+
15221540 auto getterDecl = cast<AccessorDecl>(afd);
15231541 auto getterImpl = static_cast <FuncDecl *>(context);
15241542
@@ -1550,7 +1568,8 @@ synthesizeUnwrappingGetterOrAddressGetterBody(AbstractFunctionDecl *afd,
15501568
15511569 // Handle operator[] that returns a reference type.
15521570 SubstitutionMap subMap = SubstitutionMap::get (
1553- ctx.getUnsafePointerDecl ()->getGenericSignature (), {elementTy}, {});
1571+ ctx.getUnsafePointerDecl ()->getGenericSignature (), {elementTy},
1572+ LookUpConformanceInModule (module ));
15541573 auto pointeePropertyRefExpr = new (ctx) MemberRefExpr (
15551574 getterImplCallExpr, SourceLoc (),
15561575 ConcreteDeclRef (pointeePropertyDecl, subMap), DeclNameLoc (),
@@ -1593,6 +1612,8 @@ synthesizeUnwrappingSetterBody(AbstractFunctionDecl *afd, void *context) {
15931612
15941613 ASTContext &ctx = setterDecl->getASTContext ();
15951614
1615+ auto *module = afd->getParentModule ();
1616+
15961617 auto selfArg = createSelfArg (setterDecl);
15971618 DeclRefExpr *valueParamRefExpr = createParamRefExpr (setterDecl, 0 );
15981619 // For a subscript this decl will have two parameters, for a pointee property
@@ -1611,7 +1632,7 @@ synthesizeUnwrappingSetterBody(AbstractFunctionDecl *afd, void *context) {
16111632
16121633 SubstitutionMap subMap = SubstitutionMap::get (
16131634 ctx.getUnsafeMutablePointerDecl ()->getGenericSignature (), {elementTy},
1614- {} );
1635+ LookUpConformanceInModule ( module ) );
16151636 auto pointeePropertyRefExpr = new (ctx)
16161637 MemberRefExpr (setterImplCallExpr, SourceLoc (),
16171638 ConcreteDeclRef (pointeePropertyDecl, subMap), DeclNameLoc (),
0 commit comments