Skip to content

Commit 4d3a8c2

Browse files
committed
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 de6d393 commit 4d3a8c2

File tree

3 files changed

+182
-114
lines changed

3 files changed

+182
-114
lines changed

stdlib/public/runtime/Casting.cpp

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

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

0 commit comments

Comments
 (0)