@@ -236,7 +236,7 @@ bool AbstractionPattern::requiresClass() const {
236
236
// ObjC generics are always class constrained.
237
237
return true ;
238
238
}
239
-
239
+
240
240
assert (GenericSig &&
241
241
" Dependent type in pattern without generic signature?" );
242
242
return GenericSig->requiresClass (type);
@@ -250,30 +250,23 @@ bool AbstractionPattern::requiresClass() const {
250
250
}
251
251
252
252
LayoutConstraint AbstractionPattern::getLayoutConstraint () const {
253
- // TODO: `ArchetypeType::getLayoutConstraint` and
254
- // `GenericSignature::getLayoutConstraint` don't always propagate implied
255
- // layout constraints from protocol/class constraints. `requiresClass`
256
- // is, for the time being, the only one we really care about, though, and
257
- // it behaves correctly.
258
- if (requiresClass ()) {
259
- return LayoutConstraint::getLayoutConstraint (LayoutConstraintKind::Class);
260
- }
261
- return LayoutConstraint ();
262
-
263
- #if GET_LAYOUT_CONSTRAINT_WORKED_THE_WAY_I_WANT
264
253
switch (getKind ()) {
265
254
case Kind::Opaque:
266
255
return LayoutConstraint ();
267
256
case Kind::Type:
268
- case Kind::Discard: {
257
+ case Kind::Discard:
258
+ case Kind::ClangType: {
269
259
auto type = getType ();
270
260
if (auto archetype = dyn_cast<ArchetypeType>(type)) {
271
- auto archetypeSig = archetype->getGenericEnvironment ()
272
- ->getGenericSignature ();
273
- return archetypeSig->getLayoutConstraint (archetype->getInterfaceType ());
274
- }
275
- else if (isa<DependentMemberType>(type) ||
276
- isa<GenericTypeParamType>(type)) {
261
+ return archetype->getLayoutConstraint ();
262
+ } else if (isa<DependentMemberType>(type) ||
263
+ isa<GenericTypeParamType>(type)) {
264
+ if (getKind () == Kind::ClangType) {
265
+ // ObjC generics are always class constrained.
266
+ return LayoutConstraint::getLayoutConstraint (
267
+ LayoutConstraintKind::Class);
268
+ }
269
+
277
270
assert (GenericSig &&
278
271
" Dependent type in pattern without generic signature?" );
279
272
return GenericSig->getLayoutConstraint (type);
@@ -283,7 +276,6 @@ LayoutConstraint AbstractionPattern::getLayoutConstraint() const {
283
276
default :
284
277
return LayoutConstraint ();
285
278
}
286
- #endif
287
279
}
288
280
289
281
bool AbstractionPattern::matchesTuple (CanTupleType substType) {
0 commit comments