Skip to content

Commit 2d066dd

Browse files
committed
RequirementMachine: Do a better job of filtering out invalid superclass and concrete type requirements
In the long run it doesn't really matter if we leave them in there, but for now matching the GenericSignatureBuilder's behavior makes the tests pass with -requirement-machine-inferred-signatures=verify.
1 parent d64fb39 commit 2d066dd

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

lib/AST/RequirementMachine/RequirementMachineRequests.cpp

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,21 +123,41 @@ RequirementMachine::buildRequirementsFromRules(
123123
return;
124124

125125
case Symbol::Kind::Superclass: {
126-
// For compatibility with the old GenericSignatureBuilder, drop requirements
127-
// containing ErrorTypes.
126+
// Requirements containing unresolved name symbols originate from
127+
// invalid code and should not appear in the generic signature.
128+
for (auto term : prop->getSubstitutions()) {
129+
if (term.containsUnresolvedSymbols())
130+
return;
131+
}
132+
133+
// Requirements containing error types originate from invalid code
134+
// and should not appear in the generic signature.
135+
if (prop->getConcreteType()->hasError())
136+
return;
137+
128138
auto superclassType = Map.getTypeFromSubstitutionSchema(
129139
prop->getConcreteType(),
130140
prop->getSubstitutions(),
131141
genericParams, MutableTerm());
132-
if (superclassType->hasError())
133-
return;
134142

135143
reqs.emplace_back(RequirementKind::Superclass,
136144
subjectType, superclassType);
137145
return;
138146
}
139147

140148
case Symbol::Kind::ConcreteType: {
149+
// Requirements containing unresolved name symbols originate from
150+
// invalid code and should not appear in the generic signature.
151+
for (auto term : prop->getSubstitutions()) {
152+
if (term.containsUnresolvedSymbols())
153+
return;
154+
}
155+
156+
// Requirements containing error types originate from invalid code
157+
// and should not appear in the generic signature.
158+
if (prop->getConcreteType()->hasError())
159+
return;
160+
141161
auto concreteType = Map.getTypeFromSubstitutionSchema(
142162
prop->getConcreteType(),
143163
prop->getSubstitutions(),

0 commit comments

Comments
 (0)