mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Sema: Fixes for conformance between higher-kind metatypes
For a concrete type A and protocol type P, A <c P now implies A.Type <c P.Type, not just A.Type < P.Type. This in turn means that A.Type.Type <c P.Type.Type. To make the coercion work, recursively peel off metatype layers when collecting conformances and in a similar situation in IRGen. Swift SVN r29377
This commit is contained in:
@@ -1972,10 +1972,11 @@ ConstraintSystem::matchTypes(Type type1, Type type2, TypeMatchKind kind,
|
||||
}
|
||||
}
|
||||
|
||||
// A subtyping relation between a metatype and an existential
|
||||
// metatype is actually equivalent to a conformance relationship
|
||||
// on the instance types.
|
||||
if (concrete && kind >= TypeMatchKind::Subtype) {
|
||||
// Conformance of a metatype to an existential metatype is actually
|
||||
// equivalent to a conformance relationship on the instance types.
|
||||
// This applies to nested metatype levels, so if A : P then
|
||||
// A.Type : P.Type.
|
||||
if (concrete && kind >= TypeMatchKind::ConformsTo) {
|
||||
if (auto meta1 = type1->getAs<MetatypeType>()) {
|
||||
if (auto meta2 = type2->getAs<ExistentialMetatypeType>()) {
|
||||
return matchTypes(meta1->getInstanceType(),
|
||||
|
||||
Reference in New Issue
Block a user