Skip to content

Commit f989aa2

Browse files
authored
SR-12486: T.self is Any.Protocol is broken (#31662)
* SR-12486: `T.self is Any.Protocol` is broken This turned out to be fallout from #27572 which was in turn motivated by our confusing metatype syntax when generic variables are bound to protocols. In particular, the earlier PR was an attempt to make the expression `x is T.Type` (where `T` is a generic type variable bound to a protocol `P`) behave the same as `x is P.Type` (where `P` is a protocol). Unfortunately, the generic `T.Type` actually binds to `P.Protocol` in this case (not `P.Type`), so the original motivation was flawed, and as it happens, `x is T.Type` already behaved the same as `x is P.Protocol` in this situation. This PR reverts that earlier change and beefs up some of the tests around these behaviors. Resolves SR-12486 Resolves rdar://62201613 Reverts PR#27572
1 parent b871528 commit f989aa2

File tree

4 files changed

+219
-125
lines changed

4 files changed

+219
-125
lines changed

stdlib/public/runtime/Casting.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,13 +1183,6 @@ swift_dynamicCastMetatypeImpl(const Metadata *sourceType,
11831183
}
11841184
break;
11851185

1186-
case MetadataKind::Existential: {
1187-
auto targetTypeAsExistential = static_cast<const ExistentialTypeMetadata *>(targetType);
1188-
if (_conformsToProtocols(nullptr, sourceType, targetTypeAsExistential, nullptr))
1189-
return origSourceType;
1190-
return nullptr;
1191-
}
1192-
11931186
default:
11941187
return nullptr;
11951188
}

0 commit comments

Comments
 (0)