File tree Expand file tree Collapse file tree 3 files changed +29
-3
lines changed Expand file tree Collapse file tree 3 files changed +29
-3
lines changed Original file line number Diff line number Diff line change @@ -1181,6 +1181,11 @@ class ASTContext final {
1181
1181
rewriting::RequirementMachine *getOrCreateRequirementMachine (
1182
1182
CanGenericSignature sig);
1183
1183
1184
+ // / This is a hack to break cycles. Don't introduce new callers of this
1185
+ // / method.
1186
+ bool isRecursivelyConstructingRequirementMachine (
1187
+ CanGenericSignature sig);
1188
+
1184
1189
// / Retrieve a generic signature with a single unconstrained type parameter,
1185
1190
// / like `<T>`.
1186
1191
CanGenericSignature getSingleGenericParameterSignature () const ;
Original file line number Diff line number Diff line change @@ -1997,6 +1997,22 @@ ASTContext::getOrCreateRequirementMachine(CanGenericSignature sig) {
1997
1997
return machine;
1998
1998
}
1999
1999
2000
+ bool ASTContext::isRecursivelyConstructingRequirementMachine (
2001
+ CanGenericSignature sig) {
2002
+ auto &rewriteCtx = getImpl ().TheRewriteContext ;
2003
+ if (!rewriteCtx)
2004
+ return false ;
2005
+
2006
+ auto arena = getArena (sig);
2007
+ auto &machines = getImpl ().getArena (arena).RequirementMachines ;
2008
+
2009
+ auto found = machines.find (sig);
2010
+ if (found == machines.end ())
2011
+ return false ;
2012
+
2013
+ return !found->second ->isComplete ();
2014
+ }
2015
+
2000
2016
Optional<llvm::TinyPtrVector<ValueDecl *>>
2001
2017
OverriddenDeclsRequest::getCachedResult () const {
2002
2018
auto decl = std::get<0 >(getStorage ());
Original file line number Diff line number Diff line change @@ -819,9 +819,14 @@ Type AssociatedTypeInference::computeFixedTypeWitness(
819
819
!conformedProto->inheritsFrom (assocType->getProtocol ()))
820
820
continue ;
821
821
822
- const auto ty =
823
- conformedProto->getGenericSignature ()->getCanonicalTypeInContext (
824
- structuralTy);
822
+ auto sig = conformedProto->getGenericSignature ();
823
+
824
+ // FIXME: The RequirementMachine will assert on re-entrant construction.
825
+ // We should find a more principled way of breaking this cycle.
826
+ if (ctx.isRecursivelyConstructingRequirementMachine (sig.getCanonicalSignature ()))
827
+ continue ;
828
+
829
+ const auto ty = sig->getCanonicalTypeInContext (structuralTy);
825
830
826
831
// A dependent member type with an identical base and name indicates that
827
832
// the protocol does not same-type constrain it in any way; move on to
You can’t perform that action at this time.
0 commit comments