Skip to content

Commit e71788d

Browse files
committed
[GenericSigBuilder] Conformances due to concrete types can be abstract.
When a type parameter is made concrete via an existential type, conformance requirements on that type parameter will be abstract. Fixes rdar://problem/30610428.
1 parent 5f4b2cf commit e71788d

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

lib/AST/GenericSignatureBuilder.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1934,10 +1934,15 @@ bool GenericSignatureBuilder::addSameTypeRequirementToConcrete(
19341934

19351935
conformances.insert({protocol, *conformance});
19361936

1937+
// Abstract conformances are acceptable for existential types.
1938+
assert(conformance->isConcrete() || Concrete->isExistentialType());
1939+
19371940
// Update the requirement source now that we know it's concrete.
19381941
// FIXME: Bad concrete source info.
19391942
auto concreteSource = Source->viaConcrete(*this,
1940-
conformance->getConcrete());
1943+
conformance->isConcrete()
1944+
? conformance->getConcrete()
1945+
: nullptr);
19411946
updateRequirementSource(conforms.second, concreteSource);
19421947
}
19431948
}

test/Generics/requirement_inference.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,3 +230,20 @@ struct X11<T: P12, U: P12> where T.B == U.B.A {
230230
// CHECK: Canonical generic signature: <τ_0_0, τ_0_1, τ_1_0 where τ_0_0 : P12, τ_0_1 == X10, τ_0_0.B == X10>
231231
func upperSameTypeConstraint<V>(_: V) where U == X10 { }
232232
}
233+
234+
#if _runtime(_ObjC)
235+
// rdar://problem/30610428
236+
@objc protocol P14 { }
237+
238+
class X12<S: AnyObject> {
239+
func bar<V>(v: V) where S == P14 {
240+
}
241+
}
242+
243+
@objc protocol P15: P14 { }
244+
245+
class X13<S: P14> {
246+
func bar<V>(v: V) where S == P15 {
247+
}
248+
}
249+
#endif

0 commit comments

Comments
 (0)