Skip to content

Commit fb7b639

Browse files
authored
Merge pull request #71532 from slavapestov/assoc-type-regression-fixes
Fixes for a few regressions with associated type inference
2 parents bd17b06 + 615f686 commit fb7b639

19 files changed

+316
-217
lines changed

include/swift/AST/Module.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -862,11 +862,8 @@ class ModuleDecl
862862

863863
/// Collect the conformances of \c fromType to each of the protocols of an
864864
/// existential type's layout.
865-
///
866-
/// See `TypeChecker::containsProtocol` for details on the boolean arguments.
867865
ArrayRef<ProtocolConformanceRef>
868866
collectExistentialConformances(CanType fromType, CanType existential,
869-
bool skipConditionalRequirements = true,
870867
bool allowMissing = false);
871868

872869
/// Find a member named \p name in \p container that was declared in this

include/swift/AST/TypeCheckRequests.h

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -323,30 +323,6 @@ class ExistentialConformsToSelfRequest :
323323
void cacheResult(bool value) const;
324324
};
325325

326-
class CollectExistentialConformancesRequest
327-
: public SimpleRequest<CollectExistentialConformancesRequest,
328-
ArrayRef<ProtocolConformanceRef>(ModuleDecl*,
329-
CanType,
330-
CanType,
331-
bool,
332-
bool),
333-
RequestFlags::Uncached> { // TODO: maybe cache this?
334-
public:
335-
using SimpleRequest::SimpleRequest;
336-
337-
private:
338-
friend SimpleRequest;
339-
340-
// Evaluation.
341-
ArrayRef<ProtocolConformanceRef>
342-
evaluate(Evaluator &evaluator,
343-
ModuleDecl *module,
344-
CanType fromType,
345-
CanType existential,
346-
bool skipConditionalRequirements,
347-
bool allowMissing) const;
348-
};
349-
350326
/// Determine whether an existential type conforming to this protocol
351327
/// requires the \c any syntax.
352328
class HasSelfOrAssociatedTypeRequirementsRequest :

include/swift/AST/TypeCheckerTypeIDZone.def

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,6 @@ SWIFT_REQUEST(TypeChecker, EnumRawTypeRequest,
101101
Type(EnumDecl *), Cached, NoLocationInfo)
102102
SWIFT_REQUEST(TypeChecker, ExistentialConformsToSelfRequest,
103103
bool(ProtocolDecl *), SeparatelyCached, NoLocationInfo)
104-
SWIFT_REQUEST(TypeChecker, CollectExistentialConformancesRequest,
105-
ArrayRef<ProtocolConformanceRef>(ModuleDecl*,
106-
CanType,
107-
CanType,
108-
bool,
109-
bool),
110-
Uncached, NoLocationInfo)
111104
SWIFT_REQUEST(TypeChecker, HasSelfOrAssociatedTypeRequirementsRequest,
112105
bool(ProtocolDecl *), SeparatelyCached, NoLocationInfo)
113106
SWIFT_REQUEST(TypeChecker, ExtendedTypeRequest, Type(ExtensionDecl *), Cached,

lib/AST/ConformanceLookup.cpp

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,20 @@ using namespace swift;
4747
ArrayRef<ProtocolConformanceRef>
4848
ModuleDecl::collectExistentialConformances(CanType fromType,
4949
CanType existential,
50-
bool skipConditionalRequirements,
5150
bool allowMissing) {
52-
CollectExistentialConformancesRequest request{this,
53-
fromType,
54-
existential,
55-
skipConditionalRequirements,
56-
allowMissing};
57-
return evaluateOrDefault(getASTContext().evaluator, request, /*default=*/{});
51+
assert(existential.isAnyExistentialType());
52+
53+
auto layout = existential.getExistentialLayout();
54+
auto protocols = layout.getProtocols();
55+
56+
SmallVector<ProtocolConformanceRef, 4> conformances;
57+
for (auto *proto : protocols) {
58+
auto conformance = lookupConformance(fromType, proto, allowMissing);
59+
assert(conformance);
60+
conformances.push_back(conformance);
61+
}
62+
63+
return getASTContext().AllocateCopy(conformances);
5864
}
5965

6066
ProtocolConformanceRef

lib/SILGen/SILGenPoly.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,6 @@ static ManagedValue emitTransformExistential(SILGenFunction &SGF,
279279
SGF.SGM.M.getSwiftModule()->collectExistentialConformances(
280280
fromInstanceType,
281281
toInstanceType,
282-
/*skipConditionalRequirements=*/true,
283282
/*allowMissing=*/true);
284283

285284
// Build result existential

0 commit comments

Comments
 (0)