File tree Expand file tree Collapse file tree 3 files changed +18
-16
lines changed Expand file tree Collapse file tree 3 files changed +18
-16
lines changed Original file line number Diff line number Diff line change @@ -150,9 +150,6 @@ class Witness {
150
150
// / Determines whether there is a witness at all.
151
151
explicit operator bool () const { return !storage.isNull (); }
152
152
153
- // / Determine whether this witness requires any substitutions.
154
- bool requiresSubstitution () const { return storage.is <StoredWitness *>(); }
155
-
156
153
// / Retrieve the substitutions required to use this witness from the
157
154
// / synthetic environment.
158
155
// /
@@ -164,15 +161,17 @@ class Witness {
164
161
165
162
// / Retrieve the synthetic generic environment.
166
163
GenericEnvironment *getSyntheticEnvironment () const {
167
- assert (requiresSubstitution () && " No substitutions required for witness" );
168
- return storage.get <StoredWitness *>()->syntheticEnvironment ;
164
+ if (auto *storedWitness = storage.dyn_cast <StoredWitness *>())
165
+ return storedWitness->syntheticEnvironment ;
166
+ return nullptr ;
169
167
}
170
168
171
169
// / Retrieve the substitution map that maps the interface types of the
172
170
// / requirement to the interface types of the synthetic environment.
173
171
SubstitutionList getRequirementToSyntheticSubs () const {
174
- assert (requiresSubstitution () && " No substitutions required for witness" );
175
- return storage.get <StoredWitness *>()->reqToSyntheticEnvSubs ;
172
+ if (auto *storedWitness = storage.dyn_cast <StoredWitness *>())
173
+ return storedWitness->reqToSyntheticEnvSubs ;
174
+ return {};
176
175
}
177
176
178
177
LLVM_ATTRIBUTE_DEPRECATED (
Original file line number Diff line number Diff line change @@ -2507,13 +2507,18 @@ class Verifier : public ASTWalker {
2507
2507
// Check the witness substitutions.
2508
2508
const auto &witness = normal->getWitness (req, nullptr );
2509
2509
2510
- if (witness.requiresSubstitution ()) {
2511
- GenericEnv.push_back ({witness.getSyntheticEnvironment ()});
2512
- for (const auto &sub : witness.getSubstitutions ()) {
2513
- verifyChecked (sub.getReplacement ());
2514
- }
2510
+ if (auto *genericEnv = witness.getSyntheticEnvironment ())
2511
+ GenericEnv.push_back ({genericEnv});
2512
+
2513
+ for (const auto &sub : witness.getRequirementToSyntheticSubs ())
2514
+ verifyChecked (sub.getReplacement ());
2515
+
2516
+ for (const auto &sub : witness.getSubstitutions ())
2517
+ verifyChecked (sub.getReplacement ());
2518
+
2519
+ if (auto *genericEnv = witness.getSyntheticEnvironment ()) {
2515
2520
assert (GenericEnv.back ().storage .dyn_cast <GenericEnvironment *>()
2516
- == witness. getSyntheticEnvironment () );
2521
+ == genericEnv );
2517
2522
GenericEnv.pop_back ();
2518
2523
}
2519
2524
Original file line number Diff line number Diff line change @@ -1573,9 +1573,7 @@ void Serializer::writeNormalConformance(
1573
1573
// Write the witness substitutions.
1574
1574
writeSubstitutions (witness.getSubstitutions (),
1575
1575
DeclTypeAbbrCodes,
1576
- witness.requiresSubstitution ()
1577
- ? witness.getSyntheticEnvironment ()
1578
- : nullptr );
1576
+ witness.getSyntheticEnvironment ());
1579
1577
});
1580
1578
}
1581
1579
You can’t perform that action at this time.
0 commit comments