@@ -72,21 +72,6 @@ static Decl *lookupDirectSingleWithoutExtensions(NominalTypeDecl *decl,
7272 return dyn_cast<Decl>(results.front ());
7373}
7474
75- // / Similar to ModuleDecl::conformsToProtocol, but doesn't introduce a
76- // / dependency on Sema.
77- static bool isConcreteAndValid (ProtocolConformanceRef conformanceRef) {
78- if (conformanceRef.isInvalid ())
79- return false ;
80- if (!conformanceRef.isConcrete ())
81- return false ;
82- auto conformance = conformanceRef.getConcrete ();
83- auto subMap = conformance->getSubstitutionMap ();
84- return llvm::all_of (subMap.getConformances (),
85- [&](ProtocolConformanceRef each) -> bool {
86- return isConcreteAndValid (each);
87- });
88- }
89-
9075static FuncDecl *getInsertFunc (NominalTypeDecl *decl,
9176 TypeAliasDecl *valueType) {
9277 ASTContext &ctx = decl->getASTContext ();
@@ -226,9 +211,7 @@ static FuncDecl *getMinusOperator(NominalTypeDecl *decl) {
226211 if (lhsNominal != rhsNominal || lhsNominal != decl)
227212 return false ;
228213 auto returnTy = minus->getResultInterfaceType ();
229- auto conformanceRef =
230- lookupConformance (returnTy, binaryIntegerProto);
231- if (!isConcreteAndValid (conformanceRef))
214+ if (!checkConformance (returnTy, binaryIntegerProto))
232215 return false ;
233216 return true ;
234217 };
@@ -722,8 +705,8 @@ void swift::conformToCxxSequenceIfNeeded(
722705
723706 // Check if RawIterator conforms to UnsafeCxxInputIterator.
724707 auto rawIteratorConformanceRef =
725- lookupConformance (rawIteratorTy, cxxIteratorProto);
726- if (!isConcreteAndValid ( rawIteratorConformanceRef) )
708+ checkConformance (rawIteratorTy, cxxIteratorProto);
709+ if (!rawIteratorConformanceRef)
727710 return ;
728711 auto rawIteratorConformance = rawIteratorConformanceRef.getConcrete ();
729712 auto pointeeDecl =
@@ -768,9 +751,7 @@ void swift::conformToCxxSequenceIfNeeded(
768751 return false ;
769752
770753 // Check if RawIterator conforms to UnsafeCxxRandomAccessIterator.
771- auto rawIteratorRAConformanceRef =
772- lookupConformance (rawIteratorTy, cxxRAIteratorProto);
773- if (!isConcreteAndValid (rawIteratorRAConformanceRef))
754+ if (!checkConformance (rawIteratorTy, cxxRAIteratorProto))
774755 return false ;
775756
776757 // CxxRandomAccessCollection always uses Int as an Index.
@@ -890,9 +871,7 @@ void swift::conformToCxxSetIfNeeded(ClangImporter::Implementation &impl,
890871
891872 auto rawMutableIteratorTy = rawMutableIteratorType->getUnderlyingType ();
892873 // Check if RawMutableIterator conforms to UnsafeCxxInputIterator.
893- auto rawIteratorConformanceRef =
894- lookupConformance (rawMutableIteratorTy, cxxIteratorProto);
895- if (!isConcreteAndValid (rawIteratorConformanceRef))
874+ if (!checkConformance (rawMutableIteratorTy, cxxIteratorProto))
896875 return ;
897876
898877 impl.addSynthesizedTypealias (decl, ctx.getIdentifier (" RawMutableIterator" ),
@@ -973,15 +952,11 @@ void swift::conformToCxxDictionaryIfNeeded(
973952 auto rawMutableIteratorTy = mutableIterType->getUnderlyingType ();
974953
975954 // Check if RawIterator conforms to UnsafeCxxInputIterator.
976- auto rawIteratorConformanceRef =
977- lookupConformance (rawIteratorTy, cxxInputIteratorProto);
978- if (!isConcreteAndValid (rawIteratorConformanceRef))
955+ if (!checkConformance (rawIteratorTy, cxxInputIteratorProto))
979956 return ;
980957
981958 // Check if RawMutableIterator conforms to UnsafeCxxMutableInputIterator.
982- auto rawMutableIteratorConformanceRef = lookupConformance (
983- rawMutableIteratorTy, cxxMutableInputIteratorProto);
984- if (!isConcreteAndValid (rawMutableIteratorConformanceRef))
959+ if (!checkConformance (rawMutableIteratorTy, cxxMutableInputIteratorProto))
985960 return ;
986961
987962 // Make the original subscript that returns a non-optional value unavailable.
@@ -1039,9 +1014,7 @@ void swift::conformToCxxVectorIfNeeded(ClangImporter::Implementation &impl,
10391014 auto rawIteratorTy = iterType->getUnderlyingType ();
10401015
10411016 // Check if RawIterator conforms to UnsafeCxxRandomAccessIterator.
1042- auto rawIteratorConformanceRef =
1043- lookupConformance (rawIteratorTy, cxxRandomAccessIteratorProto);
1044- if (!isConcreteAndValid (rawIteratorConformanceRef))
1017+ if (!checkConformance (rawIteratorTy, cxxRandomAccessIteratorProto))
10451018 return ;
10461019
10471020 impl.addSynthesizedTypealias (decl, ctx.Id_Element ,
0 commit comments