Skip to content

Commit d9bc9a2

Browse files
authored
Merge pull request #82655 from DougGregor/isolated-conformances-collection-literals-6.2
[6.2] [SE-0470] Check uses of isolated conformances in collection literals
2 parents c1d96d6 + 96583f1 commit d9bc9a2

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3496,6 +3496,13 @@ namespace {
34963496
getDeclContext(), RefineConformances{*this});
34973497
}
34983498

3499+
if (auto *collectionExpr = dyn_cast<CollectionExpr>(expr)) {
3500+
checkIsolatedConformancesInContext(
3501+
collectionExpr->getInitializer(),
3502+
collectionExpr->getLoc(),
3503+
getDeclContext(), RefineConformances{*this});
3504+
}
3505+
34993506
return Action::Continue(expr);
35003507
}
35013508

test/Concurrency/isolated_conformance.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,3 +186,12 @@ func testIsolatedConformancesOnAssociatedTypes(hc: HoldsC, c: C) {
186186
// associated type.
187187
HoldsC.acceptSendableAliased(C.self)
188188
}
189+
190+
191+
struct MyHashable: @MainActor Hashable {
192+
var counter = 0
193+
}
194+
195+
@concurrent func testMyHashableSet() async {
196+
let _: Set<MyHashable> = [] // expected-warning{{main actor-isolated conformance of 'MyHashable' to 'Hashable' cannot be used in nonisolated context}}
197+
}

0 commit comments

Comments
 (0)