Skip to content

Commit f7d94d9

Browse files
authored
Merge pull request swiftlang#5627 from rudkx/fix-rdar28317710
Do not assume Set/Dictionary are always bound generic types.
2 parents be99a3b + c7f448f commit f7d94d9

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

lib/Sema/TypeCheckProtocol.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4567,12 +4567,14 @@ void TypeChecker::useObjectiveCBridgeableConformances(DeclContext *dc,
45674567
// of the key type to Hashable.
45684568
if (nominalDecl == TC.Context.getSetDecl() ||
45694569
nominalDecl == TC.Context.getDictionaryDecl()) {
4570-
auto args = ty->castTo<BoundGenericType>()->getGenericArgs();
4571-
if (!args.empty()) {
4572-
auto keyType = args[0];
4573-
auto *hashableProto =
4574-
TC.Context.getProtocol(KnownProtocolKind::Hashable);
4575-
(void)TC.conformsToProtocol(keyType, hashableProto, DC, options);
4570+
if (auto boundGeneric = ty->getAs<BoundGenericType>()) {
4571+
auto args = boundGeneric->getGenericArgs();
4572+
if (!args.empty()) {
4573+
auto keyType = args[0];
4574+
auto *hashableProto =
4575+
TC.Context.getProtocol(KnownProtocolKind::Hashable);
4576+
(void)TC.conformsToProtocol(keyType, hashableProto, DC, options);
4577+
}
45764578
}
45774579
}
45784580
}

validation-test/Sema/type_checker_crashers/rdar28317710.swift

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// RUN: not %target-swift-frontend %s -parse
2+
// REQUIRES: OS=macosx
3+
4+
let array = [Dictionary]()

0 commit comments

Comments
 (0)