File tree Expand file tree Collapse file tree 3 files changed +52
-3
lines changed Expand file tree Collapse file tree 3 files changed +52
-3
lines changed Original file line number Diff line number Diff line change @@ -1443,10 +1443,13 @@ void IRGenModule::maybeEmitOpaqueTypeDecl(OpaqueTypeDecl *opaque) {
1443
1443
addRuntimeResolvableType (opaque);
1444
1444
if (IRGen.hasLazyMetadata (opaque))
1445
1445
IRGen.noteUseOfOpaqueTypeDescriptor (opaque);
1446
- else
1447
- emitOpaqueTypeDecl (opaque);
1446
+ else {
1447
+ if (IRGen.EmittedNonLazyOpaqueTypeDecls .insert (opaque).second )
1448
+ emitOpaqueTypeDecl (opaque);
1449
+ }
1448
1450
} else if (!IRGen.hasLazyMetadata (opaque)) {
1449
- emitOpaqueTypeDecl (opaque);
1451
+ if (IRGen.EmittedNonLazyOpaqueTypeDecls .insert (opaque).second )
1452
+ emitOpaqueTypeDecl (opaque);
1450
1453
}
1451
1454
}
1452
1455
Original file line number Diff line number Diff line change @@ -301,6 +301,10 @@ class IRGenerator {
301
301
llvm::DenseMap<OpaqueTypeDecl*, LazyOpaqueInfo> LazyOpaqueTypes;
302
302
// / The queue of opaque type descriptors to emit.
303
303
llvm::SmallVector<OpaqueTypeDecl*, 4 > LazyOpaqueTypeDescriptors;
304
+ public:
305
+ // / The set of eagerly emitted opaque types.
306
+ llvm::SmallPtrSet<OpaqueTypeDecl *, 4 > EmittedNonLazyOpaqueTypeDecls;
307
+ private:
304
308
305
309
// / The queue of lazy field metadata records to emit.
306
310
llvm::SmallVector<NominalTypeDecl *, 4 > LazyFieldDescriptors;
Original file line number Diff line number Diff line change
1
+ // RUN: %target-swift-frontend -enable-library-evolution -emit-ir %s
2
+
3
+ // REQUIRES: OS=macosx
4
+
5
+ // This test used to crash with a duplicate LLVM IR definition.
6
+
7
+ @available ( macOS 11 . 0 , * )
8
+ public protocol Proto1 { }
9
+
10
+ @available ( macOS 11 . 0 , * )
11
+ public struct Thing { }
12
+
13
+ @available ( macOS 11 . 0 , * )
14
+ public struct Thing0 : Proto1 {
15
+ public init ( ) { }
16
+ }
17
+ @available ( macOS 11 . 0 , * )
18
+ @_marker public protocol MarkerProto { }
19
+
20
+ @available ( macOS 11 . 0 , * )
21
+ @frozen
22
+ @usableFromInline
23
+ struct LimitedAvailability : Proto1 , MarkerProto { }
24
+
25
+ @available ( macOS 11 . 0 , * )
26
+ extension Thing {
27
+ @_alwaysEmitIntoClient
28
+ public static func doIt(
29
+ _ thingy: ( any Proto1 & MarkerProto ) ?
30
+ ) -> some Proto1 {
31
+ if #available( macOS 13 . 0 , * ) {
32
+ return thingy as! LimitedAvailability
33
+ } else {
34
+ return Thing0 ( )
35
+ }
36
+ }
37
+ }
38
+
39
+ @available ( macOS 11 . 0 , * )
40
+ public func doIt( _ thingy: ( any Proto1 & MarkerProto ) ? ) -> some Proto1 {
41
+ return Thing . doIt ( thingy)
42
+ }
You can’t perform that action at this time.
0 commit comments