@@ -72,21 +72,6 @@ static Decl *lookupDirectSingleWithoutExtensions(NominalTypeDecl *decl,
72
72
return dyn_cast<Decl>(results.front ());
73
73
}
74
74
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
-
90
75
static FuncDecl *getInsertFunc (NominalTypeDecl *decl,
91
76
TypeAliasDecl *valueType) {
92
77
ASTContext &ctx = decl->getASTContext ();
@@ -226,9 +211,7 @@ static FuncDecl *getMinusOperator(NominalTypeDecl *decl) {
226
211
if (lhsNominal != rhsNominal || lhsNominal != decl)
227
212
return false ;
228
213
auto returnTy = minus->getResultInterfaceType ();
229
- auto conformanceRef =
230
- lookupConformance (returnTy, binaryIntegerProto);
231
- if (!isConcreteAndValid (conformanceRef))
214
+ if (!checkConformance (returnTy, binaryIntegerProto))
232
215
return false ;
233
216
return true ;
234
217
};
@@ -722,8 +705,8 @@ void swift::conformToCxxSequenceIfNeeded(
722
705
723
706
// Check if RawIterator conforms to UnsafeCxxInputIterator.
724
707
auto rawIteratorConformanceRef =
725
- lookupConformance (rawIteratorTy, cxxIteratorProto);
726
- if (!isConcreteAndValid ( rawIteratorConformanceRef) )
708
+ checkConformance (rawIteratorTy, cxxIteratorProto);
709
+ if (!rawIteratorConformanceRef)
727
710
return ;
728
711
auto rawIteratorConformance = rawIteratorConformanceRef.getConcrete ();
729
712
auto pointeeDecl =
@@ -768,9 +751,7 @@ void swift::conformToCxxSequenceIfNeeded(
768
751
return false ;
769
752
770
753
// Check if RawIterator conforms to UnsafeCxxRandomAccessIterator.
771
- auto rawIteratorRAConformanceRef =
772
- lookupConformance (rawIteratorTy, cxxRAIteratorProto);
773
- if (!isConcreteAndValid (rawIteratorRAConformanceRef))
754
+ if (!checkConformance (rawIteratorTy, cxxRAIteratorProto))
774
755
return false ;
775
756
776
757
// CxxRandomAccessCollection always uses Int as an Index.
@@ -890,9 +871,7 @@ void swift::conformToCxxSetIfNeeded(ClangImporter::Implementation &impl,
890
871
891
872
auto rawMutableIteratorTy = rawMutableIteratorType->getUnderlyingType ();
892
873
// Check if RawMutableIterator conforms to UnsafeCxxInputIterator.
893
- auto rawIteratorConformanceRef =
894
- lookupConformance (rawMutableIteratorTy, cxxIteratorProto);
895
- if (!isConcreteAndValid (rawIteratorConformanceRef))
874
+ if (!checkConformance (rawMutableIteratorTy, cxxIteratorProto))
896
875
return ;
897
876
898
877
impl.addSynthesizedTypealias (decl, ctx.getIdentifier (" RawMutableIterator" ),
@@ -973,15 +952,11 @@ void swift::conformToCxxDictionaryIfNeeded(
973
952
auto rawMutableIteratorTy = mutableIterType->getUnderlyingType ();
974
953
975
954
// Check if RawIterator conforms to UnsafeCxxInputIterator.
976
- auto rawIteratorConformanceRef =
977
- lookupConformance (rawIteratorTy, cxxInputIteratorProto);
978
- if (!isConcreteAndValid (rawIteratorConformanceRef))
955
+ if (!checkConformance (rawIteratorTy, cxxInputIteratorProto))
979
956
return ;
980
957
981
958
// Check if RawMutableIterator conforms to UnsafeCxxMutableInputIterator.
982
- auto rawMutableIteratorConformanceRef = lookupConformance (
983
- rawMutableIteratorTy, cxxMutableInputIteratorProto);
984
- if (!isConcreteAndValid (rawMutableIteratorConformanceRef))
959
+ if (!checkConformance (rawMutableIteratorTy, cxxMutableInputIteratorProto))
985
960
return ;
986
961
987
962
// Make the original subscript that returns a non-optional value unavailable.
@@ -1039,9 +1014,7 @@ void swift::conformToCxxVectorIfNeeded(ClangImporter::Implementation &impl,
1039
1014
auto rawIteratorTy = iterType->getUnderlyingType ();
1040
1015
1041
1016
// Check if RawIterator conforms to UnsafeCxxRandomAccessIterator.
1042
- auto rawIteratorConformanceRef =
1043
- lookupConformance (rawIteratorTy, cxxRandomAccessIteratorProto);
1044
- if (!isConcreteAndValid (rawIteratorConformanceRef))
1017
+ if (!checkConformance (rawIteratorTy, cxxRandomAccessIteratorProto))
1045
1018
return ;
1046
1019
1047
1020
impl.addSynthesizedTypealias (decl, ctx.Id_Element ,
0 commit comments